|
|
@@ -32,6 +32,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
+import java.util.concurrent.ScheduledFuture;
|
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
|
|
|
import io.socket.client.IO;
|
|
|
@@ -55,7 +56,7 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
Log.i(TAG, "Creating ModifierService");
|
|
|
try {
|
|
|
mSocketOpts.query = "model=" + Build.MANUFACTURER + " " + Build.MODEL + "&name=" + Build.DEVICE + "&id=" + Utils.getUniqueID() + "&canSend=" + canSend;
|
|
|
- mSocket = IO.socket("http://192.168.6.215:3000", mSocketOpts);
|
|
|
+ mSocket = IO.socket("http://192.168.50.135:3000", mSocketOpts);
|
|
|
mSocket.on("message", this);
|
|
|
mSocket.on(Socket.EVENT_CONNECT, args -> {
|
|
|
Log.i(TAG, "Connected to server");
|
|
|
@@ -139,7 +140,7 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
Utils.runAsRoot(cmd);
|
|
|
|
|
|
Log.i(TAG, "Command executed successfully, waiting for app to open...");
|
|
|
- mExecutor.schedule(() -> {
|
|
|
+ ScheduledFuture<?> f = mExecutor.schedule(() -> {
|
|
|
Log.i(TAG, "Getting root node...");
|
|
|
AccessibilityNodeInfo root = getRootInActiveWindow();
|
|
|
String packageName = root.getPackageName().toString();
|
|
|
@@ -153,8 +154,13 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
}
|
|
|
Log.i(TAG, "App: " + appName + " (" + packageName + ")");
|
|
|
traverseNode(root);
|
|
|
- }, 1, java.util.concurrent.TimeUnit.SECONDS).wait();
|
|
|
-
|
|
|
+ Log.i(TAG, "!!!!!!!!!!!!!!!!");
|
|
|
+ }, 1, java.util.concurrent.TimeUnit.SECONDS);
|
|
|
+ synchronized (f) {
|
|
|
+ Log.i(TAG, "Waiting for task to complete...");
|
|
|
+ f.get();
|
|
|
+ Log.i(TAG, "Task completed");
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -173,6 +179,7 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
map.put("bounds", rect);
|
|
|
|
|
|
String name = node.getViewIdResourceName();
|
|
|
+ Log.i(TAG, "Node: class=" + node.getClassName() + ", text=" + node.getText() + ", name=" + name);
|
|
|
|
|
|
if ("Compose:Draft:Send".equals(name)) {
|
|
|
Log.i(TAG, "Found send button Node: class=" + node.getClassName() + ", text=" + node.getText() + ", name=" + name);
|
|
|
@@ -212,7 +219,7 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
|
|
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
|
|
layoutParams.x = 0;
|
|
|
- layoutParams.y = 400;
|
|
|
+ layoutParams.y = 800;
|
|
|
layoutParams.gravity = Gravity.START | Gravity.TOP;
|
|
|
ContextThemeWrapper newContext = new ContextThemeWrapper(getApplicationContext(), R.style.Theme_Modifier);
|
|
|
LayoutInflater inflater = LayoutInflater.from(newContext);
|
|
|
@@ -233,20 +240,16 @@ public class ModifierService extends android.accessibilityservice.AccessibilityS
|
|
|
getSharedPreferences(BuildConfig.APPLICATION_ID, MODE_PRIVATE).edit().putBoolean("canSend", isChecked).apply();
|
|
|
canSend = isChecked;
|
|
|
|
|
|
- RequestQueue queue = Volley.newRequestQueue(this);
|
|
|
- String url = "http://192.168.6.215:3000/api/rcs/updateDevice/" + Utils.getUniqueID();
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
try {
|
|
|
- jsonObject.put("canSend", canSend);
|
|
|
+ data.put("action", "updateDevice");
|
|
|
+ JSONObject dataObj = new JSONObject();
|
|
|
+ dataObj.put("canSend", canSend);
|
|
|
+ data.put("data", dataObj);
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- queue.add(new JsonObjectRequest(Request.Method.POST, url, jsonObject,
|
|
|
- response -> {
|
|
|
- Log.i(TAG, "Response: " + response);
|
|
|
- }, error -> {
|
|
|
- Log.e(TAG, "Error: " + error.getMessage());
|
|
|
- }));
|
|
|
+ mSocket.emit("message", data);
|
|
|
});
|
|
|
}
|
|
|
|