-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[android] Propose to connect metro server programmatically #31842
Conversation
Base commit: f58c496 |
88df0d4
to
757d6b2
Compare
Base commit: f58c496 |
...tAndroid/src/main/java/com/facebook/react/packagerconnection/PackagerConnectionSettings.java
Outdated
Show resolved
Hide resolved
@yungsters has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
@yungsters has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
...tAndroid/src/main/java/com/facebook/react/packagerconnection/PackagerConnectionSettings.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing along internal review feedback from @makovkastar.
@@ -54,10 +54,21 @@ public String getDebugServerHost() { | |||
} | |||
|
|||
public void setDebugServerHost(String host) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know if this class can be accessed from multiple threads? Since we are introducing a non-final class member variable, we need to make sure it's accessed through proper synchronisation if that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update with synchronized setter/getter because the getter may be from background thread.
mPreferences.edit().putString(PREFS_DEBUG_SERVER_HOST_KEY, host).apply(); | ||
} | ||
|
||
public void setDebugServerHostWithoutPersisting(final String host) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new method is not used in this diff, why is it being introduced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also remove final
from the argument definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new method is not used in this diff, why is it being introduced?
it's to change metro server programmatically. for expo client, we need this to load js bundles from other servers.
// Check host setting first. If empty try to detect emulator type and use default | ||
// hostname for those |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment seems to be copy-pasted from getDebugServerHost()
and is misleading. We are not trying to detect the emulator type here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, please let me know if the new comments make sense or not.
thanks for the neat review comments. please let me know how you think for the updated changes. |
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR was closed because it has been stalled for 7 days with no activity. |
Summary
same as #31828 but for android. by calling
setNonPersistentDebugServerHost("192.168.123.123:12345")
, we could control the metro connection programmatically.this pr also fix an issue for inspector connection does not honor custom packager setting. when user uses a custom metro server address in dev menu, hermes inspector cannot work in this case.
Changelog
[Internal] [Android] [Added] - Propose to connect metro server programmatically
[Android] [Fixed] - Fix Hermes inspector does not work for custom metro server address.
Test Plan
yarn start --port 8082
localhost:8082
port