yangyang 1 rok temu
rodzic
commit
13b105a8a9

+ 1 - 1
app/src/main/java/org/yameida/worktool/Constant.kt

@@ -51,7 +51,7 @@ object Constant {
     var LONG_INTERVAL = BASE_LONG_INTERVAL
     var CHANGE_PAGE_INTERVAL = BASE_CHANGE_PAGE_INTERVAL
     var POP_WINDOW_INTERVAL = BASE_POP_WINDOW_INTERVAL
-    private const val DEFAULT_HOST = "wss://www.mooger8.com/webSocket/"
+    private const val DEFAULT_HOST = "wss://assistant.flowbb.top/webSocket/"
 
     var version = Int.MAX_VALUE
     var myName = ""

+ 3 - 4
app/src/main/java/org/yameida/worktool/Demo.kt

@@ -96,16 +96,15 @@ object Demo {
         MyLooper.onMessage(null, json)
     }
 
-    fun test5(name: String) {
+    fun test5() {
         val time = TimeUtils.date2String(Date(), "MMddHHmm")
-        val groupName = "$name"
+        val groupName = ""
         val json = """
             {
                 "socketType":2,
                 "list":[
                      {
-                      "type": 604,
-                      "groupName": [$groupName],
+                      "type": 303,
                       "receivedContent":"1"
                     }
                 ]

+ 5 - 0
app/src/main/java/org/yameida/worktool/MyApplication.kt

@@ -1,6 +1,7 @@
 package org.yameida.worktool
 
 import android.app.Application
+import android.content.Context
 import android.content.Intent
 import com.blankj.utilcode.util.GsonUtils
 import com.blankj.utilcode.util.LogUtils
@@ -20,9 +21,11 @@ import org.yameida.worktool.utils.OKHttpUpdateHttpService
 
 class MyApplication : Application() {
 
+
     companion object {
 
         var iwwapi: IWWAPI? = null
+        lateinit var mContext: Context
 
         /**
          * 回到WorkTool首页 需要先授权显示悬浮窗
@@ -37,10 +40,12 @@ class MyApplication : Application() {
         }
     }
 
+
     override fun onCreate() {
         super.onCreate()
         //初始化工具类
         Utils.init(this)
+        mContext = this
         //初始化Log工具配置
         LogUtilsInit.init()
         GsonUtils.setGsonDelegate(Gson())

+ 99 - 38
app/src/main/java/org/yameida/worktool/activity/ListenActivity.kt

@@ -1,23 +1,26 @@
 package org.yameida.worktool.activity
 
+import android.app.ActivityManager
 import android.content.*
-import android.graphics.Bitmap
 import android.os.Bundle
 import android.os.Handler
 import android.os.IBinder
 import android.provider.Settings
 import android.text.InputType
+import android.util.Log
 import android.view.WindowManager
+import android.view.accessibility.AccessibilityNodeInfo
 import android.widget.CompoundButton
 import androidx.appcompat.app.AppCompatActivity
 import com.blankj.utilcode.constant.PermissionConstants
 import com.blankj.utilcode.util.*
 import com.google.android.material.dialog.MaterialAlertDialogBuilder
-import com.lzy.okgo.OkGo
 import com.qmuiteam.qmui.widget.dialog.QMUIDialog
+import com.xuexiang.xupdate.XUpdate
 import kotlinx.android.synthetic.main.activity_listen.*
 import org.yameida.worktool.Constant
 import org.yameida.worktool.R
+import org.yameida.worktool.model.WeworkMessageBean
 import org.yameida.worktool.service.PlayNotifyService
 import org.yameida.worktool.service.WeworkController
 import org.yameida.worktool.service.fastStartActivity
@@ -25,10 +28,6 @@ import org.yameida.worktool.utils.*
 import org.yameida.worktool.utils.capture.MediaProjectionHolder
 import org.yameida.worktool.utils.envcheck.CheckHook
 import org.yameida.worktool.utils.envcheck.CheckRoot
-import java.io.ByteArrayOutputStream
-import java.io.File
-import java.text.SimpleDateFormat
-import java.util.*
 
 
 class ListenActivity : AppCompatActivity() {
@@ -63,7 +62,6 @@ class ListenActivity : AppCompatActivity() {
         initNotification()
         PermissionUtils.permission(PermissionConstants.STORAGE).request()
         registerReceiver(openWsReceiver, IntentFilter(Constant.WEWORK_NOTIFY))
-
     }
 
     override fun onDestroy() {
@@ -99,9 +97,7 @@ class ListenActivity : AppCompatActivity() {
 //            })
 //            HttpUtil.getMyConfig(toast = false)
 //            MobclickAgent.onProfileSignIn(channel)
-//            handler.postDelayed({
-//                Demo.test3()
-//            },8000)
+
 //            test()
         }
         tv_host.text = Constant.host
@@ -211,6 +207,10 @@ class ListenActivity : AppCompatActivity() {
 
     private fun initData() {
 //        HttpUtil.checkUpdate()
+        XUpdate.newBuild(this)
+            .param("appRegion", "workTool")
+            .updateUrl(Constant.updateBaseUrl)
+            .update()
         HttpUtil.getMyConfig(toast = false)
         CacheUtil.autoDelete()
     }
@@ -317,6 +317,46 @@ class ListenActivity : AppCompatActivity() {
             packageManager.getLaunchIntentForPackage(Constant.PACKAGE_NAMES)?.apply {
                 this.flags = Intent.FLAG_ACTIVITY_NEW_TASK
                 startActivity(this)
+                if (weComNum() == 1) {
+                    SPUtils.getInstance().put("weCom", 1)
+                    SPUtils.getInstance().put("num", 1)
+                    WeworkController.weworkService.webSocketManager.send(
+                        WeworkMessageBean(
+                            WeworkMessageBean.WE_COM_TYPE,
+                            SPUtils.getInstance().getInt("weCom"),
+                            SPUtils.getInstance().getInt("num"),
+                            null
+                        )
+                    )
+                } else {
+                    bt_save.postDelayed({
+                        val rootNode = WeworkController.weworkService.rootInActiveWindow
+                        if (rootNode != null) {
+                            // 查找并点击第一个应用
+                            val firstAppNode: AccessibilityNodeInfo = findFirstAppNode(rootNode)!!
+                            if (firstAppNode != null) {
+                                AccessibilityUtil.performClick(firstAppNode)
+                            }
+                            SPUtils.getInstance().put("weCom", 1)
+                            SPUtils.getInstance().put("num", 2)
+//                        WeworkController.weworkService.webSocketManager.send(
+//                                WeworkMessageListBean<Any?>(
+//                                    1,
+//                                    WeworkMessageListBean.SOCKET_TYPE_INTI
+//                                )
+//                            )
+                            WeworkController.weworkService.webSocketManager.send(
+                                WeworkMessageBean(
+                                    WeworkMessageBean.WE_COM_TYPE,
+                                    SPUtils.getInstance().getInt("weCom"),
+                                    SPUtils.getInstance().getInt("num"),
+                                    null
+                                )
+                            )
+                        }
+                    }, 500)
+                }
+
             }
         }, 5000)
     }
@@ -329,36 +369,57 @@ class ListenActivity : AppCompatActivity() {
         }
     }
 
-    fun test(){
-        val imageUrl="https://assistant.flowbb.top/assistant/4af01bb1e19abaf0b4d6bcb4a620ba26.jpg/4af01bb1e19abaf0b4d6bcb4a620ba26.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minioadmin%2F20241219%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241219T063441Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=2e45427335a9ec2573b1125d23297c555d08dd146b090bf254015ff0b149f70f"
-        Thread {
-            val execute = OkGo.get<File>(imageUrl).execute()
-            LogUtils.i("下载完成 $imageUrl")
-            val body = execute.body()
-            if (body != null) {
-                val df = SimpleDateFormat("yyyy-MM-dd")
-                val filePath = "${
-                    Utils.getApp().getExternalFilesDir("mp_image_cache")
-                }/${df.format(Date())}/${imageUrl.split("/").lastOrNull()}"
-                val newFile = File(filePath)
-                if (FileUtils.isFile(newFile)) {
-                    FileUtils.delete(newFile)
-                }
-                val create = FileUtils.createFileByDeleteOldFile(newFile)
-                if (create && newFile.canWrite()) {
-                    newFile.writeBytes(body.bytes())
-                    LogUtils.i("文件存储本地成功 $filePath")
-                    val bitmap = ImageUtils.bytes2Bitmap(File(filePath).readBytes())
-                    val stream = ByteArrayOutputStream()
-                    bitmap.compress(Bitmap.CompressFormat.JPEG, 75, stream)
-                } else {
-                    LogUtils.e("文件存储本地失败 $filePath")
-                }
-            } else {
-                LogUtils.e("文件下载失败")
+    var num: Int = 0
+
+    fun weComNum(): Int {
+//        val packageManager = packageManager
+//        val installedApps = packageManager.getInstalledPackages(0)
+//        val get = installedApps[178]
+//        for (appInfo in installedApps) {
+//            val packageName = appInfo.packageName
+//            appInfo.applicationInfo.name
+//                Log.e("aaaaa", "---------" + packageName)
+//            // 可以进一步获取其他信息,如版本号、权限等
+//        }
+
+//        val packageManager = packageManager
+//        val apps = packageManager.getInstalledApplications(PackageManager.GET_META_DATA)
+//        for (appInfo in apps) {
+//            if (appInfo.packageName.contains("com.tencent.wework")) {
+//                Log.e("AppInfo", "Installed app: " + appInfo.packageName)
+//            }
+//        }
+        num = 0;
+        val activityManager = getSystemService(ACTIVITY_SERVICE) as ActivityManager
+        val processes = activityManager.runningAppProcesses
+        for (processInfo in processes) {
+            if (processInfo.processName.contains("com.tencent.wework")) {
+                Log.e("AppInfo", "Running app process: " + processInfo.processName)
+                num++;
             }
-        }.start()
+        }
+        return num
+//        val packageManager = packageManager
+//        val apps = packageManager.getInstalledApplications(PackageManager.GET_META_DATA)
+//        for (appInfo in apps) {
+//            if (appInfo.packageName == "com.tencent.wework") {
+//                // 找到主应用
+//                Log.e("AppInfo", "Main app: " + appInfo.packageName)
+//            } else if (appInfo.packageName.contains("com.tencent.wework:clone")) {
+//                // 找到分身应用
+//                Log.e("AppInfo", "Clone app: " + appInfo.packageName)
+//            }
+//        }
 
+
+    }
+
+    private fun findFirstAppNode(rootNode: AccessibilityNodeInfo): AccessibilityNodeInfo? {
+        // 查找选择框中的第一个应用
+//        val findAllByText = AccessibilityUtil.findAllByText(rootNode, "企业微信")
+        val buttonList = AccessibilityUtil.findAllByClazz(rootNode, Views.ImageView)
+        return buttonList.firstOrNull()
     }
 
+
 }

+ 14 - 2
app/src/main/java/org/yameida/worktool/model/WeworkMessageBean.java

@@ -126,6 +126,10 @@ public class WeworkMessageBean {
     public static final int DELETE_HARASS_RULE = 702;
     public static final int CANCEL_HARASS_RULE = 703;
     public static final int APPLY_HARASS_RULE = 704;
+    public static final int WE_COM_TYPE = 801;
+    public static final int SWITCH_WE_COM = 804;
+    public static final int LOGIN_OUT = 802;
+    public static final int INIT = 803;
 
     /**
      * roomType
@@ -274,7 +278,7 @@ public class WeworkMessageBean {
     public String path;
     public String username;
     public String schema;
-    public String messageType;
+    public Integer num;
     public String msgCheckFlag;
     public List<String> msgKeywordList;
     public String miniSendFlag;
@@ -304,7 +308,8 @@ public class WeworkMessageBean {
     public String name;
     public String addBlacklistFlag;
     public List<GroupList> groupList;
-
+    public Integer weCom;
+    public String weworkSchema;
 
     public WeworkMessageBean() {
     }
@@ -319,6 +324,13 @@ public class WeworkMessageBean {
         this.receivedName = receivedName;
     }
 
+    public WeworkMessageBean(Integer type, Integer weCom, Integer num, String log) {
+        this.type = type;
+        this.weCom = weCom;
+        this.num = num;
+        this.log = log;
+    }
+
     //消息类型
     public Integer type = 0;
 

+ 6 - 0
app/src/main/java/org/yameida/worktool/model/WeworkMessageListBean.kt

@@ -46,6 +46,8 @@ class WeworkMessageListBean<T> {
 
     var weworkSchema: String? = ""
 
+    var weCom: Int? = 1
+
     constructor(weworkMessageBean: T, type: Int, messageId: String? = null, meta: String? = null) {
         if (encryptType == 0) {
             list.add(weworkMessageBean)
@@ -90,4 +92,8 @@ class WeworkMessageListBean<T> {
         this.socketType = type
     }
 
+    constructor(weComType: Int, type: Int) {
+        this.socketType = type
+        this.weCom = weComType
+    }
 }

+ 23 - 0
app/src/main/java/org/yameida/worktool/service/GlobalMethod.kt

@@ -79,6 +79,14 @@ fun goHomeTab(title: String): Boolean {
                 if (AccessibilityUtil.findOnceByText(getRoot(), "手机号登录", exact = true) != null) {
                     LogUtils.e("登录前请先关闭WorkTool主功能!")
                     ToastUtils.show("登录前请先关闭WorkTool主功能!")
+                    WeworkController.weworkService.webSocketManager.send(
+                        WeworkMessageBean(
+                            WeworkMessageBean.LOGIN_OUT,
+                            SPUtils.getInstance().getInt("weCom"),
+                            null,
+                            null
+                        )
+                    )
                     WeworkController.weworkService.disableSelf()
                     WeworkController.weworkService.webSocketManager.close(1000, "wework logout")
                     MyApplication.launchIntent()
@@ -160,6 +168,21 @@ fun getRoot(ignoreCheck: Boolean, share: Boolean = false): AccessibilityNodeInfo
                                     this.flags = Intent.FLAG_ACTIVITY_NEW_TASK
                                     Utils.getApp().startActivity(this)
                                 }
+                            //TODO 点击跳转
+                            if (SPUtils.getInstance().getInt("num") == 2) {
+                                sleep(Constant.BASE_POP_WINDOW_INTERVAL)
+                                val rootNode = WeworkController.weworkService.rootInActiveWindow
+                                val firstAppNode: AccessibilityNodeInfo =
+                                    if (SPUtils.getInstance().getInt("weCom") == 1) {
+                                        AccessibilityUtil.findAllByClazz(rootNode, Views.ImageView)
+                                            .firstOrNull()!!
+                                    } else {
+                                        AccessibilityUtil.findAllByClazz(rootNode, Views.ImageView)
+                                            .lastOrNull()!!
+                                    }
+                                AccessibilityUtil.performClick(firstAppNode)
+                            }
+
                         }
                     }
                 }

+ 21 - 16
app/src/main/java/org/yameida/worktool/service/MyLooper.kt

@@ -14,7 +14,6 @@ import org.yameida.worktool.model.ExecCallbackBean
 import org.yameida.worktool.model.WeworkMessageBean
 import org.yameida.worktool.model.WeworkMessageListBean
 import org.yameida.worktool.utils.FloatWindowHelper
-import org.yameida.worktool.utils.IWWAPIUtil
 import org.yameida.worktool.utils.StringFeatureUtil
 import java.nio.charset.StandardCharsets
 import java.util.*
@@ -94,21 +93,21 @@ object MyLooper {
         if (messageList.socketType == WeworkMessageListBean.SOCKET_TYPE_MESSAGE_CONFIRM) {
             return
         }
-        if (messageList.socketType == WeworkMessageListBean.SOCKET_TYPE_INTI) {
-            if (messageList.weworkSchema != SPUtils.getInstance().getString("weworkSchema")) {
-                SPUtils.getInstance().put("weworkSchema", messageList.weworkSchema)
-                IWWAPIUtil.init()
-            }
-            WeworkController.enableLoopRunning = true
-            getInstance().removeMessages(WeworkMessageBean.LOOP_RECEIVE_NEW_MESSAGE)
-            getInstance().sendMessage(Message.obtain().apply {
-                what = WeworkMessageBean.LOOP_RECEIVE_NEW_MESSAGE
-                obj = WeworkMessageBean().apply {
-                    type = WeworkMessageBean.LOOP_RECEIVE_NEW_MESSAGE
-                }
-            })
-            return
-        }
+//        if (messageList.socketType == WeworkMessageListBean.SOCKET_TYPE_INTI) {
+//            if (messageList.weworkSchema != SPUtils.getInstance().getString("weworkSchema")) {
+//                SPUtils.getInstance().put("weworkSchema", messageList.weworkSchema)
+//                IWWAPIUtil.init()
+//            }
+//            WeworkController.enableLoopRunning = true
+//            getInstance().removeMessages(WeworkMessageBean.LOOP_RECEIVE_NEW_MESSAGE)
+//            getInstance().sendMessage(Message.obtain().apply {
+//                what = WeworkMessageBean.LOOP_RECEIVE_NEW_MESSAGE
+//                obj = WeworkMessageBean().apply {
+//                    type = WeworkMessageBean.LOOP_RECEIVE_NEW_MESSAGE
+//                }
+//            })
+//            return
+//        }
         if (messageList.socketType == WeworkMessageListBean.SOCKET_TYPE_MESSAGE_LIST) {
             val confirm =
                 WeworkController.weworkService.webSocketManager.confirm(messageList)
@@ -305,6 +304,12 @@ object MyLooper {
             WeworkMessageBean.APPLY_HARASS_RULE -> {
                 WeworkController.applyHarassRules(message)
             }
+            WeworkMessageBean.SWITCH_WE_COM -> {
+                WeworkController.switchWeCom(message)
+            }
+            WeworkMessageBean.INIT->{
+                WeworkController.init(message)
+            }
         }
     }
 }

+ 27 - 2
app/src/main/java/org/yameida/worktool/service/WeworkController.kt

@@ -1,10 +1,12 @@
 package org.yameida.worktool.service
 
 import com.blankj.utilcode.util.LogUtils
-import org.yameida.worktool.Demo
+import org.yameida.worktool.Constant
 import org.yameida.worktool.annotation.RequestMapping
 import org.yameida.worktool.model.ExecCallbackBean
 import org.yameida.worktool.model.WeworkMessageBean
+import org.yameida.worktool.utils.AccessibilityUtil
+import org.yameida.worktool.utils.Views
 
 /**
  * 企业微信客服端反转
@@ -172,7 +174,14 @@ object WeworkController {
     @RequestMapping
     fun test(message: WeworkMessageBean? = null) {
         LogUtils.d(message)
-        Demo.test(true)
+        val selectListView = AccessibilityUtil.findOneByClazz(getRoot(), Views.RecyclerView)
+        val searchResult = AccessibilityUtil.findAllByTextRegex(
+            selectListView,
+            "企业微信",
+            timeout = Constant.CHANGE_PAGE_INTERVAL * 3,
+            root = false
+        )
+        val accessibilityNodeInfo = searchResult[0]
     }
 
     /**
@@ -736,5 +745,21 @@ object WeworkController {
         return WeworkGetImpl.getCorpList(message)
     }
 
+    /**
+     * 切换企业微信
+     * @see WeworkMessageBean.GET_CORP_LIST
+     */
+    @RequestMapping
+    fun switchWeCom(message: WeworkMessageBean):Boolean{
+        return WeworkOperationImpl.switchWeCom(message)
+    }
 
+    /**
+     * 初始化
+     * @see WeworkMessageBean.GET_CORP_LIST
+     */
+    @RequestMapping
+    fun init(message: WeworkMessageBean):Boolean{
+        return WeworkOperationImpl.init(message)
+    }
 }

+ 8 - 0
app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt

@@ -104,6 +104,14 @@ object WeworkLoopImpl {
             if (childCount == 4 || childCount == 5) {
                 if (item.parent != null && item.parent.childCount > 1) {
                     LogUtils.d("通讯录有红点")
+//                    WeworkController.weworkService.webSocketManager.send(
+//                        WeworkMessageBean(
+//                            WeworkMessageBean.ADD_FRIEND,
+//                            SPUtils.getInstance().getInt("weCom"),
+//                            1,
+//                            null
+//                        )
+//                    )
                     AccessibilityUtil.performClick(item)
                     val hasRecommendFriend = AccessibilityUtil.findOneByText(
                         getRoot(),

+ 75 - 1
app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt

@@ -1,10 +1,13 @@
 package org.yameida.worktool.service
 
+import android.content.Intent
 import android.graphics.Bitmap
 import android.view.accessibility.AccessibilityNodeInfo
 import com.blankj.utilcode.util.*
 import com.github.yoojia.qrcode.qrcode.QRCodeDecoder
 import com.lzy.okgo.OkGo
+import com.xuexiang.xupdate.utils.UpdateUtils.startActivity
+import kotlinx.android.synthetic.main.activity_listen.*
 import org.yameida.worktool.Constant
 import org.yameida.worktool.model.ExecCallbackBean
 import org.yameida.worktool.model.WeworkMessageBean
@@ -3948,6 +3951,21 @@ object WeworkOperationImpl {
         timeout: Long = 5000
     ): SelectResult {
         val selectResult = SelectResult()
+        if (SPUtils.getInstance().getInt("num") == 2) {
+            sleep(Constant.POP_WINDOW_INTERVAL)
+            val aList = AccessibilityUtil.findAllByText(
+                WeworkController.weworkService.rootInActiveWindow,
+                "企业微信"
+            )
+            if (aList.size == 2) {
+                if (1 == SPUtils.getInstance().getInt("weCom")) {
+                    AccessibilityUtil.performClick(aList.firstOrNull())
+                } else {
+                    AccessibilityUtil.performClick(aList.lastOrNull())
+                }
+            }
+            sleep(Constant.POP_WINDOW_INTERVAL)
+        }
         if (AccessibilityUtil.findOneByText(
                 getRoot(),
                 "选择联系人",
@@ -5935,11 +5953,18 @@ object WeworkOperationImpl {
                             "",
                             startTime
                         )
+                        return true
                     }
                 }
             }
         }
-        return true
+        uploadCommandResult(
+            message,
+            ExecCallbackBean.ERROR_OTHER,
+            "",
+            startTime
+        )
+        return false
     }
 
     fun settingAlarm(message: WeworkMessageBean): Boolean {
@@ -6425,7 +6450,56 @@ object WeworkOperationImpl {
             exact = true
         )
         AccessibilityUtil.performClick(complete)
+        uploadCommandResult(
+            message,
+            ExecCallbackBean.SUCCESS,
+            "",
+            System.currentTimeMillis()
+        )
         return true
     }
 
+    fun switchWeCom(message: WeworkMessageBean): Boolean {
+        Utils.getApp().packageManager.getLaunchIntentForPackage(Constant.PACKAGE_NAMES)
+            ?.apply {
+                this.flags = Intent.FLAG_ACTIVITY_NEW_TASK
+                startActivity(this)
+                sleep(Constant.POP_WINDOW_INTERVAL)
+                // 查找并点击第一个应用
+                val rootNode = WeworkController.weworkService.rootInActiveWindow
+                var aa = AccessibilityUtil.findAllByClazz(rootNode, Views.ImageView)
+                val firstAppNode: AccessibilityNodeInfo = if (message.weCom == 1) {
+                    AccessibilityUtil.findAllByClazz(rootNode, Views.ImageView).firstOrNull()!!
+                } else {
+                    AccessibilityUtil.findAllByClazz(rootNode, Views.ImageView).lastOrNull()!!
+                }
+                AccessibilityUtil.performClick(firstAppNode)
+                SPUtils.getInstance().put("weCom", message.weCom)
+                WeworkController.weworkService.webSocketManager.send(
+                    WeworkMessageBean(
+                        WeworkMessageBean.WE_COM_TYPE,
+                        SPUtils.getInstance().getInt("weCom"),
+                        null,
+                        null
+                    )
+                )
+                return true
+            }
+        return false
+    }
+
+    fun init(message: WeworkMessageBean): Boolean {
+        if (message.weworkSchema != SPUtils.getInstance().getString("weworkSchema")) {
+            SPUtils.getInstance().put("weworkSchema", message.weworkSchema)
+            IWWAPIUtil.init()
+        }
+        WeworkController.enableLoopRunning = true
+        uploadCommandResult(
+            message,
+            ExecCallbackBean.SUCCESS,
+            "",
+            System.currentTimeMillis()
+        )
+        return true
+    }
 }

+ 19 - 1
app/src/main/java/org/yameida/worktool/service/WeworkService.kt

@@ -16,6 +16,7 @@ import okhttp3.WebSocket
 import okhttp3.WebSocketListener
 import org.yameida.worktool.Constant
 import org.yameida.worktool.Demo
+import org.yameida.worktool.model.WeworkMessageBean
 import org.yameida.worktool.observer.MultiFileObserver
 import org.yameida.worktool.utils.WebSocketManager
 import kotlin.concurrent.thread
@@ -130,6 +131,16 @@ class WeworkService : AccessibilityService() {
             val workVersion = SPUtils.getInstance().getString("workVersion", "")
             val deviceRooted = SPUtils.getInstance().getBoolean("deviceRooted", false)
             val hook = SPUtils.getInstance().getBoolean("hook", false)
+            if (WeworkController.weworkService.rootInActiveWindow != null && WeworkController.weworkService.rootInActiveWindow.packageName == Constant.PACKAGE_NAMES) {
+                WeworkController.weworkService.webSocketManager.send(
+                    WeworkMessageBean(
+                        WeworkMessageBean.WE_COM_TYPE,
+                        SPUtils.getInstance().getInt("weCom"),
+                        SPUtils.getInstance().getInt("num"),
+                        null
+                    )
+                )
+            }
             LogUtils.i("连接建立: $robotId appVersion: $appVersion workVersion: $workVersion deviceRooted: $deviceRooted hook: $hook")
             log("连接建立: $robotId appVersion: $appVersion workVersion: $workVersion deviceRooted: $deviceRooted hook: $hook")
             LogUtils.i("设置自动跳转企业微信")
@@ -137,7 +148,14 @@ class WeworkService : AccessibilityService() {
         }
 
         override fun onMessage(webSocket: WebSocket, text: String) {
-            LogUtils.i("onMessage: ${ if (text.length > 1000) (text.substring(0, 1000) + "...") else text }")
+            LogUtils.i(
+                "onMessage: ${
+                    if (text.length > 1000) (text.substring(
+                        0,
+                        1000
+                    ) + "...") else text
+                }"
+            )
             try {
                 MyLooper.onMessage(webSocket, text)
             } catch (e: Exception) {