refactor(ui): refactor ScriptListView

This commit is contained in:
hyb1996
2018-09-17 09:24:22 +08:00
parent c5c9aaa8e1
commit 37796048f4
48 changed files with 1219 additions and 891 deletions

View File

@@ -1,6 +1,7 @@
module.exports = function(__runtime__, scope){
function RootAutomator(nonBlockingForReady){
this.__ra__ = Object.create(new com.stardust.autojs.core.inputevent.RootAutomator(scope.context, !nonBlockingForReady));
function RootAutomator(inputDevice, nonBlockingForReady){
inputDevice = inputDevice == undefined ? null : inputDevice;
this.__ra__ = Object.create(new com.stardust.autojs.core.inputevent.RootAutomator(scope.context, inputDevice, !nonBlockingForReady));
var methods = ["sendEvent", "touch", "setScreenMetrics", "touchX", "touchY", "sendSync", "sendMtSync", "tap",
"swipe", "press", "longPress", "touchDown", "touchUp", "touchMove", "getDefaultId", "setDefaultId", "exit"];
for(var i = 0; i < methods.length; i++){

View File

@@ -9,6 +9,10 @@ package com.stardust.autojs.core.inputevent;
public class InputEventCodes {
public static final int UP = 0x00;
public static final int DOWN = 0x01;
/*
* Device properties and quirks

View File

@@ -41,9 +41,15 @@ public class RootAutomator implements Shell.Callback {
private final Object mReadyLock = new Object();
private volatile boolean mReady = false;
private final Context mContext;
private String mInputDevice;
public RootAutomator(Context context, boolean waitForReady) throws IOException {
public RootAutomator(Context context, String inputDevice, boolean waitForReady) throws IOException {
mContext = context;
if (inputDevice == null) {
mInputDevice = RootAutomatorEngine.getDeviceNameOrPath(mContext, InputDevices.getTouchDeviceName());
} else {
mInputDevice = inputDevice;
}
mShell = new Shell(true);
mShell.setCallback(this);
if (waitForReady) {
@@ -180,19 +186,21 @@ public class RootAutomator implements Shell.Callback {
sendEvent(EV_ABS, ABS_MT_POSITION_X, scaleX(x));
sendEvent(EV_ABS, ABS_MT_POSITION_Y, scaleY(y));
sendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 5);
sendEvent(EV_SYN, SYN_REPORT, 0x00000000);
sendEvent(EV_ABS, ABS_MT_WIDTH_MAJOR, 5);
sendEvent(EV_SYN, SYN_REPORT, 0);
}
private void touchDown0(int x, int y, int id) throws IOException {
mSlotIdMap.put(id, 0);
sendEvent(EV_ABS, ABS_MT_TRACKING_ID, mTracingId.getAndIncrement());
sendEvent(EV_KEY, BTN_TOUCH, 0x00000001);
sendEvent(EV_KEY, BTN_TOOL_FINGER, 0x00000001);
sendEvent(EV_KEY, BTN_TOUCH, DOWN);
//sendEvent(EV_KEY, BTN_TOOL_FINGER, 0x00000001);
sendEvent(EV_ABS, ABS_MT_POSITION_X, scaleX(x));
sendEvent(EV_ABS, ABS_MT_POSITION_Y, scaleY(y));
//sendEvent(EV_ABS, ABS_MT_PRESSURE, 200);
sendEvent(EV_ABS, ABS_MT_TOUCH_MAJOR, 5);
sendEvent(EV_SYN, SYN_REPORT, 0x00000000);
sendEvent(EV_ABS, ABS_MT_WIDTH_MAJOR, 5);
sendEvent(EV_SYN, SYN_REPORT, 0);
}
public void touchDown(int x, int y) throws IOException {
@@ -211,8 +219,8 @@ public class RootAutomator implements Shell.Callback {
sendEvent(EV_ABS, ABS_MT_SLOT, slotId);
sendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0xffffffff);
if (mSlotIdMap.size() == 0) {
sendEvent(EV_KEY, BTN_TOUCH, 0x00000000);
sendEvent(EV_KEY, BTN_TOOL_FINGER, 0x00000000);
sendEvent(EV_KEY, BTN_TOUCH, UP);
//sendEvent(EV_KEY, BTN_TOOL_FINGER, 0x00000000);
}
sendEvent(EV_SYN, SYN_REPORT, 0x00000000);
}

View File

@@ -35,7 +35,7 @@ public class RootAutomatorEngine extends ScriptEngine.AbstractScriptEngine<AutoF
private static final String ROOT_AUTOMATOR_EXECUTABLE_ASSET = "binary/root_automator";
private Context mContext;
private String mDeviceNameOrPath;
private final String mDeviceNameOrPath;
private Thread mThread;
private String mExecutablePath;
private String mPid;