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 ca3558939..65f71e503 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java
@@ -29,6 +29,7 @@ public class DevInternalSettings implements
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String PREFS_FPS_DEBUG_KEY = "fps_debug";
+ private static final String PREFS_JS_DEV_MODE_DEBUG_KEY = "js_dev_mode_debug";
private static final String PREFS_DEBUG_SERVER_HOST_KEY = "debug_http_host";
private static final String PREFS_ANIMATIONS_DEBUG_KEY = "animations_debug";
private static final String PREFS_RELOAD_ON_JS_CHANGE_KEY = "reload_on_js_change";
@@ -54,12 +55,19 @@ public class DevInternalSettings implements
return mPreferences.getBoolean(PREFS_ANIMATIONS_DEBUG_KEY, false);
}
+ @Override
+ public boolean isJSDevModeEnabled() {
+ return mPreferences.getBoolean(PREFS_JS_DEV_MODE_DEBUG_KEY, true);
+ }
+
public @Nullable String getDebugServerHost() {
return mPreferences.getString(PREFS_DEBUG_SERVER_HOST_KEY, null);
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (PREFS_FPS_DEBUG_KEY.equals(key) || PREFS_RELOAD_ON_JS_CHANGE_KEY.equals(key)) {
+ if (PREFS_FPS_DEBUG_KEY.equals(key) ||
+ PREFS_RELOAD_ON_JS_CHANGE_KEY.equals(key) ||
+ PREFS_JS_DEV_MODE_DEBUG_KEY.equals(key)) {
mDebugManager.reloadSettings();
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
index 99a9da485..a91312b73 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
@@ -54,7 +54,7 @@ import okio.Sink;
private static final String DEVICE_LOCALHOST = "localhost";
private static final String BUNDLE_URL_FORMAT =
- "http://%s:8081/%s.bundle?platform=android";
+ "http://%s:8081/%s.bundle?platform=android&dev=%s";
private static final String SOURCE_MAP_URL_FORMAT =
BUNDLE_URL_FORMAT.replaceFirst("\\.bundle", ".map");
private static final String LAUNCH_CHROME_DEVTOOLS_COMMAND_URL_FORMAT =
@@ -111,6 +111,13 @@ import okio.Sink;
return "localhost";
}
+ /**
+ * @return whether we should enabled dev mode or not when requesting JS bundles.
+ */
+ private boolean getDevMode() {
+ return mSettings.isJSDevModeEnabled();
+ }
+
/**
* @return the host to use when connecting to the bundle server.
*/
@@ -145,15 +152,15 @@ import okio.Sink;
return Build.FINGERPRINT.contains("generic");
}
- private String createBundleURL(String host, String jsModulePath) {
- return String.format(BUNDLE_URL_FORMAT, host, jsModulePath);
+ private String createBundleURL(String host, String jsModulePath, boolean devMode) {
+ return String.format(BUNDLE_URL_FORMAT, host, jsModulePath, devMode);
}
public void downloadBundleFromURL(
final BundleDownloadCallback callback,
final String jsModulePath,
final File outputFile) {
- final String bundleURL = createBundleURL(getDebugServerHost(), jsModulePath);
+ final String bundleURL = createBundleURL(getDebugServerHost(), jsModulePath, getDevMode());
Request request = new Request.Builder()
.url(bundleURL)
.build();
@@ -288,17 +295,17 @@ import okio.Sink;
}
public String getSourceMapUrl(String mainModuleName) {
- return String.format(Locale.US, SOURCE_MAP_URL_FORMAT, getDebugServerHost(), mainModuleName);
+ return String.format(Locale.US, SOURCE_MAP_URL_FORMAT, getDebugServerHost(), mainModuleName, getDevMode());
}
public String getSourceUrl(String mainModuleName) {
- return String.format(Locale.US, BUNDLE_URL_FORMAT, getDebugServerHost(), mainModuleName);
+ return String.format(Locale.US, BUNDLE_URL_FORMAT, getDebugServerHost(), mainModuleName, getDevMode());
}
public String getJSBundleURLForRemoteDebugging(String mainModuleName) {
// The host IP we use when connecting to the JS bundle server from the emulator is not the
// same as the one needed to connect to the same server from the Chrome proxy running on the
// host itself.
- return createBundleURL(getHostForJSProxy(), mainModuleName);
+ return createBundleURL(getHostForJSProxy(), mainModuleName, getDevMode());
}
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DeveloperSettings.java b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DeveloperSettings.java
index 2ecad91c3..13a230fc3 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DeveloperSettings.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DeveloperSettings.java
@@ -23,4 +23,9 @@ public interface DeveloperSettings {
* @return Whether debug information about transitions should be displayed.
*/
boolean isAnimationFpsDebugEnabled();
+
+ /**
+ * @return Whether dev mode should be enabled in JS bundles.
+ */
+ boolean isJSDevModeEnabled();
}
diff --git a/ReactAndroid/src/main/res/devsupport/xml/preferences.xml b/ReactAndroid/src/main/res/devsupport/xml/preferences.xml
index 4eca11330..f7eb6a5fb 100644
--- a/ReactAndroid/src/main/res/devsupport/xml/preferences.xml
+++ b/ReactAndroid/src/main/res/devsupport/xml/preferences.xml
@@ -7,6 +7,12 @@
android:key="catalyst_perf"
android:title="Performance"
>
+