Browse Source

1.每次更新策略时都刷新时间。

2025_1_7x505f
wangwanlei 2 weeks ago
parent
commit
6368d70658

+ 24
- 9
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

@@ -359,6 +359,15 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
359 359
                         LogShow("冻结失败" + e.toString())
360 360
                     }
361 361
                     unInstallAppList.clear()
362
+                    var hasapp = 1
363
+                    try {
364
+                        val strategyBean =
365
+                            spUtils.getFromJson(Const.STRATEGYBEANKEY, StrategyBean::class.java) as StrategyBean
366
+                        //获得平板策略是否使用app策略
367
+                        hasapp = strategyBean.hasapp
368
+                    }catch (e:Exception){
369
+
370
+                    }
362 371
                     if (modelList.size > 0) {
363 372
                         ManageApplication.disableInstallation(true)
364 373
                         //modelList为0表示未打开应用策略,不删除应用,并且打开应用安装权限,其余情况关闭
@@ -373,8 +382,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
373 382
                             }
374 383
                         }
375 384
                     } else {
376
-                        //modelList为0表示未打开应用策略,所以打开打开应用安装权限
377
-                        ManageApplication.disableInstallation(false)
385
+                        //hasapp==0表示未打开应用策略,所以打开打开应用安装权限,使用策略并未空则不允许安装应用
386
+                        if (hasapp==0){
387
+                            ManageApplication.disableInstallation(false)
388
+                        }else{
389
+                            ManageApplication.disableInstallation(true)
390
+                        }
378 391
                     }
379 392
                 }
380 393
             }
@@ -618,9 +631,14 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
618 631
 
619 632
         viewModel.viewModelScope.launch {
620 633
             viewModel.autoAppData.collect {
634
+                lifecycleScope.launch {
635
+                    withContext(Dispatchers.IO){
636
+                        delay(10000)
637
+                    }
638
+                    mBinding.flayoutRoot.visibility = View.GONE
639
+                }
621 640
                 it?.let {
622 641
                     if (!netAutoAppFlag || isDestroyFlag) {
623
-                        mBinding.flayoutRoot.visibility = View.GONE
624 642
                         return@collect
625 643
                     } else {
626 644
                         netAutoAppFlag = false
@@ -634,7 +652,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
634 652
                         //如果地址为空并且请求为true则不跳转,否则跳转
635 653
                         try {
636 654
                             if ((it.authUrl.isNullOrEmpty() || it.appPackage.isNullOrEmpty()) && it.netSucessFlag) {
637
-                                mBinding.flayoutRoot.visibility = View.GONE
638 655
                                 //请求成功但地址为空,不跳转
639 656
                                 canClickFlag = true
640 657
                                 autoAppFlag = false
@@ -666,18 +683,14 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
666 683
                                 } else {
667 684
                                     //其余情况都允许触控
668 685
                                     canClickFlag = true
669
-                                    mBinding.flayoutRoot.visibility = View.GONE
670 686
                                 }
671 687
                             } else {
672
-                                mBinding.flayoutRoot.visibility = View.GONE
673 688
                                 canClickFlag = true
674 689
                             }
675 690
                         } catch (e: Exception) {
676 691
                             canClickFlag = true
677
-                            mBinding.flayoutRoot.visibility = View.GONE
678 692
                         }
679 693
                     } else {
680
-                        mBinding.flayoutRoot.visibility = View.GONE
681 694
                         canClickFlag = true
682 695
                         autoAppFlag = false
683 696
                         startIntentActivity(MainActivity().javaClass)
@@ -810,7 +823,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
810 823
             canClickFlag = true
811 824
             LogShow("跳转问题是$e")
812 825
         }
813
-        mBinding.flayoutRoot.visibility = View.GONE
814 826
     }
815 827
 
816 828
     private fun showSucessToast() {
@@ -1119,6 +1131,9 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>(), Downloa
1119 1131
         viewModel.postAppNetWhiteList()
1120 1132
         updatePadInfo()
1121 1133
         updateAppInstallInfo()
1134
+        //自动同时一次时间
1135
+        viewModel.postSyncTime()
1136
+        lastTimeLong = System.currentTimeMillis()
1122 1137
     }
1123 1138
 
1124 1139
     private fun updateAppInstallInfo() {

+ 2
- 1
app/src/main/java/com/xhly/manageapp/viewmodel/BaseViewModel.kt View File

@@ -186,7 +186,8 @@ open class BaseViewModel : CommonBaseViewModel() {
186 186
                 val obj = postSyncTime.obj
187 187
                 val l = obj + (endTime - startTime) / 2
188 188
                 LogShow("设置的时间是"+SystemClock.getDateString(l))
189
-                timeResult.value = l
189
+                /*timeResult.value = l*/
190
+                timeResult.value = obj
190 191
             } else {
191 192
                 if (!postSyncTime.msg.isNullOrEmpty()) {
192 193
                     netMessage.value = postSyncTime.msg

+ 8
- 8
app/src/main/res/layout/activity_main.xml View File

@@ -84,14 +84,6 @@
84 84
                 android:layout_marginTop="24dp"
85 85
                 android:overScrollMode="never" />
86 86
         </LinearLayout>
87
-        <LinearLayout
88
-            android:id="@+id/flayout_root"
89
-            android:layout_width="match_parent"
90
-            android:layout_height="match_parent"
91
-            android:background="@drawable/main_bg"
92
-            android:gravity="center_horizontal"
93
-            android:orientation="vertical"
94
-            />
95 87
         <LinearLayout
96 88
             android:id="@+id/lock_llayout"
97 89
             android:layout_width="match_parent"
@@ -187,5 +179,13 @@
187 179
                 android:textColor="#253A70"
188 180
                 android:textSize="8sp" />
189 181
         </LinearLayout>
182
+        <LinearLayout
183
+            android:id="@+id/flayout_root"
184
+            android:layout_width="match_parent"
185
+            android:layout_height="match_parent"
186
+            android:background="@drawable/main_bg"
187
+            android:gravity="center_horizontal"
188
+            android:orientation="vertical"
189
+            />
190 190
     </FrameLayout>
191 191
 </LinearLayout>

Loading…
Cancel
Save