diff --git a/README.md b/README.md index c683c1a2..d7ae6a03 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@

- +

🎉Agent of Sonic Cloud Real Machine Testing Platform

English | - + 简体中文

- + @@ -18,18 +18,18 @@

- + - + - - + +

### Official Website -[Sonic Official Website](http://zhouyixun.gitee.io/sonic-official-website) +[Sonic Official Website](http://sonic-cloud.gitee.io) ## Background #### What is sonic ? @@ -62,7 +62,7 @@ mvn package -Pwindows-x86_64 > Can only be used on Linux or Mac! > -> [Click Here!](https://hub.docker.com/repository/docker/zhouyixun/sonic-agent-linux) +> [Click Here!](https://hub.docker.com/repository/docker/sonicorg) ### jar Mode diff --git a/README_CN.md b/README_CN.md index 3301fd27..fb448100 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,16 +1,16 @@

- +

🎉Sonic云真机测试平台Agent端

- + English | 简体中文

- + @@ -18,18 +18,18 @@

- + - + - - + +

### 官方网站 -[Sonic Official Website](http://zhouyixun.gitee.io/sonic-official-website) +[Sonic Official Website](http://sonic-cloud.gitee.io) ## 背景 #### 什么是Sonic? @@ -62,7 +62,7 @@ mvn package -Pwindows-x86_64 > 仅Linux和Mac可用! > -> [点击这里!](https://hub.docker.com/repository/docker/zhouyixun/sonic-agent-linux) +> [点击这里!](https://hub.docker.com/repository/docker/sonicorg) ### jar模式 diff --git a/config/application-prod.yml b/config/application-prod.yml index b8676de9..6c40687a 100644 --- a/config/application-prod.yml +++ b/config/application-prod.yml @@ -19,12 +19,12 @@ modules: android: enable: true # 是否开启远程adb调试功能 - use-adbkit: false + use-adbkit: true # iOS模块配置 ios: enable: true - #替换为wda的bundleId,正常要添加.xctrunner后缀 - wda-bundle-id: com.sonic.wda.xctrunner + #替换为你自己使用的wda的bundleId,正常要添加.xctrunner后缀,建议使用公司的开发者证书 + wda-bundle-id: com.facebook.WebDriverAgentRunner.xctrunner appium: enable: true # 在线webView调试模块配置 diff --git a/src/main/java/com/sonic/agent/automation/IOSStepHandler.java b/src/main/java/com/sonic/agent/automation/IOSStepHandler.java index 36327596..7abeae75 100644 --- a/src/main/java/com/sonic/agent/automation/IOSStepHandler.java +++ b/src/main/java/com/sonic/agent/automation/IOSStepHandler.java @@ -10,6 +10,7 @@ import com.sonic.agent.tools.LogTool; import com.sonic.agent.tools.UploadTools; import io.appium.java_client.MobileBy; +import io.appium.java_client.Setting; import io.appium.java_client.android.appmanagement.AndroidTerminateApplicationOptions; import io.appium.java_client.android.nativekey.AndroidKey; import io.appium.java_client.android.nativekey.KeyEvent; @@ -68,6 +69,7 @@ public int startIOSDriver(String udId) throws InterruptedException, IOException try { iosDriver = new IOSDriver(AppiumServer.service.getUrl(), desiredCapabilities); iosDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); + iosDriver.setSetting(Setting.MJPEG_SERVER_FRAMERATE, 30); log.sendStepLog(StepType.PASS, "连接设备驱动成功", ""); } catch (Exception e) { log.sendStepLog(StepType.ERROR, "连接设备驱动失败!", ""); @@ -95,6 +97,7 @@ public void closeIOSDriver() { List processList = IOSProcessMap.getMap().get(udId); for (Process p : processList) { if (p != null) { + p.children().forEach(ProcessHandle::destroy); p.destroy(); } } diff --git a/src/main/java/com/sonic/agent/websockets/AndroidWSServer.java b/src/main/java/com/sonic/agent/websockets/AndroidWSServer.java index c256ed0f..8dc727af 100644 --- a/src/main/java/com/sonic/agent/websockets/AndroidWSServer.java +++ b/src/main/java/com/sonic/agent/websockets/AndroidWSServer.java @@ -550,7 +550,7 @@ private void exit(Session session) { try { HandlerMap.getAndroidMap().get(session.getId()).closeAndroidDriver(); } catch (Exception e) { - e.printStackTrace(); + logger.info("关闭driver异常!"); } finally { HandlerMap.getAndroidMap().remove(session.getId()); } diff --git a/src/main/java/com/sonic/agent/websockets/IOSWSServer.java b/src/main/java/com/sonic/agent/websockets/IOSWSServer.java index 33fd9d99..9b1f0b61 100644 --- a/src/main/java/com/sonic/agent/websockets/IOSWSServer.java +++ b/src/main/java/com/sonic/agent/websockets/IOSWSServer.java @@ -44,7 +44,7 @@ import java.util.concurrent.atomic.AtomicReference; @Component -@ServerEndpoint(value = "/websockets/ios/{key}/{udId}", configurator = MyEndpointConfigure.class) +@ServerEndpoint(value = "/websockets/ios/{key}/{udId}/{token}", configurator = MyEndpointConfigure.class) public class IOSWSServer { private final Logger logger = LoggerFactory.getLogger(IOSWSServer.class); private Map udIdMap = new ConcurrentHashMap<>(); @@ -52,11 +52,17 @@ public class IOSWSServer { private String key; @OnOpen - public void onOpen(Session session, @PathParam("key") String secretKey, @PathParam("udId") String udId) throws Exception { - if (secretKey.length() == 0 || (!secretKey.equals(key))) { + public void onOpen(Session session, @PathParam("key") String secretKey, + @PathParam("udId") String udId, @PathParam("token") String token) throws Exception { + if (secretKey.length() == 0 || (!secretKey.equals(key)) || token.length() == 0) { logger.info("拦截访问!"); return; } + JSONObject jsonDebug = new JSONObject(); + jsonDebug.put("msg", "debugUser"); + jsonDebug.put("token", token); + jsonDebug.put("udId", udId); + NettyThreadPool.send(jsonDebug); WebSocketSessionMap.getMap().put(session.getId(), session); if (!TIDeviceTool.getDeviceList().contains(udId)) { logger.info("设备未连接,请检查!"); @@ -72,6 +78,8 @@ public void onOpen(Session session, @PathParam("key") String secretKey, @PathPar int imgPort = iosStepHandler.startIOSDriver(udId); result.put("status", "success"); result.put("port", imgPort); + result.put("width", iosStepHandler.getDriver().manage().window().getSize().width); + result.put("height", iosStepHandler.getDriver().manage().window().getSize().height); result.put("detail", "初始化Driver完成!"); HandlerMap.getIOSMap().put(session.getId(), iosStepHandler); } catch (Exception e) { @@ -252,7 +260,7 @@ private void exit(Session session) { try { HandlerMap.getIOSMap().get(session.getId()).closeIOSDriver(); } catch (Exception e) { - e.printStackTrace(); + logger.info("关闭driver异常!"); } finally { HandlerMap.getIOSMap().remove(session.getId()); }