From a4864d15e870da3c838ffde7f3791a2b815f903b Mon Sep 17 00:00:00 2001 From: jianbo <263303411@qq.com> Date: Sun, 26 Sep 2021 17:08:32 +0800 Subject: [PATCH] atom --- .../new_modular_customarouter/test2.java | 35 + .../fisherbone/fuzhu/abllib/BaseAblStep.java | 20 +- .../fuzhu/activity/CancleFollowActivity.java | 41 +- .../fuzhu/activity/ControlWindow.java | 32 +- .../fuzhu/activity/MainActivity.java | 4 +- .../fisherbone/fuzhu/activity/ShowAty.java | 19 - .../fuzhu/entity/CancleFollowBean.java | 6 +- .../fisherbone/fuzhu/step/TestAblStep0.java | 192 ++-- .../fisherbone/fuzhu/step/TestAblStep2.java | 18 +- .../fisherbone/fuzhu/step/TestAblStep21.java | 360 ------- .../fuzhu/step/TestAblStep31bei.java | 923 ------------------ .../fisherbone/fuzhu/step/TestAblStep6.java | 322 +++--- .../fisherbone/fuzhu/step/TestAblStep7.java | 385 -------- .../res/layout/activity_cancle_follow.xml | 2 + 14 files changed, 371 insertions(+), 1988 deletions(-) create mode 100644 app/src/androidTest/java/com/xiangxue/new_modular_customarouter/test2.java delete mode 100644 app/src/main/java/com/fisherbone/fuzhu/activity/ShowAty.java delete mode 100644 app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep21.java delete mode 100644 app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java delete mode 100644 app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep7.java diff --git a/app/src/androidTest/java/com/xiangxue/new_modular_customarouter/test2.java b/app/src/androidTest/java/com/xiangxue/new_modular_customarouter/test2.java new file mode 100644 index 0000000..388065d --- /dev/null +++ b/app/src/androidTest/java/com/xiangxue/new_modular_customarouter/test2.java @@ -0,0 +1,35 @@ +package com.xiangxue.new_modular_customarouter; + +import android.content.Context; +import android.util.Log; + +import androidx.test.InstrumentationRegistry; + +import org.junit.Before; +import org.junit.Test; + +/** + * 数据库调试 + */ +public class test2 { + + private Context mTargetContext; + + @Before + public void setUp() throws Exception { + mTargetContext = InstrumentationRegistry.getTargetContext(); + } + + @Test + public void onCreate() { + + gaizaotime("关注 389"); + } + + private void gaizaotime(String end_time) { + + String[] all = end_time.split(" "); + Log.e("TIAOSHI###", all[1]); + } + +} diff --git a/app/src/main/java/com/fisherbone/fuzhu/abllib/BaseAblStep.java b/app/src/main/java/com/fisherbone/fuzhu/abllib/BaseAblStep.java index cbfc251..e10ca27 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/abllib/BaseAblStep.java +++ b/app/src/main/java/com/fisherbone/fuzhu/abllib/BaseAblStep.java @@ -33,7 +33,11 @@ public abstract class BaseAblStep implements AblStepHandler.StepListener { AblService instance = AblService.getInstance(); if(ChangLiang.phonetype.equals("0")){ instance.clickPoint(648,1286, 300);//红米7a - }else { + }else if(ChangLiang.phonetype.equals("3")){ + AblViewUtil.mySleep(6); + AblService.getInstance().clickPoint(972, 2103, 300); + } + else { instance.clickPoint(648,1536, 300);//华为畅享20 [632,1521][664,1552] } Log.e("TIAOSHI###", "点击了我按钮"); @@ -70,8 +74,6 @@ public abstract class BaseAblStep implements AblStepHandler.StepListener { Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); } else { Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); - AblViewUtil.mySleep(2); - AblStepHandler.sendMsg(AblSteps.STEP_14); } } @@ -345,16 +347,16 @@ public abstract class BaseAblStep implements AblStepHandler.StepListener { AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); -// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); -// nodeZuobiao(child); + Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + nodeZuobiao(child); for (int y = 0; y < child.getChildCount(); y++) { AccessibilityNodeInfo child1 = child.getChild(y); -// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); -// nodeZuobiao(child1); + Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + nodeZuobiao(child1); for (int j = 0; j < child1.getChildCount(); j++) { AccessibilityNodeInfo child2 = child1.getChild(j); -// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); -// nodeZuobiao(child2); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + nodeZuobiao(child2); for (int x = 0; x < child2.getChildCount(); x++) { AccessibilityNodeInfo child3 = child2.getChild(x); Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/CancleFollowActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/CancleFollowActivity.java index 23ccae2..a6735c0 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/activity/CancleFollowActivity.java +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/CancleFollowActivity.java @@ -37,27 +37,10 @@ public class CancleFollowActivity extends BaseActivity { mTitleBar = (TitleBar) findViewById(R.id.title_bar); mTitleBar.setTitle("一键取关"); initNormalBack(); - binding.radioButton01.setChecked(true); - cancleFollowBean.setCancelclosed(true); - binding.radioButton02.setChecked(false); - cancleFollowBean.setCancelcrosscor(false); - - binding.radioButton01.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean b) { - cancleFollowBean.setCancelclosed(b); - } - }); - binding.radioButton02.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean b) { - cancleFollowBean.setCancelcrosscor(b); - } - }); - binding.rlStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + ProfileSpUtils.getInstance().saveCan(cancleFollowBean); Log.e("TIAOSHI###==发送的一键取关参数", cancleFollowBean.toString()); //将参数数据缓存起来 ChangLiang.cancelclosed = cancleFollowBean.getCancelclosed(); @@ -89,25 +72,9 @@ public class CancleFollowActivity extends BaseActivity { } } - if(!addWinEntity.cancleisopen){ - //下面两个步骤不能同时执行 - //取消已关 - if (ChangLiang.cancelclosed&&!ChangLiang.cancelcrosscor) { - Log.e("TIAOSHI###==发送的一键取关参数", "执行取消已关"); - EventBus.getDefault().post(new FourEvent("success","2")); - - } - //取消互关 - if (ChangLiang.cancelcrosscor&&!ChangLiang.cancelclosed) { - Log.e("TIAOSHI###==发送的一键取关参数", "执行取消互关"); - EventBus.getDefault().post(new FourEvent("success","2")); - } - - if(ChangLiang.cancelclosed&&ChangLiang.cancelcrosscor){ - Log.e("TIAOSHI###==发送的一键取关参数", "执行取消互关"); - EventBus.getDefault().post(new FourEvent("success","2")); - } - } +// if(!addWinEntity.cancleisopen){ +// EventBus.getDefault().post(new FourEvent("success","2")); +// } } }); } diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/ControlWindow.java b/app/src/main/java/com/fisherbone/fuzhu/activity/ControlWindow.java index ed07ecc..851c45f 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/activity/ControlWindow.java +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/ControlWindow.java @@ -19,6 +19,7 @@ import com.fisherbone.fuzhu.entity.ControlBean; import com.fisherbone.fuzhu.entity.addWinEntity; import com.fisherbone.fuzhu.step.TestAblStep30; import com.fisherbone.fuzhu.step.TestAblStep34; +import com.fisherbone.fuzhu.step.TestAblStep6; import com.fisherbone.fuzhu.step.TestAblStepXin5; import com.fisherbone.fuzhu.utils.ProfileSpUtils; import com.jeremyliao.liveeventbus.LiveEventBus; @@ -75,21 +76,9 @@ public class ControlWindow { break; case "2": if (AblUtil.isAccessibilityServiceOpen(mContext)) { + AblStepHandler.getInstance().initStepClass(new TestAblStep6()); stutas(ChangLiang.isrun); - if (ChangLiang.cancelclosed && !ChangLiang.cancelcrosscor) { - Log.e("TIAOSHI###", "执行取消关注"); - AblStepHandler.sendMsg(AblSteps.STEP_11); - } - //取消互关 - if (ChangLiang.cancelcrosscor && !ChangLiang.cancelclosed) { - Log.e("TIAOSHI###", "执行取消相互关注"); - AblStepHandler.sendMsg(AblSteps.STEP_15); - } - //取消互关+取消已关 - if (ChangLiang.cancelcrosscor && ChangLiang.cancelclosed) { - Log.e("TIAOSHI###", "执行取消相互关注+取消已关"); - AblStepHandler.sendMsg(AblSteps.STEP_60); - } + AblStepHandler.sendMsg(AblSteps.STEP_11); } else { ToastUtils.showShort("点到了"); ToastUtils.showShort("请先开启辅助服务"); @@ -193,20 +182,7 @@ public class ControlWindow { case "2": if (AblUtil.isAccessibilityServiceOpen(mContext)) { stutas(ChangLiang.isrun); - if (ChangLiang.cancelclosed && !ChangLiang.cancelcrosscor) { - Log.e("TIAOSHI###", "执行取消关注"); - AblStepHandler.sendMsg(AblSteps.STEP_11); - } - //取消互关 - if (ChangLiang.cancelcrosscor && !ChangLiang.cancelclosed) { - Log.e("TIAOSHI###", "执行取消相互关注"); - AblStepHandler.sendMsg(AblSteps.STEP_15); - } - //取消互关+取消已关 - if (ChangLiang.cancelcrosscor && ChangLiang.cancelclosed) { - Log.e("TIAOSHI###", "执行取消相互关注+取消已关"); - AblStepHandler.sendMsg(AblSteps.STEP_60); - } + AblStepHandler.sendMsg(AblSteps.STEP_11); } else { ToastUtils.showShort("点到了"); ToastUtils.showShort("请先开启辅助服务"); diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/MainActivity.java b/app/src/main/java/com/fisherbone/fuzhu/activity/MainActivity.java index 3fd7d8e..6b9facd 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/activity/MainActivity.java +++ b/app/src/main/java/com/fisherbone/fuzhu/activity/MainActivity.java @@ -66,7 +66,6 @@ import com.fisherbone.fuzhu.step.TestAblStep13; import com.fisherbone.fuzhu.step.TestAblStep18; import com.fisherbone.fuzhu.step.TestAblStep19; import com.fisherbone.fuzhu.step.TestAblStep2; -import com.fisherbone.fuzhu.step.TestAblStep21; import com.fisherbone.fuzhu.step.TestAblStep23; import com.fisherbone.fuzhu.step.TestAblStep24; import com.fisherbone.fuzhu.step.TestAblStep25; @@ -78,7 +77,6 @@ import com.fisherbone.fuzhu.step.TestAblStep31; import com.fisherbone.fuzhu.step.TestAblStep32; import com.fisherbone.fuzhu.step.TestAblStep33; import com.fisherbone.fuzhu.step.TestAblStep6; -import com.fisherbone.fuzhu.step.TestAblStep7; import com.fisherbone.fuzhu.step.TestAblStep8; import com.fisherbone.fuzhu.step.TestAblStep9; import com.fisherbone.fuzhu.utils.JsonUtils; @@ -286,7 +284,7 @@ public class MainActivity extends BaseActivity implements InfoMessage { .setFindViewMillisInFuture(10000)//寻找界面超时时间 .setFindViewCountDownInterval(200)//寻找界面间隔时间 .build().init(); - AblStepHandler.getInstance().initStepClass(new TestAblStep0(), new TestAblStep1(), new TestAblStep2(), new TestAblStep6(), new TestAblStep7(), new TestAblStep8(), new TestAblStep9(), new TestAblStep10(), new TestAblStep12(), new TestAblStep13(), new TestAblStep18(), new TestAblStep19(), new TestAblStep21(), new TestAblStep23(), new TestAblStep24(), new TestAblStep25(), new TestAblStep26(), new TestAblStep27(), new TestAblStep28(), new TestAblStep29(), new TestAblStep31(), new TestAblStep32(), new TestAblStep33()); + AblStepHandler.getInstance().initStepClass(new TestAblStep0(), new TestAblStep1(), new TestAblStep2(), new TestAblStep8(), new TestAblStep9(), new TestAblStep10(), new TestAblStep12(), new TestAblStep13(), new TestAblStep18(), new TestAblStep19(), new TestAblStep23(), new TestAblStep24(), new TestAblStep25(), new TestAblStep26(), new TestAblStep27(), new TestAblStep28(), new TestAblStep29(), new TestAblStep31(), new TestAblStep32(), new TestAblStep33()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { int hasWriteContactsPermission = checkSelfPermission(Manifest.permission.READ_CONTACTS); if (hasWriteContactsPermission != PackageManager.PERMISSION_GRANTED) { diff --git a/app/src/main/java/com/fisherbone/fuzhu/activity/ShowAty.java b/app/src/main/java/com/fisherbone/fuzhu/activity/ShowAty.java deleted file mode 100644 index 0667b13..0000000 --- a/app/src/main/java/com/fisherbone/fuzhu/activity/ShowAty.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fisherbone.fuzhu.activity; - -import android.content.Context; -import android.content.Intent; - -public class ShowAty { - - public static void LoginPasswordActivity(Context ctx) { -// Intent i = new Intent(ctx, LoginPasswordActivity.class); -// i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); -// ctx.startActivity(i); - } - - public static void ScriptSettingActivity(Context ctx) { - Intent i = new Intent(ctx, ScriptSettingActivity.class); - ctx.startActivity(i); - } - -} diff --git a/app/src/main/java/com/fisherbone/fuzhu/entity/CancleFollowBean.java b/app/src/main/java/com/fisherbone/fuzhu/entity/CancleFollowBean.java index 6667ce8..4ec03a8 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/entity/CancleFollowBean.java +++ b/app/src/main/java/com/fisherbone/fuzhu/entity/CancleFollowBean.java @@ -37,21 +37,23 @@ public class CancleFollowBean extends BaseObservable { } String passnumber; //取关数 - + @Bindable public boolean getCancelclosed() { return cancelclosed; } public void setCancelclosed(boolean cancelclosed) { this.cancelclosed = cancelclosed; + notifyPropertyChanged(BR.cancelclosed); } - + @Bindable public boolean getCancelcrosscor() { return cancelcrosscor; } public void setCancelcrosscor(boolean cancelcrosscor) { this.cancelcrosscor = cancelcrosscor; + notifyPropertyChanged(BR.cancelcrosscor); } @Bindable diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep0.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep0.java index 9380394..ade21c9 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep0.java +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep0.java @@ -21,50 +21,61 @@ import java.util.List; * 获得作品时间 */ public class TestAblStep0 extends BaseAblStep { - private List jiluBeans; - private String guanzhunum; - private String fensinum; - private String zuopinnum; - private String huozannum; - public String SHEBEITIPE_VILUEONE = "0"; - public String SHEBEITIPE_VILUETHREE = "3"; - private ArrayList accessibilityNodeInfos; - private String direction = "0";//0代表向上滑动,1代表向下 - public String IFCONTIAN = "x"; - private int liwusubstring; - private boolean noqinmidu = true; - private int num3; + private String substring = "1000000";//当前的关注数 @Override public void onStep(int step, Message msg) { switch (step) { case AblSteps.STEP_1: AblViewUtil.startApplication(); - jiluBeans = new ArrayList<>(); AblStepHandler.sendMsg(AblSteps.STEP_2); break; case AblSteps.STEP_2: AblViewUtil.mySleep(2); - // getNodeInfoh(); - // geliwu(""); - AblService.getInstance().clickPoint(100, 100, 200); + // getNodeInfoh(); + // getNum(); + cancelGuanzhu(); break; default: } } - /** - * 获得背包中第一排位置的了礼物 - */ - private int geliwu(String text) { - int doubiNum = 0; - ArrayList liwuBeans = new ArrayList<>(); - ArrayList oneInfos = new ArrayList<>(); - ArrayList twoInfos = new ArrayList<>(); - ArrayList threeInfos = new ArrayList<>(); - ArrayList fourInfos = new ArrayList<>(); + /** + * 获得左上角主播的昵称 + * @return + */ + private String getNodeName() { + String nikename= ""; + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + nodeZuobiao(child2); + //fourNode:android.widget.TextView:关注 389:关注 389,按钮 + //显示节点的坐标:(208,253),(375,308) + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); + nodeZuobiao(child3); + nikename = AblViewUtil.getString(nikename, child3, 253, 308, 208, 540, "android.widget.TextView"); + } + } + } + } + return nikename; + } + + private void cancelGuanzhu() { AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); @@ -80,90 +91,69 @@ public class TestAblStep0 extends BaseAblStep { // nodeZuobiao(child2); for (int x = 0; x < child2.getChildCount(); x++) { AccessibilityNodeInfo child3 = child2.getChild(x); - Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); - nodeZuobiao(child3); - - Rect rect = new Rect(); - child3.getBoundsInScreen(rect); - if (rect.top >= 1438 && rect.bottom <= 1698 && rect.left >= 37 && rect.right <= 248) { - - Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); - nodeZuobiao(child3); - oneInfos.add(child3); - - - } - if (rect.top >= 1438 && rect.bottom <= 1698 && rect.left >= 248 && rect.right <= 540) { - - Log.e("TIAOSHI###", "----fourNodetwo:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); - nodeZuobiao(child3); - twoInfos.add(child3); - - } - if (rect.top >= 1438 && rect.bottom <= 1698 && rect.left >= 540 && rect.right <= 810) { - - Log.e("TIAOSHI###", "----fourNodehree:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); - nodeZuobiao(child3); - threeInfos.add(child3); - - } - if (rect.top >= 1438 && rect.bottom <= 1698 && rect.left >= 810 && rect.right <= 1080) { - - Log.e("TIAOSHI###", "----fourNodefour:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); - nodeZuobiao(child3); - fourInfos.add(child3); +// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); +// nodeZuobiao(child3); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); +// Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText()+ ":" + child4.getContentDescription()); +// nodeZuobiao(child4); + for (int m = 0; m < child4.getChildCount(); m++) { + AccessibilityNodeInfo child5 = child4.getChild(m); + // Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription()); + nodeZuobiao(child5); + yiguanzhu(child5); + } } } } } } - addLiwuData(liwuBeans, oneInfos); - addLiwuData(liwuBeans, twoInfos); - addLiwuData(liwuBeans, threeInfos); - addLiwuData(liwuBeans, fourInfos); - Gson gson = new Gson(); - String s1 = gson.toJson(liwuBeans); - Log.e("礼物的字符串", s1);//[{"login_status":"1","short_id":"xiao629972576","short_name":""}] - for(int j=0;j liwuBeans, ArrayList oneInfos) { - LiwuBean liwuBean = new LiwuBean(); - if (oneInfos.size() > 0) { - String s0 = oneInfos.get(0).getText().toString(); - liwuBean.setLiwuTime(s0); - String s1 = oneInfos.get(1).getText().toString(); - liwuBean.setLiwuName(s1); - String s2 = oneInfos.get(2).getText().toString(); - if(s1.equals("大啤酒")) { - liwuBean.setLiwuDanjia("2"); - }else if(s1.equals("小心心")){ - liwuBean.setLiwuDanjia("1"); - }else if(s1.equals("棒棒糖")){ - liwuBean.setLiwuDanjia("9"); - }else if(s1.equals("玫瑰")){ - liwuBean.setLiwuDanjia("1"); + if (child2.getChildCount() != 0) { + for (int w = 0; w < child2.getChildCount(); w++) { + AccessibilityNodeInfo childw = child2.getChild(w); + if (childw != null) { + if (childw.getText() != null) { + if (!childw.getText().toString().equals("互相关注")) { + continue; + } + } + + AblViewUtil.mySleep(1); + if (childw.getText() != null) { + if (childw.getText().toString().equals("互相关注")) { + clickcommontwo(childw, "互相关注"); + AblViewUtil.mySleep(2); + AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 1); + clickcommontwo(quxiao, "取消关注"); + + } + } + } } - String s3 = oneInfos.get(3).getText().toString(); - if (s3.contains(IFCONTIAN)) { - String substring = s3.substring(1); - liwusubstring = Integer.valueOf(substring); - Log.e("TIAOSHI###", "----礼物个数=:" + substring); - } - liwuBean.setLiwuNum(liwusubstring+""); - String liwuDanjia = liwuBean.getLiwuDanjia(); - int danjia = Integer.valueOf(liwuDanjia); - liwuBean.setLiwuDoubi(liwusubstring*danjia+""); - liwuBeans.add(liwuBean); } } - } diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep2.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep2.java index 386b3b9..b1f67ed 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep2.java +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep2.java @@ -210,16 +210,18 @@ public class TestAblStep2 extends BaseAblStep { AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("android.widget.TextView".equals(child.getClassName())) { - if(child.getText()!=null) { - if (child.getText().toString().contains("正在尝试开启") || child.getText().toString().contains("是否允许")) { - int childCount = root.getChildCount(); - AccessibilityNodeInfo child1 = root.getChild(childCount - 1); - clickNodeInfo(child1, "点击了允许"); + if(child!=null) { + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + if ("android.widget.TextView".equals(child.getClassName())) { + if (child.getText() != null) { + if (child.getText().toString().contains("正在尝试开启") || child.getText().toString().contains("是否允许")) { + int childCount = root.getChildCount(); + AccessibilityNodeInfo child1 = root.getChild(childCount - 1); + clickNodeInfo(child1, "点击了允许"); + } } + ifOpen = true; } - ifOpen = true; } } return ifOpen; diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep21.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep21.java deleted file mode 100644 index aa9c486..0000000 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep21.java +++ /dev/null @@ -1,360 +0,0 @@ -package com.fisherbone.fuzhu.step; - -import android.accessibilityservice.AccessibilityService; -import android.accessibilityservice.GestureDescription; -import android.graphics.Path; -import android.graphics.Rect; -import android.os.Build; -import android.os.Message; -import android.util.Log; -import android.view.accessibility.AccessibilityNodeInfo; - -import androidx.annotation.RequiresApi; - -import com.blankj.utilcode.util.ToastUtils; -import com.fisherbone.fuzhu.ChangLiang; -import com.fisherbone.fuzhu.abllib.AblService; -import com.fisherbone.fuzhu.abllib.AblStepHandler; -import com.fisherbone.fuzhu.abllib.AblSteps; -import com.fisherbone.fuzhu.abllib.BaseAblStep; -import com.fisherbone.fuzhu.abllib.RandumInt; -import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; - -import java.util.List; - -/** - * @param - * @description 一键取关(取消已关注+取消互相关注) - * @return - */ -public class TestAblStep21 extends BaseAblStep { - private String substring;//当前的关注数 - private int numb;//阈值 - private String guanzhunum; - private AccessibilityNodeInfo child3; - - - @Override - public void onStep(int step, Message msg) { - - // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); - switch (step) { - case AblSteps.STEP_60: - AblViewUtil.startApplication(); - AblViewUtil.mySleep(8); - AblStepHandler.sendMsg(AblSteps.STEP_61); - break; - case AblSteps.STEP_61: - ChangLiang.ishuodong = "T"; - AblViewUtil.mySleep(5); - AblService instance = AblService.getInstance(); - //1.关闭广告 - //2.关闭青少年弹窗 - //3.点击我的 - myClick(); - AblViewUtil.mySleep(2); - //获取关注数(对比关注数是否满足预设的取关值;)若不满足,则直接结束任务,若满足,则点击【关注】,进入关注页; - getargone(); - AblViewUtil.mySleep(1); - if (guanzhunum==null) { - Log.e("TIAOSHI###", "关注数==null结束任务"); - ToastUtils.showShort("关注数==null结束任务"); - AblStepHandler.getInstance().setStop(true); - // AblViewUtil.onMessage("停止"); - return; - } - Log.e("TIAOSHI###", "获得的关注数==" + guanzhunum); - if(guanzhunum!=null) { - int num = Integer.parseInt(guanzhunum.toString()); - Log.e("TIAOSHI###", "关注数" + num); - numb = Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber); - if (num <= Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber)) { - Log.e("TIAOSHI###", "关注数小于等于设定的取关数结束任务"); - ToastUtils.showLong("关注数小于等于设定的取关数结束任务"); - AblStepHandler.getInstance().setStop(true); - AblViewUtil.onMessage("停止"); - return; - } - //点击进入用户关注页 - AblViewUtil.mySleep(2); - // AblService.getInstance().clickcommontwo(child, "进入用户关注页"); - AblService.getInstance().clickcommontwo(child3, "进入用户关注页"); - AblStepHandler.sendMsg(AblSteps.STEP_62); - } - break; - case AblSteps.STEP_62: - //寻找到第一条互相关注的进入个人信息页面 - //AblViewUtil.mySleep(1); - int num2 = Integer.parseInt(getNum()); - if (num2 > numb) { - // AblViewUtil.mySleep(1); - cancelGuanzhu(AblService.getInstance()); - } else { - ChangLiang.ishuodong = "F"; - AblViewUtil.back(); - } - break; - case AblSteps.STEP_63: - //获取一屏幕数据:快照 - AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); - List idsj = roott.findAccessibilityNodeInfosByText("查找好友并关注"); - if (idsj.size() > 0) { - AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); - CharSequence text1 = accessibilityNodeInfo.getText(); - if (text1.equals("查找好友并关注")) { - ChangLiang.ishuodong = "F"; - AblViewUtil.back(); - } - } - if (ChangLiang.ishuodong.equals("T")) { - AblViewUtil.mySleep(1); - // randomSwipe(); - AccessibilityNodeInfo chilrecy = getrecy(); - chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 - AblViewUtil.mySleep(3); - AblStepHandler.sendMsg(AblSteps.STEP_62); - } - break; - default: - } - } - - - private AccessibilityNodeInfo getrecy() { - AccessibilityNodeInfo chilrecy = null; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { - AccessibilityNodeInfo child1 = child.getChild(1); - Rect rect = new Rect(); - child1.getBoundsInScreen(rect); - Log.e("TIAOSHI###", "----fourNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { - chilrecy=child1; - } - } - } - return chilrecy; - } - - private void cancelGuanzhu(AblService instance) { - // 取消已关: - // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; - AblViewUtil.mySleep(2); - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - //遍历root下的子节点有哪些 - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { - Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); - AccessibilityNodeInfo child1 = child.getChild(1); - // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { - for (int x = 0; x < child1.getChildCount(); x++) { - AccessibilityNodeInfo child2 = child1.getChild(x); - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - if (child2.getChildCount() != 0) { - for (int w = 0; w < child2.getChildCount(); w++) { - AccessibilityNodeInfo childw = child2.getChild(w); - if(childw!=null) { - if (childw.getText().equals("已关注")) { - AblViewUtil.mySleep(2); - if (childw.getText() != null) { - if (childw.getText().toString().equals("已关注")) { - clickcommontwo(childw, "已关注"); - } - } - } - if (childw.getText().equals("互相关注")) { - AblViewUtil.mySleep(2); - if (childw.getText() != null) { - if (childw.getText().toString().equals("互相关注")) { - clickcommontwo(child2, "进入互相关注"); - AblViewUtil.mySleep(2); - //点击取消关注 - AccessibilityNodeInfo getquxiaoguanzhu = getquxiaoguanzhu(); - AblService.getInstance().clickcommontwo(getquxiaoguanzhu, "点击互相关注"); - AblViewUtil.mySleep(2); - //点击取消关注 - AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 1); - AblService.getInstance().clickcommonthree(quxiao, "取消关注"); - AblViewUtil.mySleep(2); - AblViewUtil.back(); - } - } - } - } - } - } - } - } - } - } - - //向上滑动 - AblViewUtil.mySleep(2); - AblStepHandler.sendMsg(AblSteps.STEP_63); - } - /** - * 获得取消关注 - */ - private AccessibilityNodeInfo getquxiaoguanzhu() { - AccessibilityNodeInfo nodeinfo = null; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { - if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { - // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - if ("android.widget.TextView".equals(child1.getClassName())) { - CharSequence text = child1.getText(); - if (text != null) { - if (text.toString().contains("互相关注")) { - nodeinfo=child1; - } - } - } - } - } - } - return nodeinfo; - } - - - /** - * 获得当前的关注数 - * - * @return - */ - private String getNum() { - //获取关注数 - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - //遍历root下的子节点有哪些 - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { - Log.e("TIAOSHI###HorizontalScrollView", "----twoNode:" + child.getChildCount()); - for (int j = 0; j < child.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child.getChild(j); - Log.e("TIAOSHI###", "----twoNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - } - AccessibilityNodeInfo child1 = child.getChild(0); - if ("androidx.appcompat.app.ActionBar$Tab".equals(child1.getClassName())) { - for (int x = 0; x < child1.getChildCount(); x++) { - AccessibilityNodeInfo child2 = child1.getChild(x); - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - String s = child2.getText().toString(); - Log.e("TIAOSHI###", s + "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - substring = s.substring(3); - Log.e("TIAOSHI###", "----关注数:" + substring); - } - } - } - } - return substring; - } - - - @RequiresApi(api = Build.VERSION_CODES.N) - public void randomSwipe() { - if (ChangLiang.phonetype.equals("0")) { - int a = 170 + RandumInt.getRandumInt4() * 8; - int b = 170 - RandumInt.getRandumInt4() * 10; - int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 - int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 - // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 - swipe(a, c, b, d, 320); //延迟330毫秒 - } else { - int a = 500 + RandumInt.getRandumInt4() * 8; - int b = 500 - RandumInt.getRandumInt4() * 10; - int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 - int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 - // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 - swipe(a, c, b, d, 420); //延迟330毫秒 - } - } - - - @RequiresApi(api = Build.VERSION_CODES.N) - public void swipe(float x1, float y1, float x2, float y2, long duration) { - Path path = new Path(); - path.moveTo(x1, y1); - path.lineTo(x2, y2); - - Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); - GestureDescription.Builder builder = new GestureDescription.Builder(); - GestureDescription gestureDescription = builder - .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) - .build(); - boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { - @Override - public void onCompleted(GestureDescription gestureDescription) { - super.onCompleted(gestureDescription); - Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); - - } - - @Override - public void onCancelled(GestureDescription gestureDescription) { - super.onCancelled(gestureDescription); - Log.e("TIAOSHI###", "滑动取消"); - } - }, null); - } - - - /** - * 获得关注数 - */ - private void getargone() { - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { - if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { - Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - // if ("android.widget.LinearLayout".equals(child1.getClassName())) { - for (int j = 0; j < child1.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child1.getChild(j); - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); - - for (int x = 0; x < child2.getChildCount(); x++) { - AccessibilityNodeInfo child4 = child2.getChild(x); - Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); - for (int z = 0; z < child4.getChildCount(); z++) { - AccessibilityNodeInfo child5 = child4.getChild(z); - Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); - if (child5.getText() != null) { - if (child5.getText().equals("关注")) { - AccessibilityNodeInfo parent = child5.getParent(); - child3 = parent.getChild(0); - Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); - guanzhunum = child3.getText().toString(); - if (child3.getText().toString().equals("-")) { - Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); - } - return; - } - - } - } - } - } - } - } - } - } -} - diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java deleted file mode 100644 index 063b36e..0000000 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep31bei.java +++ /dev/null @@ -1,923 +0,0 @@ -package com.fisherbone.fuzhu.step; - -import android.graphics.Rect; -import android.os.Build; -import android.os.Message; -import android.text.TextUtils; -import android.util.Log; -import android.view.accessibility.AccessibilityNodeInfo; - -import androidx.annotation.RequiresApi; - -import com.fisherbone.fuzhu.ChangLiang; -import com.fisherbone.fuzhu.abllib.AblService; -import com.fisherbone.fuzhu.abllib.AblStepHandler; -import com.fisherbone.fuzhu.abllib.AblSteps; -import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; -import com.fisherbone.fuzhu.entity.LiveSuiJiBean; -import com.fisherbone.fuzhu.utils.ProfileSpUtils; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import io.reactivex.Flowable; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.Disposable; -import io.reactivex.functions.Action; -import io.reactivex.functions.Consumer; - -/** - * @author keriezhang - * @description 随机直播间抢福袋 - * @return - */ -public class TestAblStep31bei extends HongbaoBase { - private List jiluBeans; - private List hongbaos; - private List times; - private int num3; - private boolean noqinmidu=true; - - @Override - public void onStep(int step, Message msg) { - - switch (step) { - case AblSteps.STEP_221: - AblViewUtil.startApplication(); - jiluBeans = new ArrayList<>(); - AblViewUtil.mySleep(3); - allowed(); - AblViewUtil.mySleep(5); - if(ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchfive()) { - //点击直播1080 - AblService.getInstance().clickPoint(90, 163, 300); - AblViewUtil.mySleep(3); - AblStepHandler.sendMsg(AblSteps.STEP_222); - } - if(ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchsix()) { - // - enfirstLive(); - } - - break; - case AblSteps.STEP_222: - Log.e("TIAOSHI###", "福袋测试STEP_222"); - AblViewUtil.mySleep(2); - //直播间的人数判断,不满足条件直接滑走 - String minnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMinnum(); - int conminnum = Integer.valueOf(minnum); - String maxnum = ProfileSpUtils.getInstance().getLiveSuiJiBean().getMaxnum(); - int conmaxnum = Integer.valueOf(maxnum); - //获取直播间人数 -// int personNum = getPersonNum(); -// AblViewUtil.mySleep(1); -// if(personNum<=conminnum||personNum>=conmaxnum){ -// huodong(); -// Log.e("TIAOSHI###", personNum+"直播间人数没有达到条件"+ChangLiang.phonetype); -// return; -// } - AblStepHandler.sendMsg(AblSteps.STEP_223); - break; - case AblSteps.STEP_223: - Log.e("TIAOSHI###", "福袋测试STEP_223"); - AblViewUtil.mySleep(2); - if (ifControlView()) { - AblViewUtil.mySleep(2); - kongjiandingweitwo(); - boolean shifouyoufudai = shifouyoufudai(); - Log.e("TIAOSHI###", "是否有福袋控件" + shifouyoufudai); - if (!shifouyoufudai) { - Log.e("TIAOSHI###", "页面布局发生变化,此位置上没有福袋控件"); - huodong(); - } - } else { - Log.e("TIAOSHI###", "页面上没有控件,滑走"); - huodong(); - } - break; - case AblSteps.STEP_224: - //直播间点赞 - Boolean switchtwo = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchtwo(); - if(switchtwo) { - zhibodianzan(50); - } - AblStepHandler.sendMsg(AblSteps.STEP_225); - break; - case AblSteps.STEP_225: - AblViewUtil.mySleep(5); - Boolean switchone = ProfileSpUtils.getInstance().getLiveSuiJiBean().getSwitchone(); - if(switchone) { - String conment = getConment(); - fasongpingluntwo(conment); - } - AblStepHandler.sendMsg(AblSteps.STEP_226); - break; - default: - } - } - - - /** - * 定位结果中是否有红包 - */ - public boolean shifouyoufudai() { - boolean flag = false; - for (int i = 0; i < jiluBeans.size(); i++) { - String s = jiluBeans.get(i); - if ("福袋".equals(s)) { - flag = true; - break; - } - } - return flag; - } - - /** - * 向上滑动 - */ - private void huodong() { - AblService.getInstance().randomSwipetwo(); - AblViewUtil.mySleep(3); - AblStepHandler.sendMsg(AblSteps.STEP_222); - } - - /** - * 控件定位 - */ - public void kongjiandingweitwo() { - jiluBeans.clear(); - for (int j = 0; j < accessibilityNodeInfos.size(); j++) { - AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); - if (child2 != null) { - clickNodeInfo(child2, ""); - Log.e("TIAOSHI###", "点击控件" + j); - Rect rect = new Rect(); - child2.getBoundsInScreen(rect); - Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - } - AblViewUtil.mySleep(2); - int pagetype = pagetype(); - if (pagetype == 1) { - AblViewUtil.mySleep(1); - AblService.getInstance().clickPoint(540, 1663, 300); - AblViewUtil.mySleep(1); - int pagetype1 = pagetype(); - if (pagetype1 == 1) { - Log.e("TIAOSHI###", "第一次点击没有关掉"); - AblViewUtil.mySleep(1); - Log.e("TIAOSHI###", "再次点击关闭按钮"); - AblViewUtil.back(); - AblViewUtil.mySleep(1); - } else { - Log.e("TIAOSHI###", "优惠卷弹框关闭了"); - } - } else if (pagetype == 2) { - jiluBeans.add("福袋"); - boolean enterfensituan = enterfensituan(); - if (enterfensituan&&!ChangLiang.fudaineirong.equals("助力主播心愿")) { - AblViewUtil.mySleep(1); - //开始计时间 - taskdaojishi(num3 + 10); - getdodsfsdfdsuyin(); - } else { - Log.e("TIAOSHI###", "不满足抢福袋的条件----"); - AblViewUtil.back(); - AblViewUtil.mySleep(1); - huodong(); - } - break; - } else if (pagetype == 21) { - jiluBeans.add("红包"); - AblViewUtil.mySleep(1); -// AblService.getInstance().clickPoint(100, 100, 300); -// AblViewUtil.mySleep(1); - - boolean getdoubi = getdoubi(); - if (getdoubi) { - getNodeInQiangtwo(); - } else { - Log.e("TIAOSHI###", "----抖币数不够条件"); - } - } else if (pagetype == 4) { - AblViewUtil.mySleep(2); - AblService.getInstance().clickPoint(100, 100, 300); - AblViewUtil.mySleep(1); - } else { - jiluBeans.add("红包"); - AblViewUtil.mySleep(1); - AblService.getInstance().clickPoint(100, 100, 300); - AblViewUtil.mySleep(1); - } - } - } - /** - * 参与抢福袋 - */ - private AccessibilityNodeInfo canyuqiangfeidai() { - AccessibilityNodeInfo kongjian = null; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - if ("android.widget.HorizontalScrollView".equals(child1.getClassName())) { - kongjian = child1; - } - } - } - return kongjian; - } - - /** - * 获得红包的位置 - * - * @return - */ - private int hongbaoweizhi() { - int position = 0; - for (int i = 0; i < hongbaos.size(); i++) { - String s = hongbaos.get(i); - if ("红包".equals(s)) { - position = i; - break; - } - } - return position; - } - - /** - * 获得福袋的位置 - * - * @return - */ - private int fudaiposition() { - int position = 0; - for (int i = 0; i < hongbaos.size(); i++) { - String s = hongbaos.get(i); - if ("福袋".equals(s)) { - position = i; - break; - } - } - return position; - } - - /** - * 获取参与抢福袋的条件值 - * - * @return - */ - private boolean enterfensituan() { - /** - * 条件 - */ - boolean conditions = false; - /** - * 是否满足时间条件 - */ - boolean timeconditions = false; - /** - * 是否中奖概率 - */ - boolean winningpro = false; - noqinmidu=true; - /** - * 中奖的概率 - */ - int baifenshu = 0; - double fudainum = 0; - double renshunum = 1; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - for (int j = 0; j < child1.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child1.getChild(j); - for (int x = 0; x < child2.getChildCount(); x++) { - AccessibilityNodeInfo child3 = child2.getChild(x); - for (int r = 0; r < child3.getChildCount(); r++) { - AccessibilityNodeInfo child4 = child3.getChild(r); - for (int m = 0; m < child4.getChildCount(); m++) { - AccessibilityNodeInfo child5 = child4.getChild(m); - for (int p = 0; p < child5.getChildCount(); p++) { - AccessibilityNodeInfo child6 = child5.getChild(p); - for (int t = 0; t < child6.getChildCount(); t++) { - AccessibilityNodeInfo child7 = child6.getChild(t); - // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); - for (int u = 0; u < child7.getChildCount(); u++) { - AccessibilityNodeInfo child8 = child7.getChild(u); - Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); - nodeZuobiao(child8); - Rect rect = new Rect(); - child8.getBoundsInScreen(rect); - Log.e("TIAOSHI###", "----9Node:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - - if(SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)){ - if (rect.top >= 1351 && rect.bottom <= 1459 && rect.left >= 91 && rect.right <= 273) { - if ("android.view.View".equals(child8.getClassName())) { - String time = child8.getText().toString(); - Log.e("TIAOSHI###", "----获取的时间" + time); - if (!TextUtils.isEmpty(time)) { - String[] buff = time.split(":"); - int num1 = Integer.valueOf(buff[0]); - int num2 = Integer.valueOf(buff[1]); - num3 = num1 * 60 + num2; - Log.e("TIAOSHI###", "获得倒计时的秒数是----" + num3); - timeconditions = isfuhe(num3); - if (!isfuhe(num3)) { - Log.e("TIAOSHI###", "倒计时不在设置的参数范围内,直接滑走"); - } - } - } - } - if (rect.top >= 1354 && rect.bottom <= 1442 && rect.left >= 540) { - if ("android.view.View".equals(child8.getClassName())) { - String text = child8.getText().toString(); - if (!TextUtils.isEmpty(text)) { - // Log.e("TIAOSHI###", "----获取的内容:" + text); - if (text.contains("总") || text.contains("抖币")) { - } else { - Log.e("TIAOSHI###", "----获取的总抖币数量:" + text); - } - } - } - } - if (rect.top >= 1453 && rect.bottom <= 1497 && rect.left >= 540 && rect.right <= 784) { - if ("android.view.View".equals(child8.getClassName())) { - String text = child8.getText().toString(); - String[] all = child8.getText().toString().split("个"); - fudainum = Integer.valueOf(all[0]); - if (!TextUtils.isEmpty(text)) { - Log.e("TIAOSHI###", "----获取的福袋个数:" + all[0]); - } - } - } - if (rect.top >= 1453 && rect.bottom <= 1497 && rect.left >= 787 && rect.right <= 1000) { - if ("android.view.View".equals(child8.getClassName())) { - String text = child8.getText().toString(); - String[] all = child8.getText().toString().split("人"); - renshunum = Integer.valueOf(all[0]); - if (!TextUtils.isEmpty(text)) { - Log.e("TIAOSHI###", "----获取的参与人数:" + all[0]); - } - } - } - //获得发表的评论内容(60,1350),(288,1388) - if (rect.top >= 1758 && rect.bottom <= 1816 && rect.left >= 91 && rect.right <= 872) { - if ("android.view.View".equals(child8.getClassName())) { - String text = child8.getText().toString(); - if (!TextUtils.isEmpty(text)) { - String[] buff = text.split(":"); - String sdfsd = buff[buff.length - 1]; - Log.e("TIAOSHI###", "获取的评论内容----:" + sdfsd); - ChangLiang.fudaineirong = sdfsd; - } - } - } - } - for (int q = 0; q < child8.getChildCount(); q++) { - AccessibilityNodeInfo child9 = child8.getChild( q); - Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); - nodeZuobiao(child9); - if ("android.view.View".equals(child9.getClassName())) { - String text = child9.getText().toString(); - if (!TextUtils.isEmpty(text)) { - if ("提升亲密度".equals(text)) { - noqinmidu=false; - break; - } - if ("加入粉丝团(1抖币)".equals(text)) { - noqinmidu=true; - break; - } - if ("去发表评论".equals(text)) { - noqinmidu=true; - break; - } - if ("助力主播心愿".equals(text)) { - noqinmidu=false; - break; - } - } - } - } - } - } - } - } - } - } - } - } - } - Double baifenshuu = (int) fudainum / renshunum * 100; - baifenshu = baifenshuu.intValue(); - Log.e("TIAOSHI###", "抢福袋的抢种概率==" + baifenshu); - String winningrate = ProfileSpUtils.getInstance().getLiveSuiJiBean().getWinningrate(); - int winningratevalue = Integer.valueOf(winningrate); - if (baifenshu >= winningratevalue) { - winningpro = true; - }else { - Log.e("TIAOSHI###", "抢福袋的抢种概率<=参数值:"+winningratevalue); - } -// if(!noqinmidu){ -// Log.e("TIAOSHI###", "点开福袋后含有提升亲密度和加团1抖币"); -// noqinmidu=false; -// } - Log.e("TIAOSHI###", "timeconditions=="+timeconditions); - Log.e("TIAOSHI###", "winningpro=="+winningpro); - Log.e("TIAOSHI###", "noqinmidu=="+noqinmidu); - if (timeconditions && winningpro&&noqinmidu) { - conditions = true; - } - return conditions; - } - - - /** - * 判断福袋的时间是否在设置范围内 - * - * @param substring - * @return - */ - public boolean isfuhe(int substring) { - LiveSuiJiBean liveSuiJiBean = ProfileSpUtils.getInstance().getLiveSuiJiBean(); - int minute = Integer.valueOf(liveSuiJiBean.getMinute()) * 60; - int minutetwo = Integer.valueOf(liveSuiJiBean.getMinutetwo()) * 60; - if (substring <= minute && substring >= minutetwo) { - Log.e("TIAOSHI###", "倒计时在设置的参数范围内=="+minutetwo+"->"+minute); - return true; - } else { - Log.e("TIAOSHI###", "倒计时不在设置的参数范围内,直接滑走" + "==" + minute + "=====" + minutetwo); - return false; - } - } - - private void getdodsfsdfdsuyin() { - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - for (int j = 0; j < child1.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child1.getChild(j); - // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child1.getContentDescription()); - for (int x = 0; x < child2.getChildCount(); x++) { - AccessibilityNodeInfo child3 = child2.getChild(x); - // Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child1.getContentDescription()); - for (int r = 0; r < child3.getChildCount(); r++) { - AccessibilityNodeInfo child4 = child3.getChild(r); - // Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText() + ":" + child4.getContentDescription()); - for (int m = 0; m < child4.getChildCount(); m++) { - AccessibilityNodeInfo child5 = child4.getChild(m); - // Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText() + ":" + child5.getContentDescription()); - for (int p = 0; p < child5.getChildCount(); p++) { - AccessibilityNodeInfo child6 = child5.getChild(p); - // Log.e("TIAOSHI###", "----7Node:" + child6.getClassName() + ":" + child6.getText() + ":" + child6.getContentDescription()); - for (int t = 0; t < child6.getChildCount(); t++) { - AccessibilityNodeInfo child7 = child6.getChild(t); - // Log.e("TIAOSHI###", "----8Node:" + child7.getClassName() + ":" + child7.getText() + ":" + child7.getContentDescription()); - for (int u = 0; u < child7.getChildCount(); u++) { - AccessibilityNodeInfo child8 = child7.getChild(u); - // Log.e("TIAOSHI###", "----9Node:" + child8.getClassName() + ":" + child8.getText() + ":" + child8.getContentDescription()); - for (int q = 0; q < child8.getChildCount(); q++) { - AccessibilityNodeInfo child9 = child8.getChild( q); - Log.e("TIAOSHI###", "----10Node:" + child9.getClassName() + ":" + child9.getText() + ":" + child9.getContentDescription()); - nodeZuobiao(child9); - if ("android.view.View".equals(child9.getClassName())) { - String text = child9.getText().toString(); - if (!TextUtils.isEmpty(text)) { - if ("加入粉丝团(1抖币)".equals(text)) { - AblViewUtil.mySleep(2); - //点击加入粉丝团 - clickcommonthree(child9, "了加入粉丝团"); - AblViewUtil.mySleep(2); - closedzfDialog(AblService.getInstance()); - AblViewUtil.mySleep(3); - clickcommonthree(child9, "去发表评论"); - AblViewUtil.mySleep(2); - //去发表评论 - //直播间发送评论 - fasongpinglun(ChangLiang.fudaineirong); - break; - } else if ("去发表评论".equals(text)) { - AblViewUtil.mySleep(2); - clickcommonthree(child9, "去发表评论"); - AblViewUtil.mySleep(2); - //去发表评论 - //直播间发送评论 - fasongpinglun(ChangLiang.fudaineirong); - break; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - - private void fasongpinglun(String conment) { - //直播间话术 - AblViewUtil.mySleep(2); - AblViewUtil.mySleep(1); - AccessibilityNodeInfo geouyintdd = geouyintdd(); - AblService.getInstance().clickcommontwo(geouyintdd, "点击发送评论"); - AblViewUtil.mySleep(2); - AblStepHandler.sendMsg(AblSteps.STEP_224); - - } - - /** - * 参与抢福袋的结束计时 - * - * @param a - */ - public void taskdaojishi(final int a) { - //启动计时器 - //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 - Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) - .observeOn(AndroidSchedulers.mainThread()) - .doOnNext(new Consumer() { - @Override - public void accept(Long aLong) throws Exception { - long b = a - aLong; - Log.e("TIAOSHI###", b + ""); - if(b==30){ - //打开福袋 - if (ifControlView()) { - openFudai(); - } - } - } - }) - .doOnComplete(new Action() { - @Override - public void run() throws Exception { - //关闭结果弹框 - - AblService.getInstance().clickPoint(100, 100, 300); - // closedjieguo(); - //继续抢福袋 - AblStepHandler.sendMsg(AblSteps.STEP_222); - - } - }) - .subscribe(); - } - - private void openFudai(){ - for (int j = 0; j < accessibilityNodeInfos.size(); j++) { - AccessibilityNodeInfo child2 = accessibilityNodeInfos.get(j); - if (child2 != null) { - clickNodeInfo(child2, ""); - Log.e("TIAOSHI###", "点击控件" + j); - Rect rect = new Rect(); - child2.getBoundsInScreen(rect); - Log.e("TIAOSHI###", "----显示控件点击的控件坐标:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - } - AblViewUtil.mySleep(2); - int pagetype = pagetype(); - if (pagetype == 1) { - Log.e("TIAOSHI###","福袋测试1"); - AblViewUtil.mySleep(1); - AblService.getInstance().clickPoint(540, 1663, 300); - AblViewUtil.mySleep(1); - int pagetype1 = pagetype(); - if (pagetype1 == 1) { - Log.e("TIAOSHI###", "第一次点击没有关掉"); - AblViewUtil.mySleep(1); - Log.e("TIAOSHI###", "再次点击关闭按钮"); - AblViewUtil.back(); - AblViewUtil.mySleep(1); - } else { - Log.e("TIAOSHI###", "优惠卷弹框关闭了"); - } - } else if (pagetype == 2) { - break; - } else if (pagetype == 21) { - AblViewUtil.mySleep(1); - AblService.getInstance().clickPoint(100, 100, 300); - AblViewUtil.mySleep(1); - - } else if (pagetype == 4) { - AblViewUtil.mySleep(2); - AblService.getInstance().clickPoint(100, 100, 300); - AblViewUtil.mySleep(1); - } else { - AblViewUtil.mySleep(1); - AblService.getInstance().clickPoint(100, 100, 300); - AblViewUtil.mySleep(1); - } - } - } - - @RequiresApi(api = Build.VERSION_CODES.N) - public void clickcommonthree(AccessibilityNodeInfo accessibilityNodeInfo, String s) { - if (accessibilityNodeInfo != null) { - Rect rect = new Rect(); - accessibilityNodeInfo.getBoundsInScreen(rect); - AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); - Log.e("TIAOSHI###", "点击" + s + "按钮"); - Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); - } else { - Log.e("TIAOSHI###", "没有找到" + s + "按钮"); - } - } - - - - /** - * 获得直播间人数 - */ - public int getPersonNum() { - int personnum = 0; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - for (int j = 0; j < child1.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child1.getChild(j); -// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); -// nodeZuobiao(child2); - Rect rect = new Rect(); - child2.getBoundsInScreen(rect); - // Log.e("TIAOSHI###", "----threeNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - //红米7A(560,77),(632,137) 畅想20(560,70),(632,130) 红米9(860,129),(959,212) - if (SHEBEITIPE_VILUEONE.equals(ChangLiang.phonetype)) { - if (rect.left > 360 && rect.top >= 77 && rect.bottom <= 137) { - if ("android.widget.Button".equals(child2.getClassName())) { - String person = child2.getText().toString(); - Log.e("TIAOSHI###", "----获取的直播间人数:" + person); - if (person.contains("万")) { - String substring = person.substring(0, person.indexOf("万")); - double personmun = Double.parseDouble(substring) * 10000; - personnum = new Double(personmun).intValue(); - Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); - } else { - personnum = Integer.valueOf(person); - } - break; - } - } - } else if (SHEBEITIPE_VILUETHREE.equals(ChangLiang.phonetype)) { - if (rect.left > 540 && rect.top >= 129 && rect.bottom <= 212) { - if ("android.widget.Button".equals(child2.getClassName())) { - String person = child2.getText().toString(); - Log.e("TIAOSHI###", "----获取的直播间人数:" + person); - if (person.contains("万")) { - String substring = person.substring(0, person.indexOf("万")); - double personmun = Double.parseDouble(substring) * 10000; - personnum = new Double(personmun).intValue(); - Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); - } else { - personnum = Integer.valueOf(person); - } - break; - } - } - } else { - // 16.5版本(561,69),(633,129) 14.6版本(560,70),(632,130) - if (rect.left > 360 && rect.top >= 68 && rect.bottom <= 130) { - if ("android.widget.Button".equals(child2.getClassName())) { - String person = child2.getText().toString(); - Log.e("TIAOSHI###", "----获取的直播间人数:" + person); - if (person.contains("万")) { - String substring = person.substring(0, person.indexOf("万")); - double personmun = Double.parseDouble(substring) * 10000; - personnum = new Double(personmun).intValue(); - Log.e("TIAOSHI###", "----获取的直播间人数:" + personnum); - } else { - personnum = Integer.valueOf(person); - } - break; - } - } - } - } - } - } - return personnum; - } - private void enfirstLive(){ -// livePosition = 0; -// slidingDir = true; - AblViewUtil.mySleep(2); - boolean b12 = enterLive(); - if (b12) { - runLog("成功进入第一个直播间"); - AblStepHandler.sendMsg(AblSteps.STEP_222); - } else { - // runLog("进入第一个直播间失败"); - AblViewUtil.mySleep(2); - boolean b2 = enterLivetwo(); - if (b2) { - runLog("成功进入第一个直播间"); - AblStepHandler.sendMsg(AblSteps.STEP_222); - } else { - // runLog("进入第一个直播间失败"); - AblViewUtil.mySleep(2); - boolean b3 = enterLivetwo(); - if (b3) { - runLog("成功进入第一个直播间"); - AblStepHandler.sendMsg(AblSteps.STEP_222); - } else { - runLog("进入第一个直播间失败"); - } - } - } - } - - public boolean getdoubi() { - boolean flag = true; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - nodeZuobiao(child); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - nodeZuobiao(child1); - if (child1 != null) { - Rect rect = new Rect(); - child1.getBoundsInScreen(rect); - //(547,1437),(613,1510) - if (rect.top >= 1437 && rect.bottom <= 1510) { - if ("android.widget.TextView".equals(child1.getClassName())) { - String doubigeshu = child1.getText().toString(); - Log.e("TIAOSHI###", "----获取的抖币数:" + doubigeshu); - int doubi = Integer.valueOf(doubigeshu); - int doubic = Integer.valueOf(10); - Log.e("TIAOSHI###", "----获取的条件抖币数:" + doubic); - if (doubi > doubic) { - flag = true; - } else { - flag = false; - } - break; - } - } - } - } - } - return flag; - } - /** - * 获取抢的控件 - * ----oneNode:android.widget.TextView:200:null - * ----显示节点的坐标:(521,1342),(620,1416) - *

- * ----oneNode:android.widget.TextView:520:null - * ----显示节点的坐标:(565,1398),(624,1443) - */ - public void getNodeInQiangtwo() { - AccessibilityNodeInfo timechild = null; - boolean flag = false; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - nodeZuobiao(child); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - nodeZuobiao(child1); - Rect rect = new Rect(); - child1.getBoundsInScreen(rect); - if (rect.top >= 1192 && rect.bottom <= 1286) { - Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - timechild = child1; - flag = true; - } else { - Log.e("TIAOSHI###", "没有控件"); - } - } - } - if (flag) { - Log.e("TIAOSHI###", "红包有时间"); - qiangHongbao(timechild); - } else { - Log.e("TIAOSHI###", "红包没有时间"); - // (462,1192),(618,1286) - AblService.getInstance().clickPoint(540, 1239, 300); - AblViewUtil.mySleep(2); - AblViewUtil.back(); - AblStepHandler.sendMsg(AblSteps.STEP_254); - AblViewUtil.mySleep(1); - } - - } - - private void qiangHongbao(AccessibilityNodeInfo child1) { - String s = child1.getText().toString(); - int daojishimiao = daojishimiao(s); - String qiehuantime = "60"; - int qihuanshijian = Integer.valueOf(qiehuantime); - if (daojishimiao < qihuanshijian) { - Log.e("TIAOSHI###", "时间在" + qihuanshijian + "秒内"); - //等待抢红包 - hongbaojishi(daojishimiao - 2); - } else { - //更新时间 - Log.e("TIAOSHI###", "更新时间"); - AblViewUtil.mySleep(2); - int pagetype = pagetype(); - if (pagetype == 21 ) { - Log.e("TIAOSHI###", "有倒计时红包弹框,点击返回"); - AblViewUtil.back(); - } else { - Log.e("TIAOSHI###", "有红包倒计时,没有有红包弹框,不点击返回"); - } - //AblViewUtil.back(); - AblViewUtil.mySleep(1); - } - } - /** - * 停任务的倒计时 - * - * @param a - */ - public void hongbaojishi(final int a) { - - //启动计时器 - //从0开始发射11个数字为:0-10依次输出,延时0s执行,每1s发射一次。 - Disposable mdDisposable = Flowable.intervalRange(0, a + 1, 0, 1, TimeUnit.SECONDS) - .observeOn(AndroidSchedulers.mainThread()) - .doOnNext(new Consumer() { - @Override - public void accept(Long aLong) throws Exception { - long b = a - aLong; - Log.e("TIAOSHI###", b + ""); - } - }) - .doOnComplete(new Action() { - @Override - public void run() throws Exception { - AblStepHandler.getInstance().setStop(false); - Log.e("TIAOSHI###", "开始点击抢红包"); - zhibodianzanb(64); - AblViewUtil.mySleep(3); - int pagetype = pagetype(); - if (pagetype == 21) { - Log.e("TIAOSHI###", "有红包弹框,点击关闭"); - // AblViewUtil.back(); - AblService.getInstance().clickPoint(540, 1663, 300); - // (100,563),(980,1746) - } else { - Log.e("TIAOSHI###", "没有有红包弹框,不点击返回"); - } - AblViewUtil.mySleep(1); - int pagenum = pagetype(); - if (pagenum != 21) { - AblStepHandler.sendMsg(AblSteps.STEP_222); - } else { - Log.e("TIAOSHI###", "有红包弹框,再次点击关闭"); - AblService.getInstance().clickPoint(540, 1663, 300); - AblStepHandler.sendMsg(AblSteps.STEP_222); - } - AblViewUtil.mySleep(1); - } - }) - .subscribe(); - } - - - /** - * 计算红包的倒计时 - * - * @param str 红包控件的值 - * @return - */ - private int daojishimiao(String str) { - int daojishitiem = 0; - if (str.contains("可抢")) { - String[] str1 = str.split("秒"); - String str2 = str1[0]; - String[] str3 = str2.split("分"); - String str4 = str3[0]; - daojishitiem = Integer.valueOf(str4) * 60 + Integer.valueOf(str3[1]); - } else { - daojishitiem = Integer.valueOf(str); - } - Log.e("TIAOSHI###", "倒计时" + daojishitiem); - return daojishitiem; - } - - -} - - - diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep6.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep6.java index 1ca0cc7..dd56d25 100644 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep6.java +++ b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep6.java @@ -19,6 +19,7 @@ import com.fisherbone.fuzhu.abllib.AblSteps; import com.fisherbone.fuzhu.abllib.BaseAblStep; import com.fisherbone.fuzhu.abllib.RandumInt; import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; +import com.fisherbone.fuzhu.utils.ProfileSpUtils; import java.util.List; @@ -38,7 +39,6 @@ public class TestAblStep6 extends BaseAblStep { @Override public void onStep(int step, Message msg) { - // Log.e("TIAOSHI###==获得一键取关的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); switch (step) { case AblSteps.STEP_11: AblViewUtil.startApplication(); @@ -49,9 +49,6 @@ public class TestAblStep6 extends BaseAblStep { ChangLiang.ishuodong = "T"; AblViewUtil.mySleep(5); AblService instance = AblService.getInstance(); - //1.关闭广告 - //2.关闭青少年弹窗 - //3.点击我的 myClick(); AblViewUtil.mySleep(2); //获取关注数(对比关注数是否满足预设的取关值;)若不满足,则直接结束任务,若满足,则点击【关注】,进入关注页; @@ -81,7 +78,12 @@ public class TestAblStep6 extends BaseAblStep { AblStepHandler.sendMsg(AblSteps.STEP_13); break; case AblSteps.STEP_13: - int num2 = Integer.parseInt(getNum()); + String num1 = getNum(); + Log.e("TIAOSHI###", "获得的关注数==" + num1); + String[] all = num1.split(" "); + String num22 = all[1]; + Log.e("TIAOSHI###", "获得的关注数==" + num22); + int num2 = Integer.parseInt(num22); if (num2 > numb) { // AblViewUtil.mySleep(1); cancelGuanzhu(AblService.getInstance()); @@ -106,10 +108,10 @@ public class TestAblStep6 extends BaseAblStep { } if (ChangLiang.ishuodong.equals("T")) { AblViewUtil.mySleep(1); - // randomSwipe(); AccessibilityNodeInfo chilrecy = getrecy(); + Log.e("TIAOSHI###", "向上滑动"); chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 - AblViewUtil.mySleep(3); + AblViewUtil.mySleep(1); AblStepHandler.sendMsg(AblSteps.STEP_13); } break; @@ -122,14 +124,20 @@ public class TestAblStep6 extends BaseAblStep { AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { - AccessibilityNodeInfo child1 = child.getChild(1); - Rect rect = new Rect(); - child1.getBoundsInScreen(rect); - Log.e("TIAOSHI###", "----fourNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { - chilrecy=child1; +// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); +// nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); +// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); +// nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + nodeZuobiao(child2); + if ("androidx.recyclerview.widget.RecyclerView".equals(child2.getClassName())) { + chilrecy = child2; + break; + } } } } @@ -142,54 +150,63 @@ public class TestAblStep6 extends BaseAblStep { * @return */ private String getNum() { - //获取关注数 + String nikename = ""; AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - //遍历root下的子节点有哪些 - if (root != null) { - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { - Log.e("TIAOSHI###HorizontalScrollView", "----twoNode:" + child.getChildCount()); - for (int j = 0; j < child.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child.getChild(j); - Log.e("TIAOSHI###", "----twoNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - } - AccessibilityNodeInfo child1 = child.getChild(0); - if ("androidx.appcompat.app.ActionBar$Tab".equals(child1.getClassName())) { - for (int x = 0; x < child1.getChildCount(); x++) { - AccessibilityNodeInfo child2 = child1.getChild(x); - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - String s = child2.getText().toString(); - Log.e("TIAOSHI###", s + "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - substring = s.substring(3); - Log.e("TIAOSHI###", "----关注数:" + substring); - } + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + // nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + // nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); + Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); + nodeZuobiao(child2); + //fourNode:android.widget.TextView:关注 389:关注 389,按钮 + //显示节点的坐标:(208,253),(375,308) + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); + Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); + nodeZuobiao(child3); + nikename = AblViewUtil.getString(nikename, child3, 253, 308, 0, 540, "android.widget.TextView"); } } } } - return substring; + return nikename; } private void cancelGuanzhu(AblService instance) { - // 取消已关: - // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; - AblViewUtil.mySleep(2); AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - //遍历root下的子节点有哪些 for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { - Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); - AccessibilityNodeInfo child1 = child.getChild(1); - Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { - for (int x = 0; x < child1.getChildCount(); x++) { - AccessibilityNodeInfo child2 = child1.getChild(x); - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - yiguanzhu(child2); +// Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); +// nodeZuobiao(child); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); +// Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); +// nodeZuobiao(child1); + for (int j = 0; j < child1.getChildCount(); j++) { + AccessibilityNodeInfo child2 = child1.getChild(j); +// Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); +// nodeZuobiao(child2); + for (int x = 0; x < child2.getChildCount(); x++) { + AccessibilityNodeInfo child3 = child2.getChild(x); +// Log.e("TIAOSHI###", "----fourNode:" + child3.getClassName() + ":" + child3.getText() + ":" + child3.getContentDescription()); +// nodeZuobiao(child3); + for (int r = 0; r < child3.getChildCount(); r++) { + AccessibilityNodeInfo child4 = child3.getChild(r); +// Log.e("TIAOSHI###", "----5Node:" + child4.getClassName() + ":" + child4.getText()+ ":" + child4.getContentDescription()); +// nodeZuobiao(child4); + for (int m = 0; m < child4.getChildCount(); m++) { + AccessibilityNodeInfo child5 = child4.getChild(m); + // Log.e("TIAOSHI###", "----6Node:" + child5.getClassName() + ":" + child5.getText()+ ":" + child5.getContentDescription()); + nodeZuobiao(child5); + yiguanzhu(child5); + } + } } } } @@ -198,36 +215,86 @@ public class TestAblStep6 extends BaseAblStep { // 3.遍历info中的子节点 (优化方法,正在测试) public void yiguanzhu(AccessibilityNodeInfo child2) { - if (child2.getChildCount() != 0) { - for (int i = 0; i < child2.getChildCount(); i++) { - AccessibilityNodeInfo child = child2.getChild(i); - if (child.getText() != null) { - if (!child.getText().toString().equals("已关注")) { - continue; + boolean cancelclosed = ProfileSpUtils.getInstance().getCan().getCancelclosed(); + boolean cancelcrosscor = ProfileSpUtils.getInstance().getCan().getCancelcrosscor(); + if (cancelclosed&&!cancelcrosscor) { + Log.e("TIAOSHI###", "QQQQQQQQQQQQQQQQQQ"); + if (child2.getChildCount() != 0) { + for (int i = 0; i < child2.getChildCount(); i++) { + AccessibilityNodeInfo child = child2.getChild(i); + if (child.getText() != null) { + if (!child.getText().toString().equals("已关注")) { + continue; + } + } + + try { + Thread.sleep(300); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (child.getText() != null) { + if (child.getText().toString().equals("已关注")) { + clickcommontwo(child, "已关注"); + } } } - - AblViewUtil.mySleep(1); - if (child.getText() != null) { - if (child.getText().toString().equals("已关注")) { - clickcommontwo(child, "已关注"); - } - } - } } - } - public void clickcommontwo(AccessibilityNodeInfo accessibilityNodeInfo, String s) { - if (accessibilityNodeInfo != null) { - Rect rect = new Rect(); - accessibilityNodeInfo.getBoundsInScreen(rect); - AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); - Log.e("TIAOSHI###", "点击" + s + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); - } else { - Log.e("TIAOSHI###", "没有找到" + s + "按钮,直接退出了。。。。"); - AblViewUtil.mySleep(2); - AblStepHandler.sendMsg(AblSteps.STEP_14); + if (cancelcrosscor&&!cancelclosed) { + Log.e("TIAOSHI###", "VVVVVVVVVVVVVVVVVVVVVV"); + if (child2.getChildCount() != 0) { + for (int w = 0; w < child2.getChildCount(); w++) { + AccessibilityNodeInfo childw = child2.getChild(w); + if (childw != null) { + if (childw.getText() != null) { + if (!childw.getText().toString().equals("互相关注")) { + continue; + } + } + + AblViewUtil.mySleep(1); + if (childw.getText() != null) { + if (childw.getText().toString().equals("互相关注")) { + clickcommontwo(childw, "互相关注"); + AblViewUtil.mySleep(2); + AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 1); + clickcommontwo(quxiao, "取消关注"); + + } + } + } + } + } + } + + if(cancelclosed&&cancelcrosscor){ + Log.e("TIAOSHI###", "WWWWWWWWWWWWWWWWWWWWW"); + if (child2.getChildCount() != 0) { + for (int i = 0; i < child2.getChildCount(); i++) { + AccessibilityNodeInfo child = child2.getChild(i); + if (child.getText() != null) { + if (child.getText().toString().equals("已关注")) { + try { + Thread.sleep(300); + } catch (InterruptedException e) { + e.printStackTrace(); + } + clickcommontwo(child, "已关注"); + } + if (child.getText().toString().equals("互相关注")) { + AblViewUtil.mySleep(1); + clickcommontwo(child, "互相关注"); + AblViewUtil.mySleep(2); + AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 1); + clickcommontwo(quxiao, "取消关注"); + AblViewUtil.mySleep(1); + + } + } + } + } } } @@ -283,54 +350,83 @@ public class TestAblStep6 extends BaseAblStep { * 获得关注数 */ private void getargone() { + AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); + for (int i = 0; i < root.getChildCount(); i++) { + AccessibilityNodeInfo child = root.getChild(i); + // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); + for (int y = 0; y < child.getChildCount(); y++) { + AccessibilityNodeInfo child1 = child.getChild(y); + if (child1 != null) { + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if (child1.getText() != null) { +// if (child1.getText().equals("获赞")) { +// AccessibilityNodeInfo parent = child1.getParent(); +// AccessibilityNodeInfo child3 = parent.getChild(1); +// if (child3.getText() != null) { +// Log.e("TIAOSHI###", "获得的获赞数==" + child3.getText().toString()); +// huozannum = child3.getText().toString(); +// if (child3.getText().toString().equals("-")) { +// Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); +// } +// } +// } + if (child1.getText().equals("关注")) { + AccessibilityNodeInfo parent = child1.getParent(); + child3 = parent.getChild(1); + if (child3.getText() != null) { + Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); + guanzhunum = child3.getText().toString(); + + if (child3.getText().toString().equals("-")) { + Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); + } + } + } +// if (child1.getText().equals("粉丝")) { +// AccessibilityNodeInfo parent = child1.getParent(); +// AccessibilityNodeInfo child3 = parent.getChild(1); +// if (child3.getText() != null) { +// Log.e("TIAOSHI###", "获得的粉丝数==" + child3.getText().toString()); +// fensinum = child3.getText().toString(); +// if (child3.getText().toString().equals("-")) { +// Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); +// } +// } +// return; +// } + } + } + } + } + } + + /** + * 获得取消关注 + */ + private AccessibilityNodeInfo getquxiaoguanzhu() { + AccessibilityNodeInfo nodeinfo = null; AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); for (int i = 0; i < root.getChildCount(); i++) { AccessibilityNodeInfo child = root.getChild(i); Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) {//13.1版本写法 - if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { - Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); + // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { + if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { + // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); for (int y = 0; y < child.getChildCount(); y++) { AccessibilityNodeInfo child1 = child.getChild(y); - if (child1 != null) { - Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - // if ("android.widget.LinearLayout".equals(child1.getClassName())) { - for (int j = 0; j < child1.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child1.getChild(j); - if (child2 != null) { - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); - - for (int x = 0; x < child2.getChildCount(); x++) { - AccessibilityNodeInfo child4 = child2.getChild(x); - if (child4 != null) { - Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); - for (int z = 0; z < child4.getChildCount(); z++) { - AccessibilityNodeInfo child5 = child4.getChild(z); - if (child5 != null) { - Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); - if (child5.getText() != null) { - if (child5.getText().equals("关注")) { - AccessibilityNodeInfo parent = child5.getParent(); - child3 = parent.getChild(0); - Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); - guanzhunum = child3.getText().toString(); - if (child3.getText().toString().equals("-")) { - Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); - } - return; - } - - } - } - } - } - } + // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); + if ("android.widget.TextView".equals(child1.getClassName())) { + CharSequence text = child1.getText(); + if (text != null) { + if (text.toString().contains("# 互相关注")) { + nodeinfo = child1; } } } } } } + return nodeinfo; } } diff --git a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep7.java b/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep7.java deleted file mode 100644 index 2a2e2fe..0000000 --- a/app/src/main/java/com/fisherbone/fuzhu/step/TestAblStep7.java +++ /dev/null @@ -1,385 +0,0 @@ -package com.fisherbone.fuzhu.step; - -import android.accessibilityservice.AccessibilityService; -import android.accessibilityservice.GestureDescription; -import android.graphics.Path; -import android.graphics.Rect; -import android.os.Build; -import android.os.Message; -import android.util.Log; -import android.view.accessibility.AccessibilityNodeInfo; - -import androidx.annotation.RequiresApi; - -import com.blankj.utilcode.util.ToastUtils; -import com.fisherbone.fuzhu.ChangLiang; -import com.fisherbone.fuzhu.abllib.AblService; -import com.fisherbone.fuzhu.abllib.AblStepHandler; -import com.fisherbone.fuzhu.abllib.AblSteps; -import com.fisherbone.fuzhu.abllib.BaseAblStep; -import com.fisherbone.fuzhu.abllib.RandumInt; -import com.fisherbone.fuzhu.abllib.utils.AblViewUtil; - -import java.util.List; - -/** - * @param - * @description 一键取关(取消互关) - * @return - */ -public class TestAblStep7 extends BaseAblStep { - private String substring;//当前的关注数 - private int numb;//阈值 - private String guanzhunum; - private AccessibilityNodeInfo child3; - private AccessibilityNodeInfo child2; - - @Override - public void onStep(int step, Message msg) { - - // Log.e("TIAOSHI###==获得一键取互相关注的参数",ChangLiang.cancelclosed+"---"+ChangLiang.cancelcrosscor+"---"+ChangLiang.passnumber+"---"+ChangLiang.swiinterval+"---"+ChangLiang.minthrthr+""); - switch (step) { - case AblSteps.STEP_15: - AblViewUtil.startApplication(); - AblViewUtil.mySleep(8); - AblStepHandler.sendMsg(AblSteps.STEP_16); - break; - case AblSteps.STEP_16: - ChangLiang.ishuodong = "T"; - AblViewUtil.mySleep(5); - AblService instance = AblService.getInstance(); - //1.关闭广告 - //2.关闭青少年弹窗 - //3.点击我的 - myClick(); - AblViewUtil.mySleep(2); - //获取关注数(对比关注数是否满足预设的取关值;)若不满足,则直接结束任务,若满足,则点击【关注】,进入关注页; - getargone(); - AblViewUtil.mySleep(1); - if (guanzhunum==null) { - Log.e("TIAOSHI###", "关注数==null结束任务"); - ToastUtils.showShort("关注数==null结束任务"); - AblStepHandler.getInstance().setStop(true); - // AblViewUtil.onMessage("停止"); - return; - } - Log.e("TIAOSHI###", "获得的关注数==" + guanzhunum); - if(guanzhunum!=null) { - int num = Integer.parseInt(guanzhunum.toString()); - Log.e("TIAOSHI###", "关注数" + num); - numb = Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber); - if (num <= Integer.parseInt(ChangLiang.minthrthr) - Integer.parseInt(ChangLiang.passnumber)) { - Log.e("TIAOSHI###", "关注数小于等于设定的取关数结束任务"); - ToastUtils.showLong("关注数小于等于设定的取关数结束任务"); - AblStepHandler.getInstance().setStop(true); - AblViewUtil.onMessage("停止"); - return; - } - //点击进入用户关注页 - AblViewUtil.mySleep(2); - // AblService.getInstance().clickcommontwo(child, "进入用户关注页"); - AblService.getInstance().clickcommontwo(child3, "进入用户关注页"); - AblStepHandler.sendMsg(AblSteps.STEP_17); - } - break; - case AblSteps.STEP_17: - //寻找到第一条互相关注的进入个人信息页面 - //AblViewUtil.mySleep(1); - int num2 = Integer.parseInt(getNum()); - if (num2 > numb) { - // AblViewUtil.mySleep(1); - cancelGuanzhu(AblService.getInstance()); - } else { - ChangLiang.ishuodong = "F"; - AblViewUtil.back(); - } - break; - case AblSteps.STEP_18: - AblViewUtil.mySleep(3); - //获取一屏幕数据:快照 - AccessibilityNodeInfo roott = AblService.getInstance().getRootInActiveWindow(); - List idsj = roott.findAccessibilityNodeInfosByText("查找好友并关注"); - // List idsj = AblViewUtil.findByText("查找好友并关注"); - if (idsj.size() > 0) { - AccessibilityNodeInfo accessibilityNodeInfo = idsj.get(0); - CharSequence text1 = accessibilityNodeInfo.getText(); - if (text1.equals("查找好友并关注")) { - ChangLiang.ishuodong = "F"; - AblViewUtil.back(); - } - } - if (ChangLiang.ishuodong.equals("T")) { - AblViewUtil.mySleep(1); - // randomSwipe(); - AccessibilityNodeInfo chilrecy = getrecy(); - chilrecy.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD); //触发容器元素的滚动事件 - AblViewUtil.mySleep(3); - AblStepHandler.sendMsg(AblSteps.STEP_17); - } - break; - default: - } - } - - private AccessibilityNodeInfo getrecy() { - AccessibilityNodeInfo chilrecy = null; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { - AccessibilityNodeInfo child1 = child.getChild(1); - Rect rect = new Rect(); - child1.getBoundsInScreen(rect); - Log.e("TIAOSHI###", "----fourNode:" + "(" + rect.left + "," + rect.top + ")" + "," + "(" + rect.right + "," + rect.bottom + ")"); - if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { - chilrecy=child1; - } - } - } - return chilrecy; - } - - - private void cancelGuanzhu(AblService instance) { - // 取消已关: - // 在关注列表中,遍历寻找【已关注】的用户,点击【已关注】进行取关; - AblViewUtil.mySleep(2); - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - //遍历root下的子节点有哪些 - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if(child!=null){ - if ("androidx.viewpager.widget.ViewPager".equals(child.getClassName())) { - Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); - AccessibilityNodeInfo child1 = child.getChild(1); - if(child1!=null) { - // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - if ("androidx.recyclerview.widget.RecyclerView".equals(child1.getClassName())) { - for (int x = 0; x < child1.getChildCount(); x++) { - AccessibilityNodeInfo child2 = child1.getChild(x); - if(child1!=null) { - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - if (child2.getChildCount() != 0) { - for (int w = 0; w < child2.getChildCount(); w++) { - AccessibilityNodeInfo childw = child2.getChild(w); - if (childw != null) { - if (childw.getText() != null) { - if (!childw.getText().toString().equals("互相关注")) { - continue; - } - } - - AblViewUtil.mySleep(1); - if (childw.getText() != null) { - if (childw.getText().toString().equals("互相关注")) { - //clickcommontwo(child2, "进入互相关注"); - if (child2 != null) { - Rect rect = new Rect(); - child2.getBoundsInScreen(rect); - AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); - Log.e("TIAOSHI###", "点击" + "进入互相关注" + "按钮"); - Log.e("TIAOSHI###", "点击" + "进入互相关注" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); - } else { - Log.e("TIAOSHI###", "没有找到" + "进入互相关注" + "按钮,直接退出了。。。。"); - return; - } - AblViewUtil.mySleep(2); - //点击取消关注 - AccessibilityNodeInfo getquxiaoguanzhu = getquxiaoguanzhu(); - //AblService.getInstance().clickcommontwo(getquxiaoguanzhu, "点击互相关注"); - if (getquxiaoguanzhu != null) { - Rect rect = new Rect(); - getquxiaoguanzhu.getBoundsInScreen(rect); - AblService.getInstance().clickPoint((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2, 300); - Log.e("TIAOSHI###", "点击" + "互相关注" + "按钮" + "(" + (rect.left + rect.right) / 2 + "," + (rect.top + rect.bottom) / 2 + ")"); - AblViewUtil.mySleep(2); - //点击取消关注 - AccessibilityNodeInfo quxiao = AblViewUtil.findByText("取消关注", 1); - AblService.getInstance().clickcommonthree(quxiao, "取消关注"); - AblViewUtil.mySleep(2); - AblViewUtil.back(); - } else { - Log.e("TIAOSHI###", "没有找到" + "互相关注" + "按钮,直接退出了。。。。"); - AblViewUtil.mySleep(2); - AblViewUtil.back(); - - } - - } - } - } - } - } - } - } - } - } - }} - } - - //向上滑动 - // AblViewUtil.mySleep(2); - AblStepHandler.sendMsg(AblSteps.STEP_18); - } - - /** - * 获得取消关注 - */ - private AccessibilityNodeInfo getquxiaoguanzhu() { - AccessibilityNodeInfo nodeinfo = null; - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - // if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { - if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { - // Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - // Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - if ("android.widget.TextView".equals(child1.getClassName())) { - CharSequence text = child1.getText(); - if (text != null) { - if (text.toString().contains("# 互相关注")) { - nodeinfo=child1; - } - } - } - } - } - } - return nodeinfo; - } - - - /** - * 获得当前的关注数 - * - * @return - */ - private String getNum() { - //获取关注数 - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - //遍历root下的子节点有哪些 - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - // Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - if ("android.widget.HorizontalScrollView".equals(child.getClassName())) { - // Log.e("TIAOSHI###HorizontalScrollView", "----twoNode:" + child.getChildCount()); - for (int j = 0; j < child.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child.getChild(j); - // Log.e("TIAOSHI###", "----twoNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - } - AccessibilityNodeInfo child1 = child.getChild(0); - if ("androidx.appcompat.app.ActionBar$Tab".equals(child1.getClassName())) { - for (int x = 0; x < child1.getChildCount(); x++) { - child2 = child1.getChild(x); - // Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText() + ":" + child2.getContentDescription()); - String s = child2.getText().toString(); - // Log.e("TIAOSHI###", s + "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - substring = s.substring(3); - Log.e("TIAOSHI###", "----关注数:" + substring); - } - } - } - } - return substring; - } - - - @RequiresApi(api = Build.VERSION_CODES.N) - public void randomSwipe() { - if (ChangLiang.phonetype.equals("0")) { - int a = 170 + RandumInt.getRandumInt4() * 8; - int b = 170 - RandumInt.getRandumInt4() * 10; - int c = 1200 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 - int d = 400 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 - // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 - swipe(a, c, b, d, 320); //延迟330毫秒 - } else { - int a = 500 + RandumInt.getRandumInt4() * 8; - int b = 500 - RandumInt.getRandumInt4() * 10; - int c = 1500 - RandumInt.getRandumInt4() * 8; // 1280分辨率起步的滑动方式 - int d = 700 - RandumInt.getRandumInt4() * 9; // 刚才是300, 延迟350~400 - // 800毫秒的时候,有时候有点卡,但是能用,再试试其他的 - swipe(a, c, b, d, 420); //延迟330毫秒 - } - } - - - @RequiresApi(api = Build.VERSION_CODES.N) - public void swipe(float x1, float y1, float x2, float y2, long duration) { - Path path = new Path(); - path.moveTo(x1, y1); - path.lineTo(x2, y2); - - Log.e("TIAOSHI###", "MyAccessibilityService中滑动swipe()方法滑动点,reset:(" + x1 + "," + y1 + "),(" + x2 + "," + y2 + ")" + "滑动的时长是:" + duration); - GestureDescription.Builder builder = new GestureDescription.Builder(); - GestureDescription gestureDescription = builder - .addStroke(new GestureDescription.StrokeDescription(path, 0, duration)) - .build(); - boolean b = AblService.getInstance().dispatchGesture(gestureDescription, new AccessibilityService.GestureResultCallback() { - @Override - public void onCompleted(GestureDescription gestureDescription) { - super.onCompleted(gestureDescription); - Log.e("TIAOSHI###", "滑动结束..." + gestureDescription.getStrokeCount()); - - } - - @Override - public void onCancelled(GestureDescription gestureDescription) { - super.onCancelled(gestureDescription); - Log.e("TIAOSHI###", "滑动取消"); - } - }, null); - } - - - /** - * 获得关注数 - */ - private void getargone() { - AccessibilityNodeInfo root = AblService.getInstance().getRootInActiveWindow(); - for (int i = 0; i < root.getChildCount(); i++) { - AccessibilityNodeInfo child = root.getChild(i); - Log.e("TIAOSHI###", "----oneNode:" + child.getClassName() + ":" + child.getText() + ":" + child.getContentDescription()); - //if ("dmt.viewpager.DmtViewPager$d".equals(child.getClassName())) { - if ("dmt.viewpager.DmtViewPager$MyAccessibilityDelegate".equals(child.getClassName())) { - Log.e("TIAOSHI###ViewPager", "----twoNode:" + child.getChildCount()); - for (int y = 0; y < child.getChildCount(); y++) { - AccessibilityNodeInfo child1 = child.getChild(y); - Log.e("TIAOSHI###", "----twoNode:" + child1.getClassName() + ":" + child1.getText() + ":" + child1.getContentDescription()); - // if ("android.widget.LinearLayout".equals(child1.getClassName())) { - for (int j = 0; j < child1.getChildCount(); j++) { - AccessibilityNodeInfo child2 = child1.getChild(j); - Log.e("TIAOSHI###", "----threeNode:" + child2.getClassName() + ":" + child2.getText()); - - for (int x = 0; x < child2.getChildCount(); x++) { - AccessibilityNodeInfo child4 = child2.getChild(x); - Log.e("TIAOSHI###", "----fourNode:" + child4.getClassName() + ":" + child4.getText()); - for (int z = 0; z < child4.getChildCount(); z++) { - AccessibilityNodeInfo child5 = child4.getChild(z); - Log.e("TIAOSHI###", "----fiveNode:" + child5.getClassName() + ":" + child5.getText()); - if (child5.getText() != null) { - if (child5.getText().equals("关注")) { - AccessibilityNodeInfo parent = child5.getParent(); - child3 = parent.getChild(0); - Log.e("TIAOSHI###", "获得的关注数==" + child3.getText().toString()); - guanzhunum = child3.getText().toString(); - if (child3.getText().toString().equals("-")) { - Log.e("TIAOSHI###", "数据异常,停止服务。。。。。。。。。。。。"); - } - return; - } - - } - } - } - } - } - } - } - } -} diff --git a/app/src/main/res/layout/activity_cancle_follow.xml b/app/src/main/res/layout/activity_cancle_follow.xml index fbec49d..3aa48b3 100644 --- a/app/src/main/res/layout/activity_cancle_follow.xml +++ b/app/src/main/res/layout/activity_cancle_follow.xml @@ -58,6 +58,7 @@ android:id="@+id/radioButton01" android:text="取消已关" android:textSize="16sp" + android:checked="@={canclefollowbean.cancelclosed}" style="@style/fragment_text" /> @@ -89,6 +90,7 @@ style="@style/fragment_text" android:text="取消互关" android:textSize="16sp" + android:checked="@={canclefollowbean.cancelcrosscor}" />