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
This commit is contained in:
David Aurelio 2018-05-03 08:38:08 -07:00 committed by Facebook Github Bot
parent 36f254aa75
commit 3e730528ee
1 changed files with 16 additions and 1 deletions

View File

@ -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")