Skip to content

Commit

Permalink
feat: add app force stop
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Mar 15, 2023
1 parent 902936b commit e0d584a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(",")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand Down

0 comments on commit e0d584a

Please sign in to comment.