From d6bca9723e6226688ec1bb3301d7ce39a17f79e3 Mon Sep 17 00:00:00 2001 From: Sunny Luo Date: Tue, 2 Apr 2019 09:36:30 -0700 Subject: [PATCH] Prevent crash when setting underlineColorAndroid (#24183) 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 --- .../java/com/facebook/react/views/textinput/BUCK | 1 + .../views/textinput/ReactTextInputManager.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK index 3c29c2262fc..69b9d0f593b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK @@ -12,6 +12,7 @@ rn_android_library( ], deps = [ YOGA_TARGET, + react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_target("java/com/facebook/react/bridge:bridge"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 67bafbc242c..1b70fb97d92 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -27,6 +27,7 @@ import android.view.KeyEvent; import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.TextView; +import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReactContext; @@ -64,7 +65,7 @@ import javax.annotation.Nullable; */ @ReactModule(name = ReactTextInputManager.REACT_CLASS) public class ReactTextInputManager extends BaseViewManager { - + public static final String TAG = ReactTextInputManager.class.getSimpleName(); protected static final String REACT_CLASS = "AndroidTextInput"; private static final int[] SPACING_TYPES = { @@ -445,9 +446,14 @@ public class ReactTextInputManager extends BaseViewManager