From effc9fdbe62c2f04090613ee4bc9e0a55230863a Mon Sep 17 00:00:00 2001 From: caofengbin <1050430934@qq.com> Date: Fri, 16 Jun 2023 20:06:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=89=E5=8D=93=E7=AB=AF=E7=9A=84uninsta?= =?UTF-8?q?ll=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=EF=BC=8C=E4=BB=85=E5=9C=A8errorMessage?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E8=AE=A4=E5=AE=9A=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent/bridge/android/AndroidDeviceBridgeTool.java | 4 ++-- .../org/cloud/sonic/agent/websockets/AndroidWSServer.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java b/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java index 5014cac6..b251c66c 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java @@ -408,8 +408,8 @@ public static void pressKey(IDevice iDevice, AndroidKey androidKey) { executeCommand(iDevice, String.format("input keyevent %s", androidKey.getCode())); } - public static void uninstall(IDevice iDevice, String bundleId) throws InstallException { - iDevice.uninstallPackage(bundleId); + public static String uninstall(IDevice iDevice, String bundleId) throws InstallException { + return iDevice.uninstallPackage(bundleId); } public static void forceStop(IDevice iDevice, String bundleId) { 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 88ba2791..37a6b107 100755 --- a/src/main/java/org/cloud/sonic/agent/websockets/AndroidWSServer.java +++ b/src/main/java/org/cloud/sonic/agent/websockets/AndroidWSServer.java @@ -212,8 +212,12 @@ public void onMessage(String message, Session session) { case "uninstallApp" -> { JSONObject result = new JSONObject(); try { - AndroidDeviceBridgeTool.uninstall(iDevice, msg.getString("detail")); - result.put("detail", "success"); + String errorMessage = AndroidDeviceBridgeTool.uninstall(iDevice, msg.getString("detail")); + if (errorMessage == null) { + result.put("detail", "success"); + } else { + result.put("detail", "fail"); + } } catch (InstallException e) { result.put("detail", "fail"); e.printStackTrace(); From 9e63363526d9da4a93f5c2248ac33c30356bcb1e Mon Sep 17 00:00:00 2001 From: caofengbin <1050430934@qq.com> Date: Fri, 16 Jun 2023 20:21:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=8C=85=E5=90=8D?= =?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=8C=E6=88=96=E8=80=85=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=EF=BC=8Cuninstall=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E8=AE=A4=E5=AE=9A=E4=B8=BA=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sonic/agent/tests/handlers/AndroidStepHandler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java b/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java index c01579f7..99463d54 100755 --- a/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java +++ b/src/main/java/org/cloud/sonic/agent/tests/handlers/AndroidStepHandler.java @@ -381,9 +381,13 @@ public void install(HandleContext handleContext, String path) { public void uninstall(HandleContext handleContext, String appPackage) { handleContext.setStepDes("卸载应用"); appPackage = TextHandler.replaceTrans(appPackage, globalParams); - handleContext.setDetail("App包名: " + appPackage); try { - AndroidDeviceBridgeTool.uninstall(iDevice, appPackage); + String errorMessage = AndroidDeviceBridgeTool.uninstall(iDevice, appPackage); + if (errorMessage == null) { + handleContext.setDetail("App包名:" + appPackage + "卸载成功"); + } else { + handleContext.setE(new Exception("uninstall app " + appPackage + " failed,errorMessage:" + errorMessage)); + } } catch (Exception e) { handleContext.setE(e); }