Skip to content

Commit

Permalink
1. untilFindOne(int timeout) 提升运行速度
Browse files Browse the repository at this point in the history
2. 默认不开启flagIncludeNotImportantViews
  • Loading branch information
1754048656 committed Dec 20, 2023
1 parent 5b5dc66 commit 777e5a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
32 changes: 16 additions & 16 deletions app/src/main/java/com/linsheng/FATJS/node/AccUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1157,7 +1157,7 @@ public static void timeSleep(int loop_time) {
}
}
} catch (InterruptedException e) {
printLogMsg(ExceptionUtil.toString(e));
printLogMsg(ExceptionUtil.toString(e), 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/linsheng/FATJS/node/UiSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/xml/accessibility.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeWindowStateChanged|typeContextClicked|typeViewClicked|typeViewTextChanged|typeViewScrolled|typeAllMask"
android:accessibilityFlags="flagDefault|flagIncludeNotImportantViews|flagReportViewIds|flagRetrieveInteractiveWindows"
android:accessibilityFlags="flagDefault|flagReportViewIds|flagRetrieveInteractiveWindows"
android:accessibilityFeedbackType="feedbackSpoken"
android:canRetrieveWindowContent="true"
android:notificationTimeout="100"
android:canPerformGestures="true"
/>

<!--FLAG_DEFAULT 默认标志位,表示使用默认的配置-->
<!-- |flagIncludeNotImportantViews -->
<!--FLAG_INCLUDE_NOT_IMPORTANT_VIEWS 包括不重要的视图。通常情况下,可访问性服务只会关注重要的视图,但设置了该标志位后,可访问性服务将会关注所有的视图-->
<!--FLAG_REPORT_VIEW_IDS 报告视图ID。设置了该标志位后,可访问性服务将会报告每个视图的唯一ID-->
<!--FLAG_REQUEST_TOUCH_EXPLORATION_MODE 请求触摸探索模式。设置了该标志位后,可访问性服务将会请求触摸探索模式,以便用户可以通过触摸来探索屏幕上的内容-->
Expand Down

0 comments on commit 777e5a3

Please sign in to comment.