fix(automator): RootAutomator (x, y) not correct on some devices

This commit is contained in:
hyb1996 2018-09-16 01:49:33 +08:00
parent 91d5eab872
commit c5c9aaa8e1
7 changed files with 18 additions and 16 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "org.autojs.autojs"
minSdkVersion 17
targetSdkVersion 23
versionCode 414
versionName "4.0.2 Alpha9"
versionCode 416
versionName "4.0.2 Alpha11"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
ndk {

View File

@ -192,7 +192,7 @@ public class CodeEditText extends AppCompatEditText {
return;
}
JavaScriptHighlighter.HighlightTokens highlightTokens = mHighlightTokens;
Log.d(LOG_TAG, "drawText: tokens = " + highlightTokens);
//Log.d(LOG_TAG, "drawText: tokens = " + highlightTokens);
Layout layout = getLayout();
int lineCount = getLineCount();
int textLength = highlightTokens == null ? 0 : highlightTokens.getText().length();

View File

@ -13,6 +13,7 @@ import com.stardust.autojs.runtime.exception.ScriptInterruptedException;
import com.stardust.util.ScreenMetrics;
import java.io.IOException;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import static com.stardust.autojs.core.inputevent.InputEventCodes.*;
@ -45,7 +46,7 @@ public class RootAutomator implements Shell.Callback {
mContext = context;
mShell = new Shell(true);
mShell.setCallback(this);
if(waitForReady){
if (waitForReady) {
waitForReady();
}
}
@ -61,11 +62,11 @@ public class RootAutomator implements Shell.Callback {
}
private void waitForReady() throws IOException {
if(mReady){
if (mReady) {
return;
}
synchronized (mReadyLock){
if(mReady){
synchronized (mReadyLock) {
if (mReady) {
return;
}
try {
@ -168,7 +169,7 @@ public class RootAutomator implements Shell.Callback {
}
public void touchDown(int x, int y, int id) throws IOException {
if(mSlotIdMap.size() == 0){
if (mSlotIdMap.size() == 0) {
touchDown0(x, y, id);
return;
}
@ -199,17 +200,17 @@ public class RootAutomator implements Shell.Callback {
}
public void touchUp(int id) throws IOException {
int slotId ;
int slotId;
int i = mSlotIdMap.indexOfKey(id);
if( i < 0){
if (i < 0) {
slotId = 0;
}else {
} else {
slotId = mSlotIdMap.valueAt(i);
mSlotIdMap.removeAt(i);
}
sendEvent(EV_ABS, ABS_MT_SLOT, slotId);
sendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0xffffffff);
if(mSlotIdMap.size() == 0){
if (mSlotIdMap.size() == 0) {
sendEvent(EV_KEY, BTN_TOUCH, 0x00000000);
sendEvent(EV_KEY, BTN_TOOL_FINGER, 0x00000000);
}
@ -281,9 +282,10 @@ public class RootAutomator implements Shell.Callback {
String deviceNameOrPath = RootAutomatorEngine.getDeviceNameOrPath(mContext, InputDevices.getTouchDeviceName());
Log.d(LOG_TAG, "deviceNameOrPath: " + deviceNameOrPath);
mShell.exec("chmod 777 " + path);
String command = path + " -d " + deviceNameOrPath;
String command = String.format(Locale.getDefault(), "%s -d %s -sw %d -sh %d", path, deviceNameOrPath,
ScreenMetrics.getDeviceScreenWidth(), ScreenMetrics.getDeviceScreenHeight());
mShell.exec(command);
synchronized (mReadyLock){
synchronized (mReadyLock) {
Log.d(LOG_TAG, "notify ready");
mReady = true;
mReadyLock.notifyAll();

View File

@ -62,7 +62,7 @@ public class Shell extends AbstractShell {
}
}
private static final boolean DEBUG = false;
private static final boolean DEBUG = true;
private static final String TAG = "Shell";
private volatile TermSession mTermSession;

View File

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":414},"path":"commonRelease-4.0.2 Alpha9.apk","properties":{"packageId":"org.autojs.autojs","split":"","minSdkVersion":"17"}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":415},"path":"commonRelease-4.0.2 Alpha10.apk","properties":{"packageId":"org.autojs.autojs","split":"","minSdkVersion":"17"}}]