Skip to content

Commit

Permalink
Replace duplicate code in AndroidInfoModule with call to AndroidInfoH…
Browse files Browse the repository at this point in the history
…elpers (#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: #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
  • Loading branch information
ide authored and facebook-github-bot committed Apr 30, 2020
1 parent f746119 commit d20ac69
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String getName() {
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());
Expand All @@ -98,12 +98,4 @@ private Boolean isRunningScreenshotTest() {
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);
}
}

0 comments on commit d20ac69

Please sign in to comment.