Skip to content

Commit

Permalink
Added: Record with root permission
Browse files Browse the repository at this point in the history
  • Loading branch information
hyb1996 committed Mar 8, 2017
1 parent 38c2264 commit a211d20
Show file tree
Hide file tree
Showing 41 changed files with 776 additions and 391 deletions.
Binary file removed app-release-1.17.0305(1)内测.apk
Binary file not shown.
Binary file removed app-release-1.17.0305内测.apk
Binary file not shown.
Binary file removed app-release-1.17.0306内测.apk
Binary file not shown.
Binary file not shown.
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ android {
applicationId "com.stardust.scriptdroid"
minSdkVersion 19
targetSdkVersion 23
versionCode 38
versionName "1.17.0306内测"
versionCode 39
versionName "1.17.0308内测"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true


}
buildTypes {
release {
Expand Down Expand Up @@ -65,7 +64,11 @@ dependencies {
compile 'com.jraska:console:0.4.3'
compile 'com.jraska:console-timber-tree:0.4.3'
compile 'com.heinrichreimersoftware:android-issue-reporter:eae4c73cbeb91e98da83fe79a3dea088a8b97448'
compile group: 'org.mozilla', name: 'rhino', version: '1.7'
//compile 'com.github.jackpal.Android-Terminal-Emulator:emulatorview:v1.0.70'
//compile 'com.github.jackpal.Android-Terminal-Emulator:libtermexec:v1.0.70'
compile(name: 'libtermexec-release', ext: 'aar')
compile(name: 'emulatorview-release', ext: 'aar')
compile(name: 'term-debug', ext: 'aar')

compile 'com.afollestad.material-dialogs:commons:0.9.2.3'
compile 'com.makeramen:roundedimageview:2.2.1'
Expand Down
Binary file removed app/libs/JSTransformer.jar
Binary file not shown.
Binary file added app/libs/emulatorview-release.aar
Binary file not shown.
Binary file added app/libs/libtermexec-release.aar
Binary file not shown.
Binary file removed app/libs/mutable-theme-debug.aar
Binary file not shown.
Binary file added app/libs/rhino-1.7.7.1.jar
Binary file not shown.
Binary file added app/libs/term-debug.aar
Binary file not shown.
7 changes: 6 additions & 1 deletion app/src/main/assets/javasccript_engine_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ var Tap = function(x, y){
return shell("input tap " + x + " " + y, true).code == 1;
}

var Swipe = function(x1, y1, x2, y2){
var Swipe = function(x1, y1, x2, y2, duration){
if(arguments.length == 5){
return shell("input swipe " + x1 + " " + y1 + " " + x2 + " " + y2 + " " + duration, true).code == 1;
}
return shell("input swipe " + x1 + " " + y1 + " " + x2 + " " + y2, true).code == 1;
}

Expand Down Expand Up @@ -219,6 +222,8 @@ var Text = function(text){
return shell("input text " + text, true).code == 1;
}

__importClassOld__(com.stardust.scriptdroid.droid.runtime.Shell);

/*
importClass("com.stardust.scriptdroid.service.AccessibilityDelegate");
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/sample_simple_calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importClass("com.afollestad.materialdialogs.MaterialDialog");

new ThemeColorMaterialDialogBuilder(activity)
new MaterialDialog.Builder(activity)
.title("简单计算器")
.input("请输入算式", "1+1", function(dialog, input){
eval("var ans = (" + input + ")");
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/stardust/scriptdroid/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
import com.stardust.util.CrashHandler;
import com.stardust.util.StateObserver;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;

import java.lang.ref.WeakReference;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.stardust.scriptdroid.droid.runtime.action.ActionPerformAccessibilityDelegate;
import com.stardust.scriptdroid.droid.runtime.action.ActionTarget;
import com.stardust.scriptdroid.droid.runtime.action.GetTextAction;
import com.stardust.scriptdroid.droid.runtime.api.IDroidRuntime;
import com.stardust.scriptdroid.file.FileUtils;
import com.stardust.scriptdroid.service.AccessibilityDelegate;
import com.stardust.scriptdroid.service.AccessibilityWatchDogService;
Expand All @@ -45,7 +44,7 @@
* Created by Stardust on 2017/1/27.
*/

public class DroidRuntime implements IDroidRuntime {
public class DroidRuntime {

private static final String TAG = "DroidRuntime";
private static DroidRuntime runtime = new DroidRuntime();
Expand All @@ -61,18 +60,15 @@ protected DroidRuntime() {
mUIHandler = new Handler(App.getApp().getMainLooper());
}

@Override
public void launchPackage(String packageName) {
PackageManager packageManager = App.getApp().getPackageManager();
App.getApp().startActivity(packageManager.getLaunchIntentForPackage(packageName));
}

@Override
public void launch(String packageName, String className) {
App.getApp().startActivity(new Intent().setClassName(packageName, className).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}

@Override
public void launchApp(String appName) {
PackageManager packageManager = App.getApp().getPackageManager();
List<ApplicationInfo> installedApplications = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
Expand All @@ -84,22 +80,18 @@ public void launchApp(String appName) {
}
}

@Override
public String[] getPackageName(String appName) {
return new String[0];
}

@Override
public ActionTarget text(String text, int i) {
return new ActionTarget.TextActionTarget(text, i);
}

@Override
public ActionTarget bounds(int left, int top, int right, int bottom) {
return new ActionTarget.BoundsActionTarget(new Rect(left, top, right, bottom));
}

@Override
public ActionTarget editable(int i) {
return new ActionTarget.EditableActionTarget(i);
}
Expand All @@ -108,32 +100,26 @@ public ActionTarget id(String id) {
return new ActionTarget.IdActionTarget(id);
}

@Override
public boolean click(ActionTarget target) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_CLICK));
}

@Override
public boolean longClick(ActionTarget target) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_LONG_CLICK));
}

@Override
public boolean scrollUp(ActionTarget target) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD));
}

