From 3e730528eea3c2a8dc4dda58bed87377122a288a Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 3 May 2018 08:38:08 -0700 Subject: [PATCH] Allow to not use native delta client Summary: Adds the possibility to disable native delta clients in `DevInternalSettings` Depending on the bridge in use, there might not be support for native delta clients, but since the settings are shared app-wide, it can not be enabled individually. Reviewed By: johnislarry Differential Revision: D7845137 fbshipit-source-id: ab368e6fed0f4bec49032c4a20466e156d20fdae --- .../react/devsupport/DevInternalSettings.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java index 5c07b7ead..e9ebe0c24 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java @@ -40,14 +40,29 @@ public class DevInternalSettings implements private final SharedPreferences mPreferences; private final Listener mListener; private final PackagerConnectionSettings mPackagerConnectionSettings; + private final boolean mSupportsNativeDeltaClients; + + public static DevInternalSettings withoutNativeDeltaClient( + Context applicationContext, + Listener listener) { + return new DevInternalSettings(applicationContext, listener, false); + } public DevInternalSettings( Context applicationContext, Listener listener) { + this(applicationContext, listener, true); + } + + private DevInternalSettings( + Context applicationContext, + Listener listener, + boolean supportsNativeDeltaClients) { mListener = listener; mPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext); mPreferences.registerOnSharedPreferenceChangeListener(this); mPackagerConnectionSettings = new PackagerConnectionSettings(applicationContext); + mSupportsNativeDeltaClients = supportsNativeDeltaClients; } public PackagerConnectionSettings getPackagerConnectionSettings() { @@ -127,7 +142,7 @@ public class DevInternalSettings implements @SuppressLint("SharedPreferencesUse") public boolean isBundleDeltasCppEnabled() { - return mPreferences.getBoolean(PREFS_JS_BUNDLE_DELTAS_CPP_KEY, false); + return mSupportsNativeDeltaClients && mPreferences.getBoolean(PREFS_JS_BUNDLE_DELTAS_CPP_KEY, false); } @SuppressLint("SharedPreferencesUse")