Преглед на файлове

新增版本号和WeworkService中的accessibilityFlags、canRetrieveWindowContent

yangyang преди 6 месеца
родител
ревизия
7589dcee64

+ 2 - 0
app/src/main/AndroidManifest.xml

@@ -93,6 +93,8 @@
             android:exported="true"
             android:label="@string/app_name"
             android:foregroundServiceType="dataSync"
+            android:accessibilityFlags="flagDefault|flagRetrieveInteractiveWindows|flagIncludeNotImportantViews"
+            android:canRetrieveWindowContent="true"
             android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
             <intent-filter>
                 <action android:name="android.accessibilityservice.AccessibilityService" />

+ 9 - 0
app/src/main/java/org/yameida/worktool/model/WeworkMessageBean.java

@@ -134,6 +134,7 @@ public class WeworkMessageBean {
     public static final int SWITCH_WE_COM = 804;
     public static final int LOGIN_OUT = 802;
     public static final int INIT = 803;
+    public static final int VERSION_NAME = 805;
 
     /**
      * roomType
@@ -315,6 +316,8 @@ public class WeworkMessageBean {
     public Integer weCom;
     public String weworkSchema;
     public List<String> ids;
+    public String weWorkVersion;
+    public String appVersionName;
 
     public boolean isRelay;
 
@@ -338,6 +341,12 @@ public class WeworkMessageBean {
         this.log = log;
     }
 
+    public WeworkMessageBean(Integer type,String weWorkVersion, String appVersionName) {
+        this.type = type;
+        this.weWorkVersion = weWorkVersion;
+        this.appVersionName = appVersionName;
+    }
+
     //消息类型
     public Integer type = 0;
 

+ 9 - 2
app/src/main/java/org/yameida/worktool/service/MyLooper.kt

@@ -3,6 +3,7 @@ package org.yameida.worktool.service
 import android.os.Handler
 import android.os.Looper
 import android.os.Message
+import com.blankj.utilcode.util.AppUtils
 import com.blankj.utilcode.util.EncryptUtils
 import com.blankj.utilcode.util.GsonUtils
 import com.blankj.utilcode.util.LogUtils
@@ -92,6 +93,12 @@ object MyLooper {
         if (messageList.socketType == WeworkMessageListBean.SOCKET_TYPE_MESSAGE_CONFIRM) {
             return
         }
+        if (messageList.socketType == WeworkMessageListBean.SOCKET_TYPE_RAW_CONFIRM) {
+            if (!messageList.list.isNullOrEmpty() && messageList.list[0].type == 805) {
+                SPUtils.getInstance().put("appVersionName", AppUtils.getAppVersionName())
+            }
+            return
+        }
 //        if (messageList.socketType == WeworkMessageListBean.SOCKET_TYPE_INTI) {
 //            if (messageList.weworkSchema != SPUtils.getInstance().getString("weworkSchema")) {
 //                SPUtils.getInstance().put("weworkSchema", messageList.weworkSchema)
@@ -127,8 +134,8 @@ object MyLooper {
             val list =
                 if (Constant.duplicationFilter) LinkedHashSet(messageList.list).toList() else messageList.list
             //去重处理 丢弃之前的重复指令 丢弃之前的获取新消息指令
-            for (i in list.indices){
-                val message= list[i]
+            for (i in list.indices) {
+                val message = list[i]
                 if (message.type == WeworkMessageBean.ROBOT_QUEUE_CLEAR) {
                     getInstance().removeCallbacksAndMessages(null)
                     LogUtils.i("清空全部待执行指令")

+ 7 - 3
app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt

@@ -6918,7 +6918,8 @@ object WeworkOperationImpl {
         return true
     }
 
-    fun sendGroupChat(message: WeworkMessageBean): Boolean {
+    fun sendGroupChat(message: WeworkMessageBean, maxRetryCount: Int? = null): Boolean {
+        val retryCount = maxRetryCount ?: 1
         if (WeworkRoomUtil.intoGroupChat("群发助手") || WeworkRoomUtil.intoGroupChat(
                 "群发助手",
                 fastIn = false
@@ -7008,8 +7009,11 @@ object WeworkOperationImpl {
                 System.currentTimeMillis()
             )
 
+        } else {
+            if (retryCount > 0) {
+                return sendGroupChat(message, retryCount - 1)
+            }
         }
-
         return true
     }
 
@@ -7017,7 +7021,7 @@ object WeworkOperationImpl {
         if (WeworkRoomUtil.intoGroupChat("客户朋友圈") || WeworkRoomUtil.intoGroupChat(
                 "客户朋友圈",
                 fastIn = false
-            )||WeworkRoomUtil.intoGroupChat("学员朋友圈") || WeworkRoomUtil.intoGroupChat(
+            ) || WeworkRoomUtil.intoGroupChat("学员朋友圈") || WeworkRoomUtil.intoGroupChat(
                 "学员朋友圈",
                 fastIn = false
             )

+ 10 - 0
app/src/main/java/org/yameida/worktool/service/WeworkService.kt

@@ -130,6 +130,7 @@ class WeworkService : AccessibilityService() {
             val appVersion = SPUtils.getInstance().getString("appVersion", "")
             val workVersion = SPUtils.getInstance().getString("workVersion", "")
             val deviceRooted = SPUtils.getInstance().getBoolean("deviceRooted", false)
+            var appVersionName = SPUtils.getInstance().getString("appVersionName","")
             val hook = SPUtils.getInstance().getBoolean("hook", false)
             if (WeworkController.weworkService.rootInActiveWindow != null) {
                 WeworkController.weworkService.webSocketManager.send(
@@ -141,6 +142,15 @@ class WeworkService : AccessibilityService() {
                     )
                 )
             }
+            if (AppUtils.getAppVersionName() != appVersionName) {
+                WeworkController.weworkService.webSocketManager.send(
+                    WeworkMessageBean(
+                        WeworkMessageBean.VERSION_NAME,
+                        workVersion,
+                        AppUtils.getAppVersionName()
+                    )
+                )
+            }
             LogUtils.i("连接建立: $robotId appVersion: $appVersion workVersion: $workVersion deviceRooted: $deviceRooted hook: $hook")
             log("连接建立: $robotId appVersion: $appVersion workVersion: $workVersion deviceRooted: $deviceRooted hook: $hook")
             LogUtils.i("设置自动跳转企业微信")