From 7fdae0165c0a64d677b6eee1db55d710b515f2e8 Mon Sep 17 00:00:00 2001 From: ZhouYixun <291028775@qq.com> Date: Wed, 17 Nov 2021 12:17:02 +0800 Subject: [PATCH] save_beta2 --- .../bridge/ios/LibIMobileDeviceTool.java | 3 ++ .../com/sonic/agent/tests/AndroidTests.java | 54 +++---------------- 2 files changed, 11 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/sonic/agent/bridge/ios/LibIMobileDeviceTool.java b/src/main/java/com/sonic/agent/bridge/ios/LibIMobileDeviceTool.java index 2ab2be6d..83cc329e 100644 --- a/src/main/java/com/sonic/agent/bridge/ios/LibIMobileDeviceTool.java +++ b/src/main/java/com/sonic/agent/bridge/ios/LibIMobileDeviceTool.java @@ -9,6 +9,7 @@ import org.jsoup.nodes.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; @@ -17,6 +18,7 @@ import java.io.LineNumberReader; import java.util.List; +@ConditionalOnProperty(value = "modules.ios.enable", havingValue = "true") @DependsOn({"iOSThreadPoolInit", "nettyMsgInit"}) @Component public class LibIMobileDeviceTool { @@ -27,6 +29,7 @@ public LibIMobileDeviceTool() { } public static void init() { + logger.info("开启iOS相关功能"); if (!System.getProperty("os.name").contains("Mac")) { logger.info("iOS设备监听已关闭"); return; diff --git a/src/main/java/com/sonic/agent/tests/AndroidTests.java b/src/main/java/com/sonic/agent/tests/AndroidTests.java index eecf3400..4b6d3c23 100644 --- a/src/main/java/com/sonic/agent/tests/AndroidTests.java +++ b/src/main/java/com/sonic/agent/tests/AndroidTests.java @@ -125,29 +125,6 @@ public void run(JSONObject jsonObject) throws IOException { } continue; } -// File logDec = new File("test-output/log"); -// if (!logDec.exists()) { -// logDec.mkdirs(); -// } - //写入logcat -// File logcatFile = new File(logDec + File.separator + Calendar.getInstance().getTimeInMillis() + "_" + udId + ".log"); -// FileOutputStream logFileOut = null; -// try { -// logFileOut = new FileOutputStream(logcatFile); -// } catch (FileNotFoundException e) { -// logger.error(e.getMessage()); -// } -// FileOutputStream finalLogFileOut = logFileOut; - //添加监听 -// androidStepHandler.getAndroidDriver().addLogcatMessagesListener((msg) -> { -// try { -// finalLogFileOut.write((msg + "\n").getBytes(StandardCharsets.UTF_8)); -// } catch (IOException e) { -// logger.error(e.getMessage()); -// } -// }); - //开始广播 -// androidStepHandler.getAndroidDriver().startLogcatBroadcast("localhost", AppiumServer.service.getUrl().getPort()); Future miniCapPro = null; AtomicReference> imgList = new AtomicReference<>(new ArrayList<>()); AtomicReference banner = new AtomicReference<>(new String[24]); @@ -162,30 +139,15 @@ public void run(JSONObject jsonObject) throws IOException { MiniCapTool miniCapTool = new MiniCapTool(); miniCapPro = miniCapTool.start(udId, banner, imgList, "high", -1, null); } - //两分钟录一次 - try { - Thread.sleep(120000); - } catch (InterruptedException e) { - logger.error(e.getMessage()); + int w = 0; + while (w < 10 && (!runStep.isDone())) { + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + logger.error(e.getMessage()); + } + w++; } - //移除监听 -// androidStepHandler.getAndroidDriver().removeAllLogcatListeners(); - //移除logcat广播 -// androidStepHandler.getAndroidDriver().stopLogcatBroadcast(); - //关闭流 -// if (logFileOut != null) { -// try { -// logFileOut.close(); -// } catch (IOException e) { -// logger.error(e.getMessage()); -// } -// } - //处理logcat日志 -// if (isFail.get()) { -// androidStepHandler.log.sendSelfLog(logcatFile.getName(), UploadTools.upload(logcatFile, "logFiles")); -// } else { -// logcatFile.delete(); -// } //处理录像 if (isSupportRecord) { if (androidStepHandler.getStatus() == 3) {