save works

This commit is contained in:
hyb1996
2017-07-16 21:47:34 +08:00
parent 73773faedc
commit 248338016b
6 changed files with 140 additions and 9 deletions

View File

@@ -36,3 +36,4 @@ require("__general__")(__runtime__, this);
})(__that__);
__importClass__(com.stardust.autojs.runtime.api.Shell);
__importClass__(com.stardust.autojs.runtime.api.InputEventSender);

View File

@@ -0,0 +1,34 @@
package com.stardust.autojs.execution;
import com.stardust.autojs.ScriptEngineService;
import com.stardust.autojs.engine.ScriptEngine;
import com.stardust.autojs.runtime.ScriptRuntime;
import com.stardust.autojs.runtime.api.AbstractShell;
import com.stardust.autojs.runtime.api.ProcessShell;
import com.stardust.util.IntentExtras;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Stardust on 2017/7/16.
*/
public class RootedScriptExecution extends RunnableScriptExecution {
private static int count = 0;
private static Map<String, ScriptExecutionTask> arguments = new HashMap<>();
public RootedScriptExecution(ScriptEngineService service, ScriptExecutionTask task) {
super(service, task);
}
@Override
public void run() {
}
public static void main(String[] args) {
}
}

View File

@@ -190,4 +190,12 @@ public abstract class AbstractShell {
}
public abstract void exitAndWaitFor();
public void sleep(long i) {
exec("sleep " + i);
}
public void usleep(long l) {
exec("usleep " + l);
}
}

View File

@@ -0,0 +1,86 @@
package com.stardust.autojs.runtime.api;
import com.stardust.util.ScreenMetrics;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* Created by Stardust on 2017/7/16.
*/
public class InputEventSender {
private DataOutputStream mDeviceFile;
private ScreenMetrics mScreenMetrics;
public InputEventSender(String devicePath) throws FileNotFoundException {
mDeviceFile = new DataOutputStream(new FileOutputStream(devicePath));
}
public InputEventSender(int i) throws FileNotFoundException {
this("/dev/input/event" + i);
}
public InputEventSender() {
}
public void sendEvent(int type, int code, int value) throws IOException {
for (int i = 0; i < 16; i++)
mDeviceFile.writeByte(0);
mDeviceFile.writeShort(type);
mDeviceFile.writeShort(code);
mDeviceFile.writeInt(value);
mDeviceFile.flush();
}
public void setInputDevice(int i) throws IOException {
if (mDeviceFile != null) {
mDeviceFile.close();
}
mDeviceFile = new DataOutputStream(new FileOutputStream("/dev/input/event" + i));
}
public void Touch(int x, int y) throws IOException {
TouchX(x);
TouchY(y);
}
public void setScreenMetrics(int width, int height) {
if (mScreenMetrics == null) {
mScreenMetrics = new ScreenMetrics();
}
mScreenMetrics.setScreenMetrics(width, height);
}
public void TouchX(int x) throws IOException {
sendEvent(3, 53, scaleX(x));
}
private int scaleX(int x) {
return mScreenMetrics.scaleX(x);
}
public void TouchY(int y) throws IOException {
sendEvent(3, 54, scaleY(y));
}
private int scaleY(int y) {
return mScreenMetrics.scaleY(y);
}
public void close() throws IOException {
mDeviceFile.close();
}
}