Browse Source

1.调试大群加好友偶发自然停止现象;2.定位消息免打扰失效问题;3.优化大群加好友结束逻辑;

owen 6 years ago
parent
commit
d88a1a663a

+ 7 - 0
app/src/main/java/com/wiipu/marketingrobot/AutoReplyService.java

@@ -246,6 +246,13 @@ public class AutoReplyService extends AccessibilityService implements getCommonV
                     performGlobalAction(GLOBAL_ACTION_HOME);
                 }
 
+                else if (event.getClassName().equals("event name:com.tencent.mm.ui.SingleChatInfoUI")){
+                    // 进入联系人页面
+                    // performGlobalAction(GLOBAL_ACTION_HOME);
+                    isSendingPermissionRequest = false;
+                    performGlobalAction(GLOBAL_ACTION_BACK);
+                }
+
                 if (!hasAction) {
                     LogUtils.d(TAG + " hasAction = false");
                     break;

+ 20 - 9
app/src/main/java/com/wiipu/marketingrobot/function/addGroupFunction.java

@@ -290,6 +290,12 @@ public class addGroupFunction implements moneyContract.View  , getCommonValueCon
             //SystemClock.sleep(3000);
 
         }
+        if (event.getClassName().equals("com.tencent.mm.ui.contact.SelectContactUI")) { //大群群员列表
+            LogUtils.d("点击到了加号"); // 应该如何避免呢
+            mService.performGlobalAction(GLOBAL_ACTION_BACK);
+            return;
+
+        }
         if (event.getClassName().equals("com.tencent.mm.plugin.profile.ui.ContactInfoUI")) {
             //群友信息界面
 
@@ -622,6 +628,7 @@ public class addGroupFunction implements moneyContract.View  , getCommonValueCon
 
         }
 
+        needToScrollUpTimes = needToScrollUpTimes > (mCurrentRoomSize / 30 + 1) ? (mCurrentRoomSize / 30 + 1) : needToScrollUpTimes;
         for (int i = 1; i < needToScrollUpTimes; i++){
             gridView.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
             LogUtils.e( " 向上滑动页面 第 " + i + " 次");
@@ -641,7 +648,7 @@ public class addGroupFunction implements moneyContract.View  , getCommonValueCon
             }
         }
         addcount++;
-        if (addcount + nullNameCount > AutoReplyService.enableFriendsCounts) {
+        if (addcount > AutoReplyService.enableFriendsCounts) {
             LogUtils.d(TAG + " 已经不能再添加好友了,当前可添加好友数量为 : " + AutoReplyService.enableFriendsCounts);
             mService.performGlobalAction(GLOBAL_ACTION_BACK);//大于预定人员数直接后退
             addcount = 0;
@@ -652,7 +659,7 @@ public class addGroupFunction implements moneyContract.View  , getCommonValueCon
         LogUtils.e(TAG + " addBigGroupFriends: 当前索引为 : " + bigChatRoomMemberIndex
                 + "  存储的人数为 : " + bigChatRoomMemberNameList.size());
 
-        if (bigChatRoomMemberNameList.size() == mCurrentRoomSize) {
+        if (bigChatRoomMemberNameList.size() + nullNameCount >= mCurrentRoomSize) {
             nullNameCount = 0;
             needToScrollUpTimes = 0;
             LogUtils.e(TAG + " addBigGroupFriends: 已经加完所有群成员了,返回到群聊页面 ");
@@ -680,18 +687,21 @@ public class addGroupFunction implements moneyContract.View  , getCommonValueCon
                 nullNameCount++;
                 LogUtils.d(TAG + " 没有群昵称的群成员个数为 :" + nullNameCount);
             }
-            SystemClock.sleep(1000);
+
+
             if (nullNameCount + bigChatRoomMemberNameList.size() < mCurrentRoomSize) {
-                if (null != child) {
+                if (null != name) {
                     AccessibilityHelper.performClick(child);
                 }else {
-                    LogUtils.e("当前位置没有图标 或 当前位置为加号图标 ");
+                    LogUtils.e("当前位置群成员没有昵称 ");
+                    addBigGroupFriends();
+                    // return;
                 }
+                bigChatRoomMemberIndex++;
             }else {
                 LogUtils.e("已经加载完整个群了");
-
+                mService.performGlobalAction(GLOBAL_ACTION_BACK);
             }
-            bigChatRoomMemberIndex++;
         }
         else {
             //找下一个该点的
@@ -784,7 +794,7 @@ public class addGroupFunction implements moneyContract.View  , getCommonValueCon
             LogUtils.e(TAG + " searchBigChatRoomMembersInfo: find 免打扰");
             rootlist.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);//增加下滑保证一定能找到
             SystemClock.sleep(1000);
-
+            searchBigChatRoomMembersInfo();
         }
 
         //在加完好友后点击消息免打扰
@@ -798,7 +808,8 @@ public class addGroupFunction implements moneyContract.View  , getCommonValueCon
         AccessibilityNodeInfo exit = AccessibilityHelper.findNodeInfosById(root, msgNoDisturb);//消息免打扰右侧开关ID
         if (exit != null) {
             // forceClick(exit);
-            LogUtils.e(TAG +  " 启用 消息免打扰 当前已注释");
+            AccessibilityHelper.performClick(exit);
+            LogUtils.e(TAG +  " 启用 消息免打扰");
         }
 
         /**

+ 6 - 4
app/src/main/java/com/wiipu/marketingrobot/function/handleChatFunction.java

@@ -245,10 +245,7 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
                     // 小群加好友,大群就退出
                     openMemberList();
                 }else {
-                    mService.performGlobalAction(GLOBAL_ACTION_BACK);
-                    AutoReplyService.isInAction = false;
-                    finishAllJob = false;
-                    RxBus.post(new eventClassFunction(true));
+                    finishAllJob = true;
                 }
                 return;
             }
@@ -1037,6 +1034,11 @@ public class handleChatFunction implements replyContract.View , LoginContract.Vi
         if (exit != null) {
             LogUtils.e(TAG +  " 启用 消息免打扰 当前已注释");
             // forceClick(exit);
+            if (exit.isClickable()) {
+                AccessibilityHelper.performClick(exit);
+            }else {
+                AccessibilityHelper.performClick(exit.getParent());
+            }
         }
 
         addCount = 0;