debug complete process chained (bugged)
This commit is contained in:
@@ -63,7 +63,7 @@ dependencies {
|
||||
implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.7'
|
||||
implementation 'com.github.tbruyelle:rxpermissions:0.10.2'
|
||||
implementation "io.reactivex.rxjava2:rxjava:2.2.14"
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
api 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation 'com.lahm.library:easy-protector-release:1.1.0'
|
||||
|
||||
testImplementation 'junit:junit:4.12'
|
||||
|
@@ -157,4 +157,8 @@ public class DoricDriver implements IDoricDriver {
|
||||
wsClient.close();
|
||||
wsClient = null;
|
||||
}
|
||||
|
||||
public void changeJSEngine(boolean isNative) {
|
||||
doricJSEngine.changeJSEngine(isNative);
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import okhttp3.WebSocketListener;
|
||||
import pub.doric.DoricContext;
|
||||
import pub.doric.DoricContextManager;
|
||||
import pub.doric.dev.event.EOFEvent;
|
||||
import pub.doric.dev.event.EnterDebugEvent;
|
||||
import pub.doric.dev.event.OpenEvent;
|
||||
|
||||
/**
|
||||
@@ -67,13 +68,24 @@ public class WSClient extends WebSocketListener {
|
||||
super.onMessage(webSocket, text);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(text);
|
||||
String source = jsonObject.optString("source");
|
||||
String script = jsonObject.optString("script");
|
||||
for (DoricContext context : DoricContextManager.aliveContexts()) {
|
||||
if (source.contains(context.getSource())) {
|
||||
context.reload(script);
|
||||
String cmd = jsonObject.optString("cmd");
|
||||
switch (cmd) {
|
||||
case "RELOAD": {
|
||||
String source = jsonObject.optString("source");
|
||||
String script = jsonObject.optString("script");
|
||||
for (DoricContext context : DoricContextManager.aliveContexts()) {
|
||||
if (source.contains(context.getSource())) {
|
||||
context.reload(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "SWITCH_TO_DEBUG": {
|
||||
EventBus.getDefault().post(new EnterDebugEvent());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@@ -0,0 +1,4 @@
|
||||
package pub.doric.dev.event;
|
||||
|
||||
public class EnterDebugEvent {
|
||||
}
|
@@ -21,6 +21,12 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.pengfeizhou.jscore.JSDecoder;
|
||||
import com.github.pengfeizhou.jscore.JavaFunction;
|
||||
import com.github.pengfeizhou.jscore.JavaValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import pub.doric.DoricRegistry;
|
||||
import pub.doric.extension.bridge.DoricBridgeExtension;
|
||||
import pub.doric.extension.timer.DoricTimerExtension;
|
||||
@@ -28,12 +34,6 @@ import pub.doric.utils.DoricConstant;
|
||||
import pub.doric.utils.DoricLog;
|
||||
import pub.doric.utils.DoricUtils;
|
||||
|
||||
import com.github.pengfeizhou.jscore.JSDecoder;
|
||||
import com.github.pengfeizhou.jscore.JavaFunction;
|
||||
import com.github.pengfeizhou.jscore.JavaValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @Description: Doric
|
||||
* @Author: pengfei.zhou
|
||||
@@ -54,7 +54,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
||||
mJSHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initJSExecutor();
|
||||
mDoricJSE = new DoricNativeJSExecutor();
|
||||
injectGlobal();
|
||||
initDoricRuntime();
|
||||
}
|
||||
});
|
||||
@@ -65,10 +66,7 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
||||
return mJSHandler;
|
||||
}
|
||||
|
||||
|
||||
private void initJSExecutor() {
|
||||
mDoricJSE = new DoricNativeJSExecutor();
|
||||
// mDoricJSE = new DoricRemoteJSExecutor();
|
||||
private void injectGlobal() {
|
||||
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_LOG, new JavaFunction() {
|
||||
@Override
|
||||
public JavaValue exec(JSDecoder[] args) {
|
||||
@@ -212,4 +210,14 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
||||
public DoricRegistry getRegistry() {
|
||||
return mDoricRegistry;
|
||||
}
|
||||
|
||||
public void changeJSEngine(boolean isNative) {
|
||||
mDoricJSE.teardown();
|
||||
if (isNative) {
|
||||
mDoricJSE = new DoricNativeJSExecutor();
|
||||
} else {
|
||||
mDoricJSE = new DoricRemoteJSExecutor();
|
||||
}
|
||||
injectGlobal();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user