From 777e5a367b19050884e57684f5d42ff11d6b4b03 Mon Sep 17 00:00:00 2001 From: 1754048656 <1754048656@qq.com> Date: Wed, 20 Dec 2023 15:54:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=20untilFindOne(int=20timeout)=20=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E8=BF=90=E8=A1=8C=E9=80=9F=E5=BA=A6=202.=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=8D=E5=BC=80=E5=90=AFflagIncludeNotImportantView?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/linsheng/FATJS/node/AccUtils.java | 32 +++++++++---------- .../com/linsheng/FATJS/node/UiSelector.java | 2 +- app/src/main/res/xml/accessibility.xml | 3 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/linsheng/FATJS/node/AccUtils.java b/app/src/main/java/com/linsheng/FATJS/node/AccUtils.java index 372f407..c5ab096 100644 --- a/app/src/main/java/com/linsheng/FATJS/node/AccUtils.java +++ b/app/src/main/java/com/linsheng/FATJS/node/AccUtils.java @@ -67,9 +67,9 @@ public static int extractFirstIntFromString(String str){ int i = -1; if (m.find()){ i = Integer.parseInt(m.group()); - AccUtils.printLogMsg("提取到的第一个整数是:" + i); + printLogMsg("提取到的第一个整数是:" + i, 0); } else { - AccUtils.printLogMsg("在字符串中没有找到整数!"); + printLogMsg("在字符串中没有找到整数!", 0); } return i; } @@ -95,7 +95,7 @@ public static void backToDesktop() { @RequiresApi(api = Build.VERSION_CODES.N) public static void viewVideo(int num) { UiSelector uiSelector = new UiSelector(); - printLogMsg("刷" + num + "个视频,点掉弹窗"); + printLogMsg("刷" + num + "个视频,点掉弹窗", 0); for (int i = 0; i < num; i++) { uiSelector.text("我知道了").findOne().click(); timeSleep(waitOneSecond); @@ -183,14 +183,14 @@ public static void printLogMsg(String msg, int type) { */ static AccessibilityNodeInfo root; public static AccessibilityNodeInfo getRootInActiveMy() { - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 10; i++) { root = AccessibilityHelper.getRootInActiveWindow(); if (root != null) { return root; } - timeSleep(500); + timeSleep(50); } - printLogMsg( "Exception: do not find window"); + printLogMsg( "Exception: do not find window", 0); return root; } @@ -251,7 +251,7 @@ static class StopRunException extends RuntimeException { public static void waitToAlarmClose() { printLogMsg("\n---------\n---------\n---------\n---------\n---------\n---------\n---------\n---------\n"); - printLogMsg("W: " + mWidth + " H: " + mHeight); + printLogMsg("W: " + mWidth + " H: " + mHeight, 0); timeSleep(6000); } @@ -314,11 +314,11 @@ public static boolean clickPoint(float x1, float y1, long duration) { Path path = new Path(); x1 = x1 + new Random().nextInt(9) - 4; y1 = y1 + new Random().nextInt(9) - 4; - printLogMsg("[x => " + x1 + ", y => " + y1 + "]"); + printLogMsg("[x => " + x1 + ", y => " + y1 + "]", 0); if (x1 > mWidth || y1 > mHeight || x1 < 0 || y1 < 0) { - printLogMsg("mWidth: " + mWidth); - printLogMsg("mHeight: " + mHeight); - printLogMsg("超出了点击范围"); + printLogMsg("mWidth: " + mWidth, 0); + printLogMsg("mHeight: " + mHeight, 0); + printLogMsg("超出了点击范围", 0); return false; } path.moveTo(x1, y1); @@ -350,11 +350,11 @@ public void onCancelled(GestureDescription gestureDescription1) { @RequiresApi(24) public static boolean clickExactPoint(float x1, float y1, long duration) { Path path = new Path(); - // printLogMsg("[x => " + x1 + ", y => " + y1 + "]"); + // printLogMsg("[x => " + x1 + ", y => " + y1 + "]", 0); if (x1 > mWidth || y1 > mHeight || x1 < 0 || y1 < 0) { - printLogMsg("mWidth: " + mWidth); - printLogMsg("mHeight: " + mHeight); - printLogMsg("超出了点击范围"); + printLogMsg("mWidth: " + mWidth, 0); + printLogMsg("mHeight: " + mHeight, 0); + printLogMsg("超出了点击范围", 0); return false; } path.moveTo(x1, y1); @@ -1157,7 +1157,7 @@ public static void timeSleep(int loop_time) { } } } catch (InterruptedException e) { - printLogMsg(ExceptionUtil.toString(e)); + printLogMsg(ExceptionUtil.toString(e), 0); } } diff --git a/app/src/main/java/com/linsheng/FATJS/node/UiSelector.java b/app/src/main/java/com/linsheng/FATJS/node/UiSelector.java index 7abc047..cefd543 100644 --- a/app/src/main/java/com/linsheng/FATJS/node/UiSelector.java +++ b/app/src/main/java/com/linsheng/FATJS/node/UiSelector.java @@ -723,7 +723,7 @@ public UiObject untilFindOne(int timeout) { return uiObject; } //printLogMsg("untilFindOne timeout: wait 1s"); - AccUtils.timeSleep(waitOneSecond); + AccUtils.timeSleep(10); long currentTime = System.currentTimeMillis(); if (currentTime - startTime >= timeout) { //printLogMsg("untilFindOne timeout: not found"); diff --git a/app/src/main/res/xml/accessibility.xml b/app/src/main/res/xml/accessibility.xml index 6563c64..201c162 100644 --- a/app/src/main/res/xml/accessibility.xml +++ b/app/src/main/res/xml/accessibility.xml @@ -1,7 +1,7 @@ +