Permalink
Browse files

Clean up `DevServerHelper`

Summary:
- Makes methods private that are not used elsewhere
- Moves a method to `DevSupportManagerImpl`
- Removes unused methods

Reviewed By: pakoito

Differential Revision: D6900907

fbshipit-source-id: c8d9f748effd396fe610f0d4d87e0bc388e155d6
  • Loading branch information...
davidaurelio authored and facebook-github-bot committed Feb 6, 2018
1 parent 644123a commit 6e44356c9bb364195280aafc69aae48cdcb2ab84
@@ -64,7 +64,6 @@
*/
public class DevServerHelper {
public static final String RELOAD_APP_EXTRA_JS_PROXY = "jsproxy";
private static final String RELOAD_APP_ACTION_SUFFIX = ".RELOAD_APP_ACTION";
private static final String BUNDLE_URL_FORMAT =
"http://%s/%s.%s?platform=android&dev=%s&minify=%s";
@@ -75,7 +74,6 @@
"http://%s/onchange";
private static final String WEBSOCKET_PROXY_URL_FORMAT = "ws://%s/debugger-proxy?role=client";
private static final String PACKAGER_STATUS_URL_FORMAT = "http://%s/status";
private static final String HEAP_CAPTURE_UPLOAD_URL_FORMAT = "http://%s/jscheapcaptureupload";
private static final String INSPECTOR_DEVICE_URL_FORMAT = "http://%s/inspector/device?name=%s&app=%s";
private static final String INSPECTOR_ATTACH_URL_FORMAT = "http://%s/nuclide/attach-debugger-nuclide?title=%s&app=%s&device=%s";
private static final String SYMBOLICATE_URL_FORMAT = "http://%s/symbolicate";
@@ -246,12 +244,6 @@ protected Void doInBackground(Void... params) {
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public void sendEventToAllConnections(String event) {
if (mInspectorPackagerConnection != null) {
mInspectorPackagerConnection.sendEventToAllConnections(event);
}
}
public void disableDebugger() {
if (mInspectorPackagerConnection != null) {
mInspectorPackagerConnection.sendEventToAllConnections(DEBUGGER_MSG_DISABLE);
@@ -370,26 +362,14 @@ public void onResponse(Call call, final Response response) throws IOException {
});
}
/** Intent action for reloading the JS */
public static String getReloadAppAction(Context context) {
return context.getPackageName() + RELOAD_APP_ACTION_SUFFIX;
}
public String getWebsocketProxyURL() {
return String.format(
Locale.US,
WEBSOCKET_PROXY_URL_FORMAT,
mSettings.getPackagerConnectionSettings().getDebugServerHost());
}
public String getHeapCaptureUploadUrl() {
return String.format(
Locale.US,
HEAP_CAPTURE_UPLOAD_URL_FORMAT,
mSettings.getPackagerConnectionSettings().getDebugServerHost());
}
public String getInspectorDeviceUrl() {
private String getInspectorDeviceUrl() {
return String.format(
Locale.US,
INSPECTOR_DEVICE_URL_FORMAT,
@@ -398,7 +378,7 @@ public String getInspectorDeviceUrl() {
mPackageName);
}
public String getInspectorAttachUrl(String title) {
private String getInspectorAttachUrl(String title) {
return String.format(
Locale.US,
INSPECTOR_ATTACH_URL_FORMAT,
@@ -115,6 +115,8 @@
private static final int JAVA_ERROR_COOKIE = -1;
private static final int JSEXCEPTION_ERROR_COOKIE = -1;
private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js";
private static final String RELOAD_APP_ACTION_SUFFIX = ".RELOAD_APP_ACTION";
private enum ErrorType {
JS,
NATIVE
@@ -246,7 +248,7 @@ public void onShake() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (DevServerHelper.getReloadAppAction(context).equals(action)) {
if (getReloadAppAction(context).equals(action)) {
if (intent.getBooleanExtra(DevServerHelper.RELOAD_APP_EXTRA_JS_PROXY, false)) {
mDevSettings.setRemoteJSDebugEnabled(true);
mDevServerHelper.launchJSDevtools();
@@ -1134,7 +1136,7 @@ private void reload() {
// register reload app broadcast receiver
if (!mIsReceiverRegistered) {
IntentFilter filter = new IntentFilter();
filter.addAction(DevServerHelper.getReloadAppAction(mApplicationContext));
filter.addAction(getReloadAppAction(mApplicationContext));
mApplicationContext.registerReceiver(mReloadAppBroadcastReceiver, filter);
mIsReceiverRegistered = true;
}
@@ -1187,4 +1189,8 @@ public void onServerContentChanged() {
}
}
/** Intent action for reloading the JS */
private static String getReloadAppAction(Context context) {
return context.getPackageName() + RELOAD_APP_ACTION_SUFFIX;
}
}

0 comments on commit 6e44356

Please sign in to comment.