From 90fad3c68bd99af959241705549c54e51cbb07a0 Mon Sep 17 00:00:00 2001 From: Paco Estevez Garcia Date: Wed, 19 Jul 2017 11:38:49 -0700 Subject: [PATCH] Add app name to PageInfo Reviewed By: dcaspi Differential Revision: D5436099 fbshipit-source-id: 73be706fbb36fe7c16b206de7ca3ba0cc3fa019b --- React/Inspector/RCTInspectorPackagerConnection.m | 1 + .../java/com/facebook/react/devsupport/DevServerHelper.java | 6 ++++-- .../facebook/react/devsupport/DevSupportManagerImpl.java | 2 +- .../react/devsupport/InspectorPackagerConnection.java | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/React/Inspector/RCTInspectorPackagerConnection.m b/React/Inspector/RCTInspectorPackagerConnection.m index df489888d..d3a26d188 100644 --- a/React/Inspector/RCTInspectorPackagerConnection.m +++ b/React/Inspector/RCTInspectorPackagerConnection.m @@ -133,6 +133,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) NSDictionary *jsonPage = @{ @"id": [@(page.id) stringValue], @"title": page.title, + @"app": [[NSBundle mainBundle] bundleIdentifier], }; [array addObject:jsonPage]; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index df2d17248..b42e0f7ba 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -109,6 +109,7 @@ public class DevServerHelper { private final OkHttpClient mClient; private final Handler mRestartOnChangePollingHandler; private final BundleDownloader mBundleDownloader; + private final String mPackageName; private boolean mOnChangePollingEnabled; private @Nullable JSPackagerClient mPackagerClient; @@ -116,7 +117,7 @@ public class DevServerHelper { private @Nullable OkHttpClient mOnChangePollingClient; private @Nullable OnServerContentChangeListener mOnServerContentChangeListener; - public DevServerHelper(DevInternalSettings settings) { + public DevServerHelper(DevInternalSettings settings, String packageName) { mSettings = settings; mClient = new OkHttpClient.Builder() .connectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS) @@ -126,6 +127,7 @@ public class DevServerHelper { mBundleDownloader = new BundleDownloader(mClient); mRestartOnChangePollingHandler = new Handler(); + mPackageName = packageName; } public void openPackagerConnection( @@ -196,7 +198,7 @@ public class DevServerHelper { new AsyncTask() { @Override protected Void doInBackground(Void... params) { - mInspectorPackagerConnection = new InspectorPackagerConnection(getInspectorDeviceUrl()); + mInspectorPackagerConnection = new InspectorPackagerConnection(getInspectorDeviceUrl(), mPackageName); mInspectorPackagerConnection.connect(); return null; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java index 927b8891f..ce8a4938a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java @@ -197,7 +197,7 @@ public class DevSupportManagerImpl implements mApplicationContext = applicationContext; mJSAppBundleName = packagerPathForJSBundleName; mDevSettings = new DevInternalSettings(applicationContext, this); - mDevServerHelper = new DevServerHelper(mDevSettings); + mDevServerHelper = new DevServerHelper(mDevSettings, mApplicationContext.getPackageName()); mBundleDownloadListener = devBundleDownloadListener; // Prepare shake gesture detector (will be started/stopped from #reload) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java index 3172191b2..b61c83579 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java @@ -31,10 +31,12 @@ public class InspectorPackagerConnection { private final Connection mConnection; private final Map mInspectorConnections; + private final String mPackageName; - public InspectorPackagerConnection(String url) { + public InspectorPackagerConnection(String url, String packageName) { mConnection = new Connection(url); mInspectorConnections = new HashMap<>(); + mPackageName = packageName; } public void connect() { @@ -145,6 +147,7 @@ public class InspectorPackagerConnection { JSONObject jsonPage = new JSONObject(); jsonPage.put("id", String.valueOf(page.getId())); jsonPage.put("title", page.getTitle()); + jsonPage.put("app", mPackageName); array.put(jsonPage); } return array;