From fe1f44827c277a7587326281fa91af3d191fd8d9 Mon Sep 17 00:00:00 2001 From: dyx123 <3055464370@qq.com> Date: Thu, 11 Nov 2021 09:56:52 +0800 Subject: [PATCH] =?UTF-8?q?atom=20=E9=9D=92=E5=B0=91=E5=B9=B4=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/gradle.xml | 3 +- .../fisherbone/fuzhu/abllib/AblService.java | 5 +- .../fuzhu/abllib/utils/AblViewUtil.java | 70 +++++++++++++++++++ .../com/fisherbone/fuzhu/quzan/AblStep1.java | 45 ++---------- 4 files changed, 81 insertions(+), 42 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index dbf0c76..22956b0 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,7 +4,7 @@ diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/AblService.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblService.java index 31cfbff..f80bb66 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/abllib/AblService.java +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/AblService.java @@ -158,7 +158,7 @@ public class AblService extends AccessibilityService { if (classname.equals("android.app.AlertDialog")) { } else if (classname.equals("com.android.packageinstaller.permission.ui.GrantPermissionsActivity")) { -// //点击安装 + //点击安装 // AblViewUtil.mySleep(2); // inputClickId("始终允许"); } else if (classname.equals("com.android.packageinstaller.PackageInstallerActivity")) { @@ -177,7 +177,8 @@ public class AblService extends AccessibilityService { } else if (classname.equals("androidx.appcompat.app.AlertDialog")) { if (str.contains("为呵护未成")) { AblViewUtil.mySleep(2); - performGlobalAction(GLOBAL_ACTION_BACK); // 返回安装页面 + performGlobalAction(GLOBAL_ACTION_BACK); + // 返回安装页面 Log.e("TIAOSHI###", "关闭了为呵护未成年人健康成长的弹框"); } } else if (str.contains("检测到更新")) {//测试可以用 diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblViewUtil.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblViewUtil.java index b702fd7..fe20c34 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblViewUtil.java +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/utils/AblViewUtil.java @@ -15,6 +15,7 @@ import android.graphics.Rect; import android.os.Build; import android.os.Bundle; import android.util.Log; +import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import androidx.annotation.Nullable; @@ -582,4 +583,73 @@ public class AblViewUtil { public static void potgegin(String str){ infoMessag.potgegin(str); } + + + /** + * 跳过广告 + */ + public static void Skip(){ + List nodeInfoList = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText("跳过"); + for (AccessibilityNodeInfo info : nodeInfoList) { + CharSequence charSequence = info.getText(); + if (charSequence != null) { + String msg = charSequence.toString(); + if (msg.contains("跳过")) { + info.performAction(AccessibilityNodeInfo.ACTION_CLICK); + } + } + } + } + + /** + * 关闭弹窗 + */ + public static void Close(){ + if (isContainText("青少年模式")){ + findAndPerformActionTextView("我知道了"); + } + if (isContainText("获取设备的定位信息")){ + findAndPerformActionTextView("仅在使用中允许"); + } + if (isContainText("")){ + findAndPerformActionTextView(""); + } + } + + + /** + * + * @param text + * 根据文本寻找控件节点 + */ + public static void findAndPerformActionTextView(String text) { + if (AblService.getInstance().getRootInActiveWindow() == null) { + return; + } + List node = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText(text); + for ( int i = 0; i < node.size(); i++ ){ + AccessibilityNodeInfo nodeInfo = (AccessibilityNodeInfo) node.get(i); + if (nodeInfo != null && nodeInfo.isEnabled()){ + performViewClick(nodeInfo); + } + } + } + /** + * 模拟点击事件,如果该node不能点击,则点击父node,将点击事件一直向父级传递,直至到根node或者找到一个可以点击的node + * + * @param nodeInfo nodeInfo + */ + public static void performViewClick(AccessibilityNodeInfo nodeInfo) { + if (nodeInfo == null) { + return; + } else { + while (nodeInfo != null) { + if (nodeInfo.isClickable()) { + nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK); + break; + } + nodeInfo = nodeInfo.getParent(); + } + } + } } diff --git a/app/src/main/java/com/fisherbone/fuzhu/quzan/AblStep1.java b/app/src/main/java/com/fisherbone/fuzhu/quzan/AblStep1.java index 1c1c321..a8c91b4 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/quzan/AblStep1.java +++ b/app/src/main/java/com/fisherbone/fuzhu/quzan/AblStep1.java @@ -2,6 +2,7 @@ package com.fisherbone.fuzhu.quzan; import android.os.Message; import android.view.accessibility.AccessibilityNodeInfo; +import android.widget.Toast; import com.fisherbone.fuzhu.ChangLiang; import com.fisherbone.fuzhu.abllib.AblService; @@ -26,19 +27,20 @@ public class AblStep1 extends BaseAblStep { switch ( step ){ case AblSteps.STEP_260: AblViewUtil.startApplication(); + AblViewUtil.Skip(); AblViewUtil.mySleep(5); AblStepHandler.sendMsg(AblSteps.STEP_261); break; case AblSteps.STEP_261: ChangLiang.ishuodong = "T"; - AblViewUtil.mySleep(2); + AblViewUtil.Close(); + AblViewUtil.mySleep(5); AblService instance = AblService.getInstance(); - AblViewUtil.mySleep(2); myClick(); AblStepHandler.sendMsg(AblSteps.STEP_262); break; case AblSteps.STEP_262: - findAndPerformActionTextView("喜欢"); + AblViewUtil.findAndPerformActionTextView("喜欢"); AblStepHandler.sendMsg(AblSteps.STEP_263); break; case AblSteps.STEP_263: @@ -59,41 +61,6 @@ public class AblStep1 extends BaseAblStep { } - /** - * - * @param text - * 根据文本寻找控件节点 - */ - public void findAndPerformActionTextView(String text) { - if (AblService.getInstance().getRootInActiveWindow() == null) { - return; - } - List node = AblService.getInstance().getRootInActiveWindow().findAccessibilityNodeInfosByText(text); - for ( int i = 0; i < node.size(); i++ ){ - AccessibilityNodeInfo nodeInfo = (AccessibilityNodeInfo) node.get(i); - if (nodeInfo != null && nodeInfo.isEnabled()){ - performViewClick(nodeInfo); - } - } - } - /** - * 模拟点击事件,如果该node不能点击,则点击父node,将点击事件一直向父级传递,直至到根node或者找到一个可以点击的node - * - * @param nodeInfo nodeInfo - */ - public void performViewClick(AccessibilityNodeInfo nodeInfo) { - if (nodeInfo == null) { - return; - } else { - while (nodeInfo != null) { - if (nodeInfo.isClickable()) { - nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK); - break; - } - nodeInfo = nodeInfo.getParent(); - } - } - } /** * 根据控件描述文本找到“喜欢”按钮 @@ -110,4 +77,6 @@ public class AblStep1 extends BaseAblStep { } } } + + }