From e0d584a08701d3a8d61aa5799dd924b9f6edcd89 Mon Sep 17 00:00:00 2001 From: Eason <291028775@qq.com> Date: Thu, 16 Mar 2023 00:16:46 +0800 Subject: [PATCH] feat: add app force stop --- .../java/org/cloud/sonic/agent/bridge/ios/SibTool.java | 5 +++++ .../cloud/sonic/agent/websockets/AndroidWSServer.java | 9 ++++++--- .../org/cloud/sonic/agent/websockets/IOSWSServer.java | 7 ++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java index cdefa7ab..77927572 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java @@ -532,6 +532,11 @@ public static void launch(String udId, String pkg) { ProcessCommandTool.getProcessLocalCommand(String.format(commandLine, sib, udId, pkg)); } + public static void kill(String udId, String pkg) { + String commandLine = "%s app kill -u %s -b %s"; + ProcessCommandTool.getProcessLocalCommand(String.format(commandLine, sib, udId, pkg)); + } + public static void uninstall(String udId, String pkg) { String commandLine = "%s app uninstall -u %s -b %s"; ProcessCommandTool.getProcessLocalCommand(String.format(commandLine, sib, udId, pkg)); diff --git a/src/main/java/org/cloud/sonic/agent/websockets/AndroidWSServer.java b/src/main/java/org/cloud/sonic/agent/websockets/AndroidWSServer.java index d85a83ae..57302d3b 100755 --- a/src/main/java/org/cloud/sonic/agent/websockets/AndroidWSServer.java +++ b/src/main/java/org/cloud/sonic/agent/websockets/AndroidWSServer.java @@ -20,6 +20,9 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.android.ddmlib.*; +import jakarta.websocket.*; +import jakarta.websocket.server.PathParam; +import jakarta.websocket.server.ServerEndpoint; import lombok.extern.slf4j.Slf4j; import org.cloud.sonic.agent.bridge.android.AndroidDeviceBridgeTool; import org.cloud.sonic.agent.bridge.android.AndroidDeviceLocalStatus; @@ -47,9 +50,6 @@ import org.springframework.stereotype.Component; import javax.imageio.stream.FileImageOutputStream; -import jakarta.websocket.*; -import jakarta.websocket.server.PathParam; -import jakarta.websocket.server.ServerEndpoint; import java.io.File; import java.io.IOException; import java.net.Socket; @@ -276,6 +276,9 @@ public void onMessage(String message, Session session) { case "openApp" -> AndroidDeviceThreadPool.cachedThreadPool.execute(() -> { AndroidDeviceBridgeTool.activateApp(iDevice, msg.getString("pkg")); }); + case "killApp" -> AndroidDeviceThreadPool.cachedThreadPool.execute(() -> { + AndroidDeviceBridgeTool.forceStop(iDevice, msg.getString("pkg")); + }); case "tap" -> { String xy = msg.getString("point"); int x = Integer.parseInt(xy.substring(0, xy.indexOf(","))); diff --git a/src/main/java/org/cloud/sonic/agent/websockets/IOSWSServer.java b/src/main/java/org/cloud/sonic/agent/websockets/IOSWSServer.java index 65d02d93..b420dbba 100755 --- a/src/main/java/org/cloud/sonic/agent/websockets/IOSWSServer.java +++ b/src/main/java/org/cloud/sonic/agent/websockets/IOSWSServer.java @@ -19,6 +19,9 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import jakarta.websocket.*; +import jakarta.websocket.server.PathParam; +import jakarta.websocket.server.ServerEndpoint; import lombok.extern.slf4j.Slf4j; import org.cloud.sonic.agent.bridge.ios.IOSDeviceLocalStatus; import org.cloud.sonic.agent.bridge.ios.IOSDeviceThreadPool; @@ -46,9 +49,6 @@ import org.springframework.stereotype.Component; import javax.imageio.stream.FileImageOutputStream; -import jakarta.websocket.*; -import jakarta.websocket.server.PathParam; -import jakarta.websocket.server.ServerEndpoint; import java.io.File; import java.io.IOException; import java.net.Socket; @@ -285,6 +285,7 @@ public void onMessage(String message, Session session) { } case "installCert" -> SibTool.launch(udId, "com.apple.mobilesafari"); case "launch" -> SibTool.launch(udId, msg.getString("pkg")); + case "kill" -> SibTool.kill(udId, msg.getString("pkg")); case "uninstallApp" -> SibTool.uninstall(udId, msg.getString("detail")); case "debug" -> { switch (msg.getString("detail")) {