Explorar el Código

1.禁止锁屏。

2.每次执行下载任务都先取消之前的下载和安装任务。
20241218TB223FC(测试jar包)
wangwanlei hace 8 meses
padre
commit
550a4b399e

+ 9
- 0
app/src/main/java/com/xhly/manageapp/ManageApplication.kt Ver fichero

@@ -686,6 +686,15 @@ class ManageApplication : MultiDexApplication() {
686 686
                 csdkManager?.enableOverlayWindow(pkg,enableFlag)
687 687
             }
688 688
         }
689
+
690
+        /**
691
+         * 设置锁屏模式 0:取消解锁模式 1:滑动解锁
692
+         */
693
+        fun setLockScreenMode(enableFlag: Int=0){
694
+            if (ModelNameUtils.IS_LianxX505f()||ModelNameUtils.IS_LianxX6e6f()) {
695
+                csdkManager?.setLockScreenMode(enableFlag)
696
+            }
697
+        }
689 698
     }
690 699
 
691 700
     override fun onCreate() {

+ 2
- 0
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt Ver fichero

@@ -314,6 +314,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(),Download
314 314
                modelList?.let {
315 315
                    //如果已经进入商店则不显示
316 316
                    if (!Const.startAppStoreFlag){
317
+                       DownLoadUtils.destroyDownLoad()
318
+                       InstallUtils.destroyInstallUtils()
317 319
                        //获得必装应用,未安装或者版本较低则更新,先删除目录中的文件
318 320
                        val rxPermissions = RxPermissions(this@MainActivity)
319 321
                        rxPermissions.request(Manifest.permission.REQUEST_INSTALL_PACKAGES)

+ 6
- 2
app/src/main/java/com/xhly/manageapp/utils/DownLoadUtils.kt Ver fichero

@@ -42,7 +42,7 @@ object DownLoadUtils {
42 42
         LogShow("添加下载任务"+savepath)
43 43
         var isHave = false
44 44
         for (element in queue) {
45
-            if (element.tag === tag) {
45
+            if (element.tag == tag) {
46 46
                 isHave = true
47 47
             }
48 48
         }
@@ -57,13 +57,16 @@ object DownLoadUtils {
57 57
     }
58 58
 
59 59
     private fun downloadAction() {
60
+        LogShow("开始下载任务"+ isRunning)
60 61
         if (isRunning) {
61 62
             return
62 63
         }
63 64
         if (coroutineScope==null){
64 65
             coroutineScope = CoroutineScope(Dispatchers.IO)
65 66
         }
67
+        LogShow("开始创建协程下载任务"+ queue.size)
66 68
         coroutineScope?.launch {
69
+            LogShow("创建协程成功,进行下载任务"+ queue.size)
67 70
             while (queue.size > 0) {
68 71
                 isRunning = true
69 72
                 val downItem = queue.peek()
@@ -84,8 +87,8 @@ object DownLoadUtils {
84 87
                             }
85 88
 
86 89
                             override fun onSuccess(call: Download.Call, response: Download.Response) {
87
-                                LogShow("下载成功"+downItem.savepath)
88 90
                                 queue.poll()
91
+                                LogShow("下载成功"+downItem.savepath+"|||"+ queue.size)
89 92
                                 for (downloadCallback in callbackList) {
90 93
                                     downloadCallback.onSuccess(downItem)
91 94
                                 }
@@ -127,6 +130,7 @@ object DownLoadUtils {
127 130
 
128 131
     fun destroyDownLoad(){
129 132
         coroutineScope?.cancel()
133
+        coroutineScope=null
130 134
         isRunning=false
131 135
         queue.clear()
132 136
     }

+ 1
- 0
app/src/main/java/com/xhly/manageapp/utils/InstallUtils.kt Ver fichero

@@ -81,6 +81,7 @@ object InstallUtils {
81 81
         isRunning= false
82 82
         isInstalling = false
83 83
         coroutineScope?.cancel()
84
+        coroutineScope=null
84 85
         LogShow("任务取消")
85 86
     }
86 87
 }

+ 2
- 1
app/src/main/java/com/xhly/manageapp/utils/StrategyUtils.kt Ver fichero

@@ -392,7 +392,7 @@ object StrategyUtils {
392 392
               ManageApplication.clearAppWhiteRule()
393 393
               //关闭网络白名单
394 394
               ManageApplication.setUrlWhiteListEnable(false)
395
-
395
+              ManageApplication.setLockScreenMode(1)
396 396
               //清除数据
397 397
               WorkManager.getInstance(context).cancelAllWork()
398 398
               context.deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
@@ -447,6 +447,7 @@ object StrategyUtils {
447 447
             ManageApplication.hideHomeSoftKey(true)
448 448
             ManageApplication.hideMenuSoftKey(true)
449 449
             ManageApplication.enableAccessibility()
450
+            ManageApplication.setLockScreenMode()
450 451
             ManageApplication.setCustomLauncher(
451 452
                 Const.CURRENTAPPPKG,
452 453
                 Const.CURRENTAPPPKG + ".ui.ManageActivity"

Loading…
Cancelar
Guardar