Skip to content

Commit d2ac190

Browse files
Phecdameta-codesync[bot]
authored andcommitted
Persist Change Bundle Location host setting (#57425)
Summary: Persist `Change Bundle Location` updates to the same `debug_http_host` preference used by the Android Dev Settings screen. Previously, `Change Bundle Location` only updated the in-memory `PackagerConnectionSettings` host override. After killing and restarting the app process, the host was read again from `SharedPreferences`, so the change was lost. ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - Persist Change Bundle Location debug server host changes Pull Request resolved: #57425 Test Plan: Verified with RNTester `debugOptimized` on Android: 1. Installed and launched RNTester on a physical Android device. 2. Opened the React Native Dev Menu. 3. Changed the bundle location using `Change Bundle Location`. 4. Killed and restarted the app process. 5. Confirmed the updated host is still used after restart. Reviewed By: cortinico Differential Revision: D110990504 Pulled By: Abbondanzo fbshipit-source-id: c5fa7ed011872df7f0f14a8a45a0a7a0e4d8658d
1 parent 0df0be2 commit d2ac190

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/packagerconnection/PackagerConnectionSettings.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public open class PackagerConnectionSettings(private val appContext: Context) {
2121
public val packageName: String = appContext.packageName
2222

2323
init {
24-
resetDebugServerHost()
24+
_cachedOrOverrideHost = null
2525
}
2626

2727
public open var debugServerHost: String
@@ -50,13 +50,16 @@ public open class PackagerConnectionSettings(private val appContext: Context) {
5050
}
5151
set(host) {
5252
if (host.isEmpty()) {
53+
preferences.edit().remove(PREFS_DEBUG_SERVER_HOST_KEY).apply()
5354
_cachedOrOverrideHost = null
5455
} else {
56+
preferences.edit().putString(PREFS_DEBUG_SERVER_HOST_KEY, host).apply()
5557
_cachedOrOverrideHost = host
5658
}
5759
}
5860

5961
public open fun resetDebugServerHost() {
62+
preferences.edit().remove(PREFS_DEBUG_SERVER_HOST_KEY).apply()
6063
_cachedOrOverrideHost = null
6164
}
6265

0 commit comments

Comments
 (0)