检测监听事件的节点信息
- private void checkNodeInfo() {
- L.d("checkNodeInfo!");
- if (this.rootNodeInfo == null) return;
- /* 聊天会话窗口,遍历节点匹配“领取红包”和"查看红包" */
- List<AccessibilityNodeInfo> nodes1 = this.findAccessibilityNodeInfosByTexts(this.rootNodeInfo, new String[]{
- GET_RED_PACKET, CHECK_RED_PACKET});
- if (!nodes1.isEmpty()) {
- L.d("!nodes1.isEmpty()");
- AccessibilityNodeInfo targetNode = nodes1.get(nodes1.size() - 1);
- if ("android.widget.LinearLayout".equals(targetNode.getParent().getClassName()))//避免被文字干扰导致外挂失效
- {
- if (this.signature.generateSignature(targetNode)) {
- mLuckyMoneyReceived = true;
- mReceiveNode = targetNode;
- L.d("signature:" + this.signature.toString());
- }
- } else {
- L.d("this is text");
- }
- return;
- }
-
- List<AccessibilityNodeInfo> nodes2 = this.findAccessibilityNodeInfosByTexts(this.rootNodeInfo, new String[]{
- "拆红包"});
- if (!nodes2.isEmpty()) {
- L.d("node2 != null");
- for (AccessibilityNodeInfo nodeInfo : nodes2) {
- if (nodeInfo.getClassName().equals("android.widget.Button"))
- nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
- }
- } else {
- /* 戳开红包,红包还没抢完,遍历节点匹配“拆红包” */
- AccessibilityNodeInfo node2 = (this.rootNodeInfo.getChildCount() > 3) ? this.rootNodeInfo.getChild(3) : null;
- if (node2 != null && node2.getClassName().equals("android.widget.Button")) {
- mUnpackNode = node2;
- mNeedUnpack = true;
- isToGetMoney = true;
- L.d("find red packet!");
- return;
- }
- }
- /* 戳开红包,红包已被抢完,遍历节点匹配“已存入零钱”和“手慢了” */
- if (mLuckyMoneyPicked) {
- List<AccessibilityNodeInfo> nodes3 = this.findAccessibilityNodeInfosByTexts(this.rootNodeInfo, new String[]{
- RED_PACKET_PICKED, RED_PACKET_SAVE, RED_PACKET_PICKED2, RED_PACKET_PICKED_DETAIL});
- if (!nodes3.isEmpty()) {
- L.d("!nodes3.isEmpty()");
- if (rootNodeInfo.getChildCount() > 1) {
- L.d("RED_PACKET_PICKED!");
- } else {
- L.d("nodes3.get(0).toString(): " + nodes3.get(0).getText().toString());
- if (!nodes3.get(0).getText().toString().equals(RED_PACKET_PICKED_DETAIL)) {
- AccessibilityNodeInfo targetNode = nodes3.get(nodes3.size() - 1);
- hongbaoInfo.getInfo(targetNode);
- if (isToGetMoney) {
- isGetMoney = true;
- isToGetMoney = false;
- gotMoney = hongbaoInfo.getMoney();
- L.d("gotMoney: " + gotMoney);
- }
- L.d("RED_PACKET_SAVE!");
- L.d("hongbaoInfo: " + hongbaoInfo.toString());
- } else {
- L.d("this packet is myself!");
- }
-
- }
- mNeedBack = true;
- mLuckyMoneyPicked = false;
- }
- }
- }
主要通过检测“领取红包”等关键文字信息来判断是否有新红包
检测收到红包时判断是否"android.widget.LinearLayout",屏蔽聊天信息中的文字干扰
拆红包时,由于微信版本可能不同,同时进行两种判断,以兼容部分版本
拆完红包需自动返回,有以下几种情况:抢到了,手慢了,以及该红包是自己发出的红包 (编辑:威海站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|