Browse Source

1.添加注释。

2.移除多余方法。
master
wangwanlei 11 months ago
parent
commit
a5b220ff3c

+ 8
- 2
app/src/main/java/com/xhly/manageapp/ManageApplication.kt View File

@@ -2,6 +2,7 @@ package com.xhly.manageapp
2 2
 
3 3
 
4 4
 import android.app.csdk.CSDKManager
5
+import android.os.Build
5 6
 import androidx.multidex.MultiDexApplication
6 7
 import com.hjq.toast.Toaster
7 8
 import com.xhly.corelib.utils.ModelNameUtils
@@ -226,7 +227,12 @@ class ManageApplication : MultiDexApplication() {
226 227
             if (ModelNameUtils.IS_LianxX505f()) {
227 228
                 return csdkManager?.getDeviceInfo(type)
228 229
             }
229
-            return "0"
230
+            val serial = Build.SERIAL
231
+            return if (serial.isNullOrBlank()){
232
+                "0"
233
+            }else{
234
+                serial
235
+            }
230 236
         }
231 237
 
232 238
         /**
@@ -262,7 +268,7 @@ class ManageApplication : MultiDexApplication() {
262 268
          */
263 269
         fun enableWifiWhiteList(enable: Boolean) {
264 270
             if (ModelNameUtils.IS_LianxX505f()) {
265
-                //csdkManager?.enableWifiWhiteList(enable)
271
+                csdkManager?.enableWifiWhiteList(enable)
266 272
             }
267 273
         }
268 274
 

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

@@ -151,7 +151,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
151 151
         } catch (e: Exception) {
152 152
             LogShow("没有数据")
153 153
         }
154
-        requestPermissionAndShotView()
155 154
     }
156 155
 
157 156
     private fun updateMcApp() {
@@ -492,28 +491,11 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
492 491
         LogShow("MainActivity被销毁")
493 492
     }
494 493
 
495
-    /**
496
-     * 请求运行时权限
497
-     */
498
-    @SuppressLint("CheckResult")
499
-    private fun requestPermissionAndShotView() {
500
-        var iccid = ""
501
-        val rxPermissions = RxPermissions(this)
502
-        var request = rxPermissions.request(Manifest.permission.READ_PHONE_STATE)
503
-        request.subscribe({ granted: Boolean ->
504
-            if (granted) {
505
-
506
-            }
507
-        }, {
508
-
509
-        })
510
-    }
511
-
512 494
 
513 495
     private fun startWorkManager() {
514 496
         WorkManager.getInstance(this).cancelAllWork()
515 497
         // 周期性任务时间最少15分钟 所以除以实际周期的时间  看需要加入几个任务
516
-        val taskList = arrayListOf(5, 10)
498
+        val taskList = arrayListOf(0,5, 10)
517 499
         for (taskNo in taskList) {
518 500
             val request = PeriodicWorkRequest
519 501
                 // 最少15分钟 PeriodicWorkRequest

+ 2
- 2
app/src/main/java/com/xhly/manageapp/utils/StrategyUtils.kt View File

@@ -83,7 +83,7 @@ object StrategyUtils {
83 83
                 }
84 84
 
85 85
                 Const.DEVICETYPE5 -> {
86
-
86
+                    //TODO 需要处理短信和电话
87 87
                 }
88 88
 
89 89
                 Const.DEVICETYPE6 -> {
@@ -209,7 +209,7 @@ object StrategyUtils {
209 209
             }
210 210
             return true
211 211
         } catch (e: Exception) {
212
-            LogShow("问题是"+e.toString())
212
+            LogShow("问题是" + e.toString())
213 213
             return true
214 214
         }
215 215
     }

+ 12
- 1
app/src/main/java/com/xhly/manageapp/workmanager/TimingWorker.kt View File

@@ -34,6 +34,10 @@ class TimingWorker(context: Context, workerParams: WorkerParameters) :
34 34
         SharedPreferencesUtils.getInstance(context)
35 35
     }
36 36
 
37
+    companion object{
38
+        private var lastTime=0L
39
+    }
40
+
37 41
     override fun doWork(): Result {
38 42
         val result: Result = Result.success()
39 43
         val logService = RetrofitService.create<LogService>()
@@ -76,7 +80,14 @@ class TimingWorker(context: Context, workerParams: WorkerParameters) :
76 80
         val dataList = AppUtils.GetAppList(applicationContext)
77 81
         val instance = Calendar.getInstance()
78 82
         instance.set(Calendar.MILLISECOND, 0)
79
-        val timeInMillis = instance.timeInMillis - 1000 * 60 * 5
83
+        val currentTime = instance.timeInMillis
84
+        if (lastTime==0L){
85
+            lastTime=currentTime
86
+        }else{
87
+            LogShow("上次时间"+ lastTime.toFormat()+"|||本次时间"+currentTime.toFormat())
88
+            lastTime=currentTime
89
+        }
90
+        val timeInMillis = currentTime - 1000 * 60 * 5
80 91
         val usageManager =
81 92
             applicationContext.getSystemService(AppCompatActivity.USAGE_STATS_SERVICE) as UsageStatsManager
82 93
         val startList = arrayListOf<LogAppStartBean>()

Loading…
Cancel
Save