@Override
public boolean scrollDown(ActionTarget target) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD));
}

@Override
public boolean scrollUp(int i) {
return performAction(ActionFactory.createScrollAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD, i));
}

@Override
public boolean scrollDown(int i) {
return performAction(ActionFactory.createScrollAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD, i));
}
Expand All @@ -146,17 +132,14 @@ public boolean scrollAllDown() {
return performAction(ActionFactory.createScrollMaxAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD));
}

@Override
public boolean focus(ActionTarget target) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_FOCUS));
}

@Override
public boolean select(ActionTarget target) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SELECT));
}

@Override
public boolean setText(ActionTarget target, String text) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_SET_TEXT, text));
}
Expand All @@ -170,7 +153,6 @@ public void run() {
});
}

@Override
public boolean paste(ActionTarget target) {
return performAction(target.createAction(AccessibilityNodeInfo.ACTION_PASTE));
}
Expand Down Expand Up @@ -230,7 +212,6 @@ public List<String> getTexts() {
return performAction(new GetTextAction());
}

@Override
public void toast(final String text) {
mUIHandler.post(new Runnable() {
@Override
Expand All @@ -240,7 +221,6 @@ public void run() {
});
}

@Override
public void sleep(long millis) {
try {
Thread.sleep(millis);
Expand Down Expand Up @@ -275,12 +255,10 @@ public String getActivityName() {
return ActionPerformAccessibilityDelegate.getLatestActivity();
}

@Override
public boolean isStopped() {
return Thread.currentThread().isInterrupted();
}

@Override
public void stop() {
Thread.interrupted();
}
Expand All @@ -289,7 +267,6 @@ public String readFile(String path) {
return FileUtils.readString(new File(Environment.getExternalStorageDirectory() + "/" + path));
}

@Override
public ThemeColorMaterialDialogBuilder dialog() {
if (App.currentActivity() == null) {
Toast.makeText(App.getApp(), R.string.text_cannot_create_dialog_when_app_invisible, Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.stardust.scriptdroid.droid.runtime;

/**
* Created by Stardust on 2017/3/7.
*/

public class Shell extends com.stardust.scriptdroid.tool.Shell {

public Shell(boolean root) {
super(root);
}

public void Tap(int x, int y) {
execute("input tap " + x + " " + y);
}

public void Swipe(int x1, int y1, int x2, int y2) {
execute("input swipe " + x1 + " " + y1 + " " + x2 + " " + y2);
}

public void Swipe(int x1, int y1, int x2, int y2, long duration) {
execute("input swipe " + x1 + " " + y1 + " " + x2 + " " + y2 + " " + duration);
}

public void KeyCode(int keyCode) {
execute("input keyevent " + keyCode);
}

public void KeyCode(String keyCode) {
execute("input keyevent " + keyCode);
}

public void Home() {
KeyCode(3);
}

public void Back() {
KeyCode(4);
}

public void Power() {
KeyCode(26);
}

public void Up() {
KeyCode(19);
}

public void Down() {
KeyCode(20);
}

public void Left() {
KeyCode(21);
}

public void Right() {
KeyCode(22);
}

public void OK() {
KeyCode(23);
}

public void VolumeUp() {
KeyCode(24);
}

public void VolumeDown() {
KeyCode(25);
}

public void Menu() {
KeyCode(1);
}

public void Camera() {
KeyCode(27);
}

public void Text(String text) {
execute("input text " + text);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
package com.stardust.scriptdroid.droid.script;

import com.efurture.script.JSTransformer;
import com.stardust.scriptdroid.App;
import com.stardust.scriptdroid.droid.Droid;
import com.stardust.scriptdroid.droid.runtime.api.IDroidRuntime;

import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

/**
* Created by Stardust on 2017/1/27.
*/
Expand Down
Loading

0 comments on commit a211d20

Please sign in to comment.