mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-12 11:40:33 +08:00
Add AppIdentity and DeviceIdentity to Inspector
Reviewed By: Hypuk Differential Revision: D5924011 fbshipit-source-id: a81d420dbe1a5ede203d2fa313548e19664b9587
This commit is contained in:
committed by
Facebook Github Bot
parent
96f23e7416
commit
da14fad829
@@ -2,8 +2,12 @@
|
||||
|
||||
package com.facebook.react;
|
||||
|
||||
import static com.facebook.react.modules.systeminfo.AndroidInfoHelpers.getFriendlyDeviceName;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.JSBundleLoader;
|
||||
import com.facebook.react.bridge.JSCJavaScriptExecutorFactory;
|
||||
@@ -262,12 +266,15 @@ public class ReactInstanceManagerBuilder {
|
||||
mUIImplementationProvider = new UIImplementationProvider();
|
||||
}
|
||||
|
||||
String appName = Uri.encode(mApplication.getPackageName());
|
||||
String deviceName = Uri.encode(getFriendlyDeviceName());
|
||||
|
||||
return new ReactInstanceManager(
|
||||
mApplication,
|
||||
mCurrentActivity,
|
||||
mDefaultHardwareBackBtnHandler,
|
||||
mJavaScriptExecutorFactory == null
|
||||
? new JSCJavaScriptExecutorFactory()
|
||||
? new JSCJavaScriptExecutorFactory(appName, deviceName)
|
||||
: mJavaScriptExecutorFactory,
|
||||
(mJSBundleLoader == null && mJSBundleAssetUrl != null)
|
||||
? JSBundleLoader.createAssetLoader(
|
||||
|
||||
@@ -10,10 +10,20 @@
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
public class JSCJavaScriptExecutorFactory implements JavaScriptExecutorFactory {
|
||||
private final String mAppName;
|
||||
private final String mDeviceName;
|
||||
|
||||
public JSCJavaScriptExecutorFactory(String appName, String deviceName) {
|
||||
this.mAppName = appName;
|
||||
this.mDeviceName = deviceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptExecutor create() throws Exception {
|
||||
WritableNativeMap jscConfig = new WritableNativeMap();
|
||||
jscConfig.putString("OwnerIdentity", "ReactNative");
|
||||
jscConfig.putString("AppIdentity", mAppName);
|
||||
jscConfig.putString("OwnerIdentity", mDeviceName);
|
||||
return new JSCJavaScriptExecutor(jscConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class AndroidInfoHelpers {
|
||||
return getServerIpAddress(INSPECTOR_PROXY_PORT);
|
||||
}
|
||||
|
||||
// FIXME(festevezga): This method is duplicated in an internal module. Any changes should be applied to both.
|
||||
public static String getFriendlyDeviceName() {
|
||||
if (isRunningOnGenymotion()) {
|
||||
// Genymotion already has a friendly name by default
|
||||
|
||||
Reference in New Issue
Block a user