You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/06/07 08:06:00 UTC
[23/50] incubator-weex git commit: * [android] prevent NPE on init
Inspector
* [android] prevent NPE on init Inspector
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a0d9d921
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a0d9d921
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a0d9d921
Branch: refs/heads/dev
Commit: a0d9d92149f61adc160f4e04ed0ecaef5ed861c7
Parents: 7c89305
Author: sospartan <so...@apache.org>
Authored: Thu Jun 1 10:49:49 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Thu Jun 1 10:49:49 2017 +0800
----------------------------------------------------------------------
.../com/taobao/weex/bridge/WXBridgeManager.java | 45 +++++++++-----------
1 file changed, 20 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a0d9d921/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
index e056663..6a745f6 100644
--- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
@@ -58,7 +58,6 @@ import com.taobao.weex.utils.batch.BactchExecutor;
import com.taobao.weex.utils.batch.Interceptor;
import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -174,39 +173,35 @@ public class WXBridgeManager implements Callback,BactchExecutor {
}
private void initWXBridge(boolean remoteDebug) {
- if (remoteDebug) {
+ if (remoteDebug && WXEnvironment.isApkDebugable()) {
WXEnvironment.sDebugServerConnectable = true;
}
if (mWxDebugProxy != null) {
mWxDebugProxy.stop(false);
}
- if (WXEnvironment.sDebugServerConnectable) {
- try {
- Class clazz = Class.forName("com.taobao.weex.devtools.debug.DebugServerProxy");
- if (clazz != null) {
- Constructor constructor = clazz.getConstructor(Context.class, WXBridgeManager.class);
- if (constructor != null) {
- mWxDebugProxy = (IWXDebugProxy) constructor.newInstance(
- WXEnvironment.getApplication(), WXBridgeManager.this);
- if (mWxDebugProxy != null) {
- mWxDebugProxy.start();
+ if (WXEnvironment.sDebugServerConnectable && WXEnvironment.isApkDebugable()) {
+ if (WXEnvironment.getApplication() != null) {
+ try {
+ Class clazz = Class.forName("com.taobao.weex.devtools.debug.DebugServerProxy");
+ if (clazz != null) {
+ Constructor constructor = clazz.getConstructor(Context.class, WXBridgeManager.class);
+ if (constructor != null) {
+ mWxDebugProxy = (IWXDebugProxy) constructor.newInstance(
+ WXEnvironment.getApplication(), WXBridgeManager.this);
+ if (mWxDebugProxy != null) {
+ mWxDebugProxy.start();
+ }
}
}
+ } catch (Throwable e) {
+ //Ignore, It will throw Exception on Release environment
}
- } catch (ClassNotFoundException e) {
- // ignore
- } catch (NoSuchMethodException e) {
- // ignore
- } catch (InstantiationException e) {
- // ignore
- } catch (IllegalAccessException e) {
- // ignore
- } catch (InvocationTargetException e) {
- // ignore
+ WXServiceManager.execAllCacheJsService();
+ } else {
+ WXLogUtils.e("WXBridgeManager", "WXEnvironment.sApplication is null, skip init Inspector");
+ WXLogUtils.w("WXBridgeManager", new Throwable("WXEnvironment.sApplication is null when init Inspector"));
}
-
- WXServiceManager.execAllCacheJsService();
}
if (remoteDebug && mWxDebugProxy != null) {
mWXBridge = mWxDebugProxy.getWXBridge();
@@ -892,7 +887,7 @@ public class WXBridgeManager implements Callback,BactchExecutor {
mWXBridge.execJS(instanceId, namespace, function, args);
}
- private void invokeInitFramework(Message msg) {
+ private void invokeInitFramework(Message msg) {
String framework = "";
if (msg.obj != null) {
framework = (String) msg.obj;