mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Replace duplicate code in AndroidInfoModule with call to AndroidInfoHelpers (#28756)
Summary: The AndroidInfoModule class defines a `getServerHost()` method that duplicates the logic in `AndroidInfoHelpers.getServerHost(context)`. This commit makes AndroidInfoModule call into AndroidInfoHelpers so that potential future changes to `AndroidInfoHelpers.getServerHost` don't need to be duplicated in `AndroidInfoModule.getServerHost`. ## Changelog [Android] [Changed] - Internal change to make `PlatformConstants` use the same method to determine `ServerHost` as other code paths Pull Request resolved: https://github.com/facebook/react-native/pull/28756 Test Plan: Tested by running the RNTester app and editing the root component to print out `NativeModules.PlatformConstants.getConstants()` and verified one of the properties was: `"ServerHost": "10.0.2.2:8081"`. Differential Revision: D21252158 Pulled By: shergin fbshipit-source-id: b460197e5f1d972a5b91991c32a929294e358d9f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f746119d62
commit
d20ac69fc8
+1
-9
@@ -73,7 +73,7 @@ public class AndroidInfoModule extends NativePlatformConstantsAndroidSpec implem
|
||||
constants.put("Fingerprint", Build.FINGERPRINT);
|
||||
constants.put("Model", Build.MODEL);
|
||||
if (ReactBuildConfig.DEBUG) {
|
||||
constants.put("ServerHost", getServerHost());
|
||||
constants.put("ServerHost", AndroidInfoHelpers.getServerHost(getReactApplicationContext().getApplicationContext()));
|
||||
}
|
||||
constants.put(
|
||||
"isTesting", "true".equals(System.getProperty(IS_TESTING)) || isRunningScreenshotTest());
|
||||
@@ -98,12 +98,4 @@ public class AndroidInfoModule extends NativePlatformConstantsAndroidSpec implem
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private String getServerHost() {
|
||||
Resources resources = getReactApplicationContext().getApplicationContext().getResources();
|
||||
|
||||
Integer devServerPort = resources.getInteger(R.integer.react_native_dev_server_port);
|
||||
|
||||
return AndroidInfoHelpers.getServerHost(devServerPort);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user