Summary:
This fixes a regression on Android introduced by f3e5cce where JS errors thrown during bundle load were lost (shown only as UnknownCppException). It is especially tough to debug (custom) bundling errors without seeing the javascript error.
Root cause hypothesis: since switching to clang, `JSError`s thrown in ReactCommon's `JSCRuntime::checkException` were never matched as `std::exception` in ReactAndroid's `convertCppExceptionToJavaException` due to these missing flags.
I'm a bit shy on low-level details concerning how C++ rtti works exactly around catching exceptions thrown in other libraries. All I can say that with this change, a `bundle.android.js` that only contains `throw new Error("wtf");` now nicely outputs a message and stack trace in the logcat. Before (and since DanielZlotin's switch to clang) it just outputted:
```
2019-04-29 12:17:59.365 1162-1306/com.rntest E/unknown:ReactNative: Exception in native call
com.facebook.jni.UnknownCppException: Unknown
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:214)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
at java.lang.Thread.run(Thread.java:764)
```
[Android] [Fixed] - JS errors during bundle load were reported as UnknownCppException.
Pull Request resolved: https://github.com/facebook/react-native/pull/24648
Differential Revision: D15123525
Pulled By: mdvacca
fbshipit-source-id: 74b5ce9ebae38d172446b6e31739d795c601947b
Summary:
We are seeing crash reports that the webview is missing. In this case
it should fail gracefully so that a missing webview does not block
from using an app built with React Native.
The contains could also be changed to check for "webview" in general
to catch all webview related exception. It's currently checking on
for the specific string that I'm seeing in our app's crashreporting tool.
<img width="1507" alt="Screen Shot 2019-04-19 at 11 26 19 AM" src="https://user-images.githubusercontent.com/741767/56438307-5e1c2f80-6297-11e9-970b-a5095d18e9d7.png">
<img width="935" alt="Screen Shot 2019-04-19 at 11 32 58 AM" src="https://user-images.githubusercontent.com/741767/56438213-fa920200-6296-11e9-8008-5eb344eca8a8.png">
[Android] [Fixed] - The ReactCookieJarContainer/ForwardingCookieHandler now handles the missing WebView gracefully.
Pull Request resolved: https://github.com/facebook/react-native/pull/24533
Differential Revision: D15062824
Pulled By: cpojer
fbshipit-source-id: 80805a47494f0d924b7ee029ce8ca0504eaeee57
Summary:
Try to prevent the crash described in https://github.com/facebook/react-native/issues/17530
There seems to be a bug in `Drawable.mutate()` in some devices/android os versions even after you check the constant state. This error is hard to reproduce and to fix, so just try to catch the exception to prevent crash.
[Android][Fixed] Prevent random crash when setting underlineColorAndroid
Pull Request resolved: https://github.com/facebook/react-native/pull/24183
Differential Revision: D14710484
Pulled By: cpojer
fbshipit-source-id: 3af20a5cb0ecd40839beaf85118c0f5aa6905414
Summary: This diff fixes an IllegalStateException that is thrown when the user click is on a edit text and tap 'Next' on the keyboard to focus on the next view, but the next view is hidden.
Reviewed By: lunaleaps, mmmulani
Differential Revision: D14598410
fbshipit-source-id: 2999cc468ed24bedff163eedcfaec50f6ee005d6
Summary:
It crashes with IllegalStateException in case you pass a wrong URL.
It crashes if it meets unexpected symbols in the header name and value,
while standard says it is not recommended to use those symbols not that
they are prohibited.
The headers handing is a special use case as a client might have an auth token in the header. In this case, we want to get 401 error response
from the server to find out that token is wrong. In case of the onerror
client will continue to retry with an existing token.
[ANDROID][Fixed] - Networking: Passing invalid URL not crashes the app instead onerror callback of HttpClient is called. Invalid symbols are stripped from the headers to allow HTTP query to fail with 401 error code in case of the broken token.
Pull Request resolved: https://github.com/facebook/react-native/pull/21231
Reviewed By: axe-fb
Differential Revision: D10222129
Pulled By: hramos
fbshipit-source-id: b23340692d0fb059a90e338fa85ad4d9612275f2
Summary:
Google recommends to use Gravity.START and Gravity.END instead of Gravity.LEFT and Gravity.RIGHT to support RTL better.
[Android] [Changed] - Improve RTL support
Pull Request resolved: https://github.com/facebook/react-native/pull/24069
Differential Revision: D14541569
Pulled By: cpojer
fbshipit-source-id: 5c104d8bd666e1270d5410216c7f2efa6152692a
Summary:
fixes#23962, where trackColor is reset when value changed. This PR will set trackColor corresponding trackColor every-time value changes.
[Android] [Changed] - Fix Switch trackColor
Pull Request resolved: https://github.com/facebook/react-native/pull/23977
Differential Revision: D14495206
Pulled By: hramos
fbshipit-source-id: d712f540cd3f8359d6e85f79c12732689870a112
Summary:
There's a bug in the OSS Switch component where the track color value is reset to the default value when the switch is toggled. It looks like the Java class resets the track color value in `setOn` (which fires in a press event): https://fburl.com/vmugfzja but these values aren't actually initialized from JS - in Switch.js we only pass through the current track color: https://fburl.com/vytekd0o.
The React component already has an API for defining both true/false track colors. However, we should also make sure not to reset these values for people using the old API of `tintColor`/`onTintColor`, so I'm changing it to only reset the value when both of those props are null.
Reviewed By: mdvacca
Differential Revision: D14035007
fbshipit-source-id: 12d968076bd47d54deedbfc15b12ff3cd77e2fd0
Summary:
This PR adds support to use Conscrypt as Security Provider if available runtime. Consscrypt supports TLS 1.2 on Android 4.x and TLS 1.3 on all Android versions. Fixes issues (ex https://github.com/facebook/react-native/issues/23151) with HTTPS connections on Android 4.x.
Just add below to your project build.gradle and it'll use it.
```gradle
implementation('org.conscrypt:conscrypt-android:2.0.0')
```
[Android] [Changed] - Add TLS 1.3 support to all Android versions using Conscrypt.
Pull Request resolved: https://github.com/facebook/react-native/pull/23984
Differential Revision: D14506000
Pulled By: cpojer
fbshipit-source-id: 58bf18f7203d20519fb4451bae83f01e2f020a44
Summary:
Autofill Hints were added in [Android API 26](https://developer.android.com/reference/android/view/View.html#setAutofillHints(java.lang.String...)). Without this runtime check, pre-26 devices will crash.
[Android][Fixed] - Fixes crash on pre-26 Android devices when setting text content type
Reviewed By: lunaleaps
Differential Revision: D14479468
fbshipit-source-id: 238c1efd6aea682a93ecb45e1123aaed6bdcd9e3
Summary: JS Deltas have been killing productivity of RN engineers lately. There's been several posts and questions asked that end in "Turn off JS Deltas". Disabling them until we can make them more stable.
Reviewed By: fkgozali
Differential Revision: D14491774
fbshipit-source-id: 29b1c8e5e72369882c2890e3b6347ecd2fe4bed1
Summary:
In API 26, autofill framework was introduced in Android.
Read more about Autofill at https://developer.android.com/guide/topics/text/autofill.
Now, if in case for some text input if developer wants to disable
autofill then he can take help from this `importantForAutoFill` prop
and pass `no` to it.
Also important of auto fill can be configured with this prop, like:
* `auto`: Let the Android System use its heuristics to determine if the view is important for autofill.
* `no`: This view isn't important for autofill.
* `noExcludeDescendants`: This view and its children aren't important for autofill.
* `yes`: This view is important for autofill.
* `yesExcludeDescendants`: This view is important for autofill, but its children aren't important for autofill.
Default value if `auto`.
Read more at: https://developer.android.com/guide/topics/text/autofill-optimize
Changelog:
----------
[Android] [Added] - Add prop to configure `importantForAutofill` in `TextInput`.
Pull Request resolved: https://github.com/facebook/react-native/pull/22763
Differential Revision: D14121242
Pulled By: cpojer
fbshipit-source-id: aa4360480dd19f6dde66f0409d26a41a6a318c94
Summary:
1. add role description for heading
2. add talkback navigation support for link and header
Fixes#22440
Pull Request resolved: https://github.com/facebook/react-native/pull/22447
Differential Revision: D14205822
Pulled By: cpojer
fbshipit-source-id: 86bfc3bfc851f3544b1962012abaf8d1a357a9d2
Summary:
Fix two bugs with Location when not using ACCESS_FINE_LOCATION:
- If we request highAccuracy=false, because we don't have ACCESS_FINE_LOCATION, but we don't have access to the NETWORK_PROVIDER...then the code should not trigger a SecurityException because it fell-back to using GPS_PROVIDER (which we don't have permission for)
- If the device is pre-lollipop, and doesn't have a provider, we should detect this properly instead of letting the pre-lollipop code raise a SecurityException.
Unfortunately, SecurityExceptions cannot be caught by the calling JS code. But I am not fixing that one here, instead choosing to fix/obviate the SecurityExceptions altogether.
Pull Request resolved: https://github.com/facebook/react-native/pull/10291
Differential Revision: D4163659
Pulled By: cpojer
fbshipit-source-id: 18bb4ee7401bc4eac4fcc97341fc2b3a2a0957c9
Summary:
This commit fixes a bug introduced in a previous attempt (https://github.com/facebook/react-native/pull/23580) to address an issue where okhttp appended `charset=utf-8` to the Content-Type header when otherwise not specified.
In that commit, I converted all characters to UTF-8, however it should instead use an existing encoding when possible.
Related issues:
https://github.com/facebook/react-native/issues/8237#issuecomment-466304854
[Android][fixed] - Respect existing character set when specified in fetch() POST request
Pull Request resolved: https://github.com/facebook/react-native/pull/23603
Differential Revision: D14191750
Pulled By: hramos
fbshipit-source-id: 11c1bfd98ccd33cd8e54ea426285b7d2ce9c2d7c
Summary:
Before this commit, `fetch()` calls append `"charset=utf8"` to the `Content-Type` header on Android (and not on iOS). This is because of an implementation detail in the okhttp library. This means that you can make a call on the JavaScript side like:
```javascript
let body = JSON.stringify({ key: "value" });
let headers = {
"Content-Type": "application/json"
};
fetch("http://10.0.2.2:3000", { method: "POST", body, headers });
```
However the resulting request appends the utf8 character:
```
POST - 13:34:32:
content-type: application/json; charset=utf-8
content-length: 15
host: 10.0.2.2:3000
connection: Keep-Alive
accept-encoding: gzip
user-agent: okhttp/3.12.1
```
Passing byte array into the RequestBody avoids this, as recommended by a maintainer of okhttp:
https://github.com/square/okhttp/issues/2099#issuecomment-366757161
Related issues:
https://github.com/facebook/react-native/issues/8237
[Android][fixed] - Prevent fetch() POST requests on Android from appending `charset=utf-8` to `Content-Type` header.
Pull Request resolved: https://github.com/facebook/react-native/pull/23580
Differential Revision: D14180849
Pulled By: cpojer
fbshipit-source-id: b84cadf83361331a9f64d1ff5f2e6399a55527a6
Summary:
Add nullable annotations to BaseViewManager and ViewManager methods. This will improve Kotlin developer experience and help Android Studio to offer better autocomplete.
[Android] [Changed] - add nullable annotations to BaseViewManager and ViewManager methods. Might break ViewManagers in Kotlin.
Pull Request resolved: https://github.com/facebook/react-native/pull/23610
Differential Revision: D14198630
Pulled By: mdvacca
fbshipit-source-id: c596c88254e1d02f0af233a466f685200fac8917
Summary:
SYSTEM_ALERT_WINDOW permission is used only for debug builds to show draw overlay views or show warnings/errors. This permissions is unused in release builds, and there is an issue regarding removing unused permissions on Android build https://github.com/facebook/react-native/issues/5886#issuecomment-464495388. This PR removes SYSTEM_ALERT_WINDOW from all builds bug debug.
[Android] [Changed] - SYSTEM_ALERT_WINDOW permissions available only in debug builds
Pull Request resolved: https://github.com/facebook/react-native/pull/23504
Differential Revision: D14123045
Pulled By: cpojer
fbshipit-source-id: 68829a774ff23c7cb2721076a9d3870405f48fea
Summary:
TL;DR: Setting `autoComplete` will allow the system to suggest autofill options for the `<TextInput>` component.
Android Oreo introduced the AutoFill Framework, for secure communication between an app and autofill services (e.g. Password managers). When using `<TextInput>` on Android Oreo+, the system already tries to autofill (based on heuristics), but there is no way to set configuring options or disable.
The quick solution would be to just add the same Android attributes (`autofillHints` & `importantForAutofill`) in React Native TextInput, but that doesn't bond well with the cross-platform nature of the library.
Introduces an `autoComplete` prop based on HTML's `autocomplete` attribute, mapping to Android `autofillHints` & `importantForAutofill` and serving as a proper placeholder for autofill/autocomplete in other platforms:
Also gives you the ability to disable autofill by setting autocomplete="off".
Pull Request resolved: https://github.com/facebook/react-native/pull/21575
Differential Revision: D14102949
Pulled By: hramos
fbshipit-source-id: 7601aeaca0332a1f3ce8da8020dba037b700853a
Summary:
Here are some leftovers from nullable annotations for native modules, discovered while developing native module in Kotlin. This will help improve Kotlin developer experience
[Android] [Changed] - Add Nonnull annotations to ReactPackage
Pull Request resolved: https://github.com/facebook/react-native/pull/23415
Differential Revision: D14064607
Pulled By: cpojer
fbshipit-source-id: af2ce1fc1911ee03c54b20a4fc3a6d1aba9267da