|
@@ -1,12 +1,22 @@
|
|
|
package com.example.modifier;
|
|
package com.example.modifier;
|
|
|
|
|
|
|
|
|
|
+import android.content.pm.ApplicationInfo;
|
|
|
|
|
+import android.content.pm.PackageManager;
|
|
|
|
|
+import android.graphics.Rect;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
|
|
|
+import android.view.accessibility.AccessibilityNodeInfo;
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.net.URISyntaxException;
|
|
import java.net.URISyntaxException;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
|
+import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
|
|
|
|
|
import io.socket.client.IO;
|
|
import io.socket.client.IO;
|
|
|
import io.socket.client.Socket;
|
|
import io.socket.client.Socket;
|
|
@@ -16,6 +26,8 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
|
|
|
|
|
private static final String TAG = "ModifierService";
|
|
private static final String TAG = "ModifierService";
|
|
|
|
|
|
|
|
|
|
+ private ScheduledExecutorService mExecutor = new ScheduledThreadPoolExecutor(8);
|
|
|
|
|
+
|
|
|
private Socket mSocket;
|
|
private Socket mSocket;
|
|
|
|
|
|
|
|
public ModifierService() {
|
|
public ModifierService() {
|
|
@@ -71,9 +83,24 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
String to = data.optString("to");
|
|
String to = data.optString("to");
|
|
|
String body = data.optString("body");
|
|
String body = data.optString("body");
|
|
|
Log.i(TAG, "Sending SMS to " + to + ": " + body);
|
|
Log.i(TAG, "Sending SMS to " + to + ": " + body);
|
|
|
- String cmd = "am start -a android.intent.action.SENDTO -d sms:" + to + " --es sms_body " + body + " --ez exit_on_sent true";
|
|
|
|
|
|
|
+ String cmd = "am start -a android.intent.action.SENDTO -d sms:" + to + " --es sms_body '" + body + "' --ez exit_on_sent true";
|
|
|
try {
|
|
try {
|
|
|
Utils.runAsRoot(cmd);
|
|
Utils.runAsRoot(cmd);
|
|
|
|
|
+
|
|
|
|
|
+ mExecutor.schedule(() -> {
|
|
|
|
|
+ AccessibilityNodeInfo root = getRootInActiveWindow();
|
|
|
|
|
+ String packageName = root.getPackageName().toString();
|
|
|
|
|
+ String appName = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ PackageManager packageManager = this.getPackageManager();
|
|
|
|
|
+ ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
|
|
|
|
|
+ appName = packageManager.getApplicationLabel(applicationInfo).toString();
|
|
|
|
|
+ } catch (PackageManager.NameNotFoundException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ traverseNode(root);
|
|
|
|
|
+ }, 2, java.util.concurrent.TimeUnit.SECONDS);
|
|
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -81,6 +108,27 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Map<String, Object> traverseNode(AccessibilityNodeInfo node) {
|
|
|
|
|
+ if (node == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("class", node.getClassName());
|
|
|
|
|
+ map.put("text", node.getText());
|
|
|
|
|
+ map.put("actions", node.getActionList().stream().map(AccessibilityNodeInfo.AccessibilityAction::getId).toArray());
|
|
|
|
|
+ Rect rect = new Rect();
|
|
|
|
|
+ node.getBoundsInScreen(rect);
|
|
|
|
|
+ map.put("bounds", rect);
|
|
|
|
|
|
|
|
|
|
+ if (node.getChildCount() != 0) {
|
|
|
|
|
+ List<Map<String, Object>> children = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < node.getChildCount(); i++) {
|
|
|
|
|
+ children.add(traverseNode(node.getChild(i)));
|
|
|
|
|
+ map.put("children", children);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|