Browse Source

1.增加UserBean信息

2.增加应用网络白名单。
20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
84041d7b7e

+ 25
- 1
app/src/main/java/com/xhly/manageapp/ManageApplication.kt View File

@@ -505,6 +505,28 @@ class ManageApplication : MultiDexApplication() {
505 505
                 }
506 506
             }
507 507
         }
508
+        /**
509
+         * 添加网络应用白名单
510
+         */
511
+        fun addAppWhiteRule(pkgList: ArrayList<String>){
512
+            clearAppWhiteRule()
513
+            if (ModelNameUtils.IS_LianxX505f()) {
514
+                pkgList.forEach {
515
+                    csdkManager?.AddAppWhiteRule(it)
516
+                }
517
+            }
518
+        }
519
+        /**
520
+         * 移除网络应用白名单
521
+         */
522
+        fun clearAppWhiteRule(){
523
+            if (ModelNameUtils.IS_LianxX505f()) {
524
+                csdkManager?.ClearAppRules()
525
+                //不移除自己和商店
526
+                csdkManager?.AddAppWhiteRule(Const.CURRENTAPPPKG)
527
+                csdkManager?.AddAppWhiteRule(Const.STOREAPPPKG)
528
+            }
529
+        }
508 530
     }
509 531
 
510 532
     override fun onCreate() {
@@ -530,9 +552,11 @@ class ManageApplication : MultiDexApplication() {
530 552
             addInstallPackageWhiteList(
531 553
                 arrayListOf(
532 554
                     Const.CURRENTAPPPKG,
533
-                    "com.xhkjedu.xh_control_appstore"
555
+                    Const.STOREAPPPKG
534 556
                 )
535 557
             )
558
+            //给自己加入网络白名单
559
+            addAppWhiteRule(arrayListOf(Const.CURRENTAPPPKG))
536 560
             //允许运行时权限,禁止状态栏下拉,屏蔽底部虚拟键。
537 561
            // setRuntimePermissions(true)
538 562
             disableStatusBarPanel(true)

+ 96
- 11
app/src/main/java/com/xhly/manageapp/bean/user/UserBean.kt View File

@@ -6,36 +6,121 @@ class UserBean {
6 6
     //记录登录返回的msg
7 7
     var xhlyLoginMessage:String?=""
8 8
 
9
-    var userid = 1L
10
-    var schoolid = 1L
11
-
12
-    //区域码
13
-    var regionid = 1L
9
+    /**
10
+     * id
11
+     */
12
+    var userid = 0L
14 13
 
14
+    /**
15
+     * 姓名
16
+     */
15 17
     var username: String? = null
18
+
19
+    /**
20
+     * 账号
21
+     */
16 22
     var loginname: String? = null
17
-    var classid: Long? = null
23
+
24
+    /**
25
+     * 密码
26
+     */
18 27
     var loginpwd:String=""
28
+    /**
29
+     *手机号
30
+     */
31
+    var userphone:String?=null
32
+    /**
33
+     * 学号
34
+     */
35
+    var studentno:String?=null
19 36
 
37
+    /**
38
+     * 身份证号
39
+     */
40
+    var cardid:String?=null
20 41
     /**
21 42
      * 管控状态1管控中2解除管控
22 43
      */
23 44
     var control=1
45
+    /**
46
+     * 是否启用1启用2禁用
47
+     */
48
+    var enabled=0
24 49
 
25 50
     /**
26
-     *手机号
51
+     *是否删除0未删除1已删除
27 52
      */
28
-    var userphone:String?=null
53
+    var deleted=0
29 54
 
30 55
     /**
31
-     * 版本
56
+     * 版本(不是app的版本号)
32 57
      */
33 58
     var rversion=0L
34 59
 
60
+
35 61
     /**
36
-     * Xh-Token-Key
62
+     * tokenKey
37 63
      */
38 64
     var Xh_Token_Key:String?=null
39
-
65
+    /**
66
+     * token
67
+     */
40 68
     var Xh_Token_Value:String?=null
69
+
70
+    /**
71
+     *班级id
72
+     */
73
+    var classid: Long? = null
74
+
75
+    /**
76
+     *学校id
77
+     */
78
+    var schoolid = 0L
79
+
80
+    /**
81
+     * 区域id
82
+     */
83
+    var regionid = 0L
84
+
85
+    /**
86
+     * sn 设备号
87
+     */
88
+    var sn:String?=""
89
+    /**
90
+     *是否强制绑定:1是0否
91
+     */
92
+    var forceBind=0
93
+    /**
94
+     *区域码
95
+     */
96
+    var regionCode=0
97
+    /**
98
+     * 区域名称
99
+     */
100
+    var regionName:String?=null
101
+
102
+    /**
103
+     * 认证密钥
104
+     */
105
+    var authKey:String?=null
106
+    /**
107
+     *认证地址
108
+     */
109
+    var authUrl:String?=null
110
+    /**
111
+     *认证类型:1账号2学号3手机号码4身份证号
112
+     */
113
+    var authType=0
114
+    /**
115
+     *学校编码
116
+     */
117
+    var schoolCode:String?=null
118
+    /**
119
+     *学校名称
120
+     */
121
+    var schoolName:String?=null
122
+    /**
123
+     *班级名称
124
+     */
125
+    var classname:String?=null
41 126
 }

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

@@ -10,7 +10,9 @@ import android.content.IntentFilter
10 10
 import android.content.pm.PackageManager
11 11
 import android.graphics.Color
12 12
 import android.graphics.drawable.Drawable
13
+import android.os.Build
13 14
 import android.provider.Settings
15
+import android.text.TextUtils
14 16
 import android.view.View
15 17
 import android.widget.Button
16 18
 import android.widget.EditText
@@ -44,9 +46,9 @@ import com.xhly.manageapp.AppAdapter
44 46
 import com.xhly.manageapp.ManageApplication
45 47
 import com.xhly.manageapp.bean.EventLog
46 48
 import com.xhly.manageapp.bean.SocketMsgBean
47
-import com.xhly.manageapp.bean.log.UpdateBean
48 49
 import com.xhly.manageapp.bean.log.LogPushBean
49 50
 import com.xhly.manageapp.bean.log.LogdOperateBean
51
+import com.xhly.manageapp.bean.log.UpdateBean
50 52
 import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
51 53
 import com.xhly.manageapp.bean.strategy.StrategyBean
52 54
 import com.xhly.manageapp.bean.user.UserBean
@@ -74,8 +76,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
74 76
     private var mMyInstallReceiver: AppInstallReceiver? = null
75 77
     private var dataList: ArrayList<AppInfo> = arrayListOf()
76 78
     private var userBean: UserBean? = null
77
-    private var timer: Timer?=null
78
-    private val currentSpUtils by lazy {  CurrentAppSharedPreferencesUtils.getInstance(this) }
79
+    private var timer: Timer? = null
80
+    private val currentSpUtils by lazy { CurrentAppSharedPreferencesUtils.getInstance(this) }
79 81
     override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
80 82
 
81 83
     override fun initData() {
@@ -88,7 +90,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
88 90
         }
89 91
         adapter = AppAdapter(this, dataList)
90 92
         mBinding.rv.layoutManager = GridLayoutManager(this, 6, GridLayoutManager.VERTICAL, false)
91
-        adapter?.changePwdListener=getChangeCodeListener()
93
+        adapter?.changePwdListener = getChangeCodeListener()
92 94
         mBinding.rv.adapter = adapter
93 95
         updateAppRv()
94 96
         // checkAccessibility(this)
@@ -103,29 +105,37 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
103 105
 
104 106
         viewModel.listAppData.observe(this) { modelList ->
105 107
             //存储商店应用包名到本地
106
-            val appNameList= arrayListOf<String>()
108
+            val appNameList = arrayListOf<String>()
109
+            val whiteList= arrayListOf<String>()
107 110
             modelList.forEach {
108 111
                 appNameList.add(it.appPackage)
112
+                if (it.whited==1){
113
+                   whiteList.add(it.appPackage)
114
+                }
109 115
             }
110
-            spUtils.saveJson(Const.APPSTOREKEY,appNameList)
116
+            ManageApplication.addAppWhiteRule(whiteList)
117
+            spUtils.saveJson(Const.APPSTOREKEY, appNameList)
111 118
             //获得应用集合,必装应用和推荐应用,再加上预装应用,其余应用需要静默卸载,必装应用需要进行静默下载和安装。安装应用从forceapp接口获取
112 119
             val appList = AppUtils.GetAppList(this)
113
-            val firstAppList= arrayListOf<String>()
120
+            val firstAppList = arrayListOf<String>()
114 121
             try {
115 122
                 //获得预装应用的包名
116 123
                 val currentList =
117
-                    currentSpUtils.getFromJson(Const.FIRSTAPPLIST, ArrayList<String>().javaClass) as ArrayList<String>
124
+                    currentSpUtils.getFromJson(
125
+                        Const.FIRSTAPPLIST,
126
+                        ArrayList<String>().javaClass
127
+                    ) as ArrayList<String>
118 128
                 firstAppList.addAll(currentList)
119
-            }catch (e:Exception){
120
-               LogShow("冻结失败"+e.toString())
129
+            } catch (e: Exception) {
130
+                LogShow("冻结失败" + e.toString())
121 131
             }
122 132
             appList.forEach { app ->
123 133
                 val filter = modelList.filter { it.appPackage.equals(app.packageName) }
124 134
                 val appInfos = firstAppList.filter { app.packageName.equals(it) }
125 135
                 //接口列表以及初始化列表中不存在则将应用冻结或者卸载,目前是冻结
126
-                LogShow("${app.name},被冻结"+(filter.isEmpty() && appInfos.isEmpty()))
127
-                if (filter.isEmpty() && appInfos.isEmpty()){
128
-                   ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
136
+                LogShow("${app.name},被冻结" + (filter.isEmpty() && appInfos.isEmpty()))
137
+                if (filter.isEmpty() && appInfos.isEmpty()) {
138
+                    ManageApplication.setPackageEnabled(app.packageName, (filter.isNotEmpty()))
129 139
                 }
130 140
             }
131 141
         }
@@ -176,7 +186,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
176 186
         viewModel.loginOutData.observe(this) {
177 187
             if (it) {
178 188
                 loginOut()
179
-            }else{
189
+            } else {
180 190
                 Toast(getString(R.string.codeerror))
181 191
             }
182 192
         }
@@ -191,37 +201,39 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
191 201
             initSchoolSet(it)
192 202
             updateAppRv()
193 203
         }
194
-        viewModel.wallpaperData.observe(this){
195
-            if (!it.hpath.isNullOrBlank()){
196
-                Glide.with(this).load(Const.URL1+it.hpath).placeholder(R.drawable.main_bg).error(R.drawable.main_bg).into(object:CustomViewTarget<LinearLayout,Drawable>(mBinding.root){
197
-                    override fun onLoadFailed(errorDrawable: Drawable?) {
198
-                        errorDrawable?.let {drawble->
199
-                            mBinding.root.background=drawble
204
+        viewModel.wallpaperData.observe(this) {
205
+            if (!it.hpath.isNullOrBlank()) {
206
+                Glide.with(this).load(Const.URL1 + it.hpath).placeholder(R.drawable.main_bg)
207
+                    .error(R.drawable.main_bg)
208
+                    .into(object : CustomViewTarget<LinearLayout, Drawable>(mBinding.root) {
209
+                        override fun onLoadFailed(errorDrawable: Drawable?) {
210
+                            errorDrawable?.let { drawble ->
211
+                                mBinding.root.background = drawble
212
+                            }
200 213
                         }
201
-                    }
202 214
 
203
-                    override fun onResourceCleared(placeholder: Drawable?) {
204
-                        placeholder?.let {drawble->
205
-                            mBinding.root.background=drawble
215
+                        override fun onResourceCleared(placeholder: Drawable?) {
216
+                            placeholder?.let { drawble ->
217
+                                mBinding.root.background = drawble
218
+                            }
206 219
                         }
207
-                    }
208 220
 
209
-                    override fun onResourceReady(
210
-                        resource: Drawable,
211
-                        transition: Transition<in Drawable>?
212
-                    ) {
213
-                        mBinding.root.background=resource
214
-                    }
215
-                })
221
+                        override fun onResourceReady(
222
+                            resource: Drawable,
223
+                            transition: Transition<in Drawable>?
224
+                        ) {
225
+                            mBinding.root.background = resource
226
+                        }
227
+                    })
216 228
             }
217 229
         }
218
-        viewModel.netWhiteListData.observe(this){
219
-           StrategyUtils.setNetWhiteList(it)
230
+        viewModel.netWhiteListData.observe(this) {
231
+            StrategyUtils.setNetWhiteList(it)
220 232
         }
221
-        viewModel.pwdResultData.observe(this){
222
-            if (it){
233
+        viewModel.pwdResultData.observe(this) {
234
+            if (it) {
223 235
                 unBindBlock()
224
-            }else{
236
+            } else {
225 237
                 Toast(getString(R.string.codeerror))
226 238
             }
227 239
         }
@@ -240,26 +252,26 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
240 252
         }
241 253
         mBinding.loginoutIv.setOnClickListener {
242 254
             val schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this@MainActivity)
243
-            if (schoolDeviceSetBean !=null&&schoolDeviceSetBean.logout==1){
255
+            if (schoolDeviceSetBean != null && schoolDeviceSetBean.logout == 1) {
244 256
                 //禁用注销
245 257
                 return@setOnClickListener
246
-            }else{
258
+            } else {
247 259
                 showEditDialog()
248 260
             }
249 261
         }
250 262
         mBinding.codeenterCv.setOnClickListener {
251 263
             //如果密码一致,则解锁
252 264
             val code = mBinding.lockEt.text.toString()
253
-            if (code.isNullOrBlank()){
265
+            if (code.isNullOrBlank()) {
254 266
                 return@setOnClickListener
255 267
             }
256 268
             ManageApplication.getDeviceInfo()?.let {
257
-                viewModel.postPwdDetail(code,it)
269
+                viewModel.postPwdDetail(code, it)
258 270
             }
259 271
         }
260 272
         onBackPressedDispatcher.addCallback {
261 273
             //屏蔽返回键
262
-           getLocation()
274
+            getLocation()
263 275
         }
264 276
     }
265 277
 
@@ -272,16 +284,16 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
272 284
         }
273 285
     }
274 286
 
275
-    private fun getChangeCodeListener():AppAdapter.ChangePwdListener{
276
-        return object :AppAdapter.ChangePwdListener{
287
+    private fun getChangeCodeListener(): AppAdapter.ChangePwdListener {
288
+        return object : AppAdapter.ChangePwdListener {
277 289
             override fun changeCode() {
278 290
                 val deviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this@MainActivity)
279
-                var showFlag=true
280
-                if (deviceSetBean!=null&&deviceSetBean.changePwd==0){
291
+                var showFlag = true
292
+                if (deviceSetBean != null && deviceSetBean.changePwd == 0) {
281 293
                     //学校设置是否禁止修改密码
282
-                    showFlag=false
294
+                    showFlag = false
283 295
                 }
284
-                if (showFlag){
296
+                if (showFlag) {
285 297
                     showChangeCodeDialog()
286 298
                 }
287 299
             }
@@ -298,22 +310,22 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
298 310
                     val enterTv = v.findViewById<TextView>(R.id.dialog_enter_tv)
299 311
                     val cancelTv = v.findViewById<TextView>(R.id.dialog_cancel_tv)
300 312
                     val editText = v.findViewById<EditText>(R.id.dialog_et)
301
-                    val oldCodeEt=v.findViewById<EditText>(R.id.dialog_oldcode_et)
302
-                    val newCodeEt=v.findViewById<EditText>(R.id.dialog_newcode_et)
313
+                    val oldCodeEt = v.findViewById<EditText>(R.id.dialog_oldcode_et)
314
+                    val newCodeEt = v.findViewById<EditText>(R.id.dialog_newcode_et)
303 315
                     enterTv.setOnClickListener {
304 316
                         val enterCode = editText.text.toString()
305 317
                         val oldCode = oldCodeEt.text.toString()
306 318
                         val newCode = newCodeEt.text.toString()
307
-                        if (!getTextFlag(enterCode)||!getTextFlag(oldCode)||!getTextFlag(newCode)){
319
+                        if (!getTextFlag(enterCode) || !getTextFlag(oldCode) || !getTextFlag(newCode)) {
308 320
                             Toast("密码不符合规则")
309 321
                             return@setOnClickListener
310 322
                         }
311
-                        if (oldCode.equals(newCode)){
323
+                        if (oldCode.equals(newCode)) {
312 324
                             Toast("新密码不能和旧密码一致。")
313 325
                             return@setOnClickListener
314 326
                         }
315 327
 
316
-                        if (!newCode.equals(enterCode)){
328
+                        if (!newCode.equals(enterCode)) {
317 329
                             Toast("两次输入的新密码不一致。")
318 330
                             return@setOnClickListener
319 331
                         }
@@ -323,7 +335,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
323 335
                             val userBean = spUtils.getFromJson(
324 336
                                 Const.USERINFO, UserBean().javaClass
325 337
                             ) as UserBean
326
-                            viewModel.postEditPwd(userBean.userid,newCode,oldCode)
338
+                            viewModel.postEditPwd(userBean.userid, newCode, oldCode)
327 339
                         } catch (e: Exception) {
328 340
 
329 341
                         }
@@ -336,10 +348,10 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
336 348
             .setAlign(CustomDialog.ALIGN.CENTER).show()
337 349
     }
338 350
 
339
-    private fun getTextFlag(code:String?):Boolean{
351
+    private fun getTextFlag(code: String?): Boolean {
340 352
         try {
341
-            return (!code.isNullOrBlank())&&code.length>=6&&code.length<=16
342
-        }catch (e:Exception){
353
+            return (!code.isNullOrBlank()) && code.length >= 6 && code.length <= 16
354
+        } catch (e: Exception) {
343 355
             return false
344 356
         }
345 357
     }
@@ -347,9 +359,17 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
347 359
     override fun onResume() {
348 360
         super.onResume()
349 361
         userBean?.let {
350
-            Const.USERID=it.userid
351
-            Const.USERNAME=it.username.toString()
362
+            Const.USERID = it.userid
363
+            Const.USERNAME = it.username.toString()
352 364
             viewModel.postDevicesetDetail(it.schoolid)
365
+            val name=StringBuffer()
366
+            if (!it.schoolName.isNullOrBlank()){
367
+                name.append(it.schoolName)
368
+            }
369
+            if (!it.classname.isNullOrBlank()){
370
+                name.append(it.classname)
371
+            }
372
+            mBinding.userschoolTv.text =name.toString()
353 373
         }
354 374
         viewModel.postWallpaperPad()
355 375
         viewModel.updateStrategy()
@@ -427,12 +447,19 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
427 447
     @SuppressLint("CheckResult")
428 448
     private fun getLocation() {
429 449
         val rxPermissions = RxPermissions(this)
450
+        //  Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS
430 451
         rxPermissions.request(
431
-            Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION,
432
-            Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS
452
+            Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION
433 453
         ).subscribe({
434 454
             if (it) {
435
-                SystemUtil.getLocation(this)
455
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
456
+                    rxPermissions.request(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
457
+                        .subscribe {
458
+                            SystemUtil.getLocation(this)
459
+                        }
460
+                } else {
461
+                    SystemUtil.getLocation(this)
462
+                }
436 463
             } else {
437 464
                 LogShow("没有权限")
438 465
             }
@@ -478,7 +505,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
478 505
     }
479 506
 
480 507
     private fun initSchoolSet(schoolDeviceSetBean: SchoolDeviceSetBean? = null) {
481
-        schoolDeviceSetBean?.let {bean->
508
+        schoolDeviceSetBean?.let { bean ->
482 509
             //是否启用截屏:1是0否
483 510
             ManageApplication.enableCaptureScreen(schoolDeviceSetBean.screenshots == 1)
484 511
             if (bean.forceBind == 1) {
@@ -496,28 +523,28 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
496 523
     }
497 524
 
498 525
     private fun startTimeTask(bean: SchoolDeviceSetBean) {
499
-        if (bean.remindDuration==1&&bean.duration>0){
526
+        if (bean.remindDuration == 1 && bean.duration > 0) {
500 527
             //如果设置的有时间则执行任务
501 528
             try {
502 529
                 timer?.cancel()
503
-                timer= Timer()
504
-            }catch (e:Exception){
530
+                timer = Timer()
531
+            } catch (e: Exception) {
505 532
 
506 533
             }
507 534
             timer?.let {
508
-                timer?.schedule( object : TimerTask() {
535
+                timer?.schedule(object : TimerTask() {
509 536
                     override fun run() {
510 537
                         // 在这里编写您的定时任务代码
511
-                        Toast(getString(R.string.durationtips)+"|||"+bean.duration)
538
+                        Toast(getString(R.string.durationtips) + "|||" + bean.duration)
512 539
                     }
513
-                },bean.duration*60*1000L,bean.duration*60*1000L)
540
+                }, bean.duration * 60 * 1000L, bean.duration * 60 * 1000L)
514 541
             }
515 542
         }
516 543
         //如果设置的有时间则取消所有任务
517
-        if (bean.remindDuration!=1){
518
-            if (timer!=null){
544
+        if (bean.remindDuration != 1) {
545
+            if (timer != null) {
519 546
                 timer?.cancel()
520
-                timer=null
547
+                timer = null
521 548
             }
522 549
         }
523 550
     }
@@ -674,21 +701,22 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
674 701
                 data.doEvent = EventLog.USBDISCONNECTEVENT
675 702
                 viewModel.eventLog(data)
676 703
             }
677
-            Const.ACCOUNTLOGINOUT->{
704
+
705
+            Const.ACCOUNTLOGINOUT -> {
678 706
                 loginOut()
679 707
             }
680 708
         }
681 709
     }
682 710
 
683
-    private fun postLogPush(pushType:Int){
684
-        val pushBean= LogPushBean()
685
-        pushBean.pushType=pushType
686
-        pushBean.pushObjid=Const.SCHOOLID
711
+    private fun postLogPush(pushType: Int) {
712
+        val pushBean = LogPushBean()
713
+        pushBean.pushType = pushType
714
+        pushBean.pushObjid = Const.SCHOOLID
687 715
         Const.USERID?.let {
688
-            pushBean.userids= longArrayOf(it)
716
+            pushBean.userids = longArrayOf(it)
689 717
         }
690 718
         Const.USERNAME?.let {
691
-            pushBean.pushObjname=it
719
+            pushBean.pushObjname = it
692 720
         }
693 721
         viewModel.postLogPushAdd(pushBean)
694 722
     }
@@ -706,7 +734,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
706 734
             dataList.addAll(appList)
707 735
             if (adapter == null) {
708 736
                 adapter = AppAdapter(this, dataList)
709
-                adapter?.changePwdListener=getChangeCodeListener()
737
+                adapter?.changePwdListener = getChangeCodeListener()
710 738
                 mBinding.rv.adapter = adapter
711 739
             }
712 740
             adapter?.let {
@@ -769,7 +797,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
769 797
                     titleTv.text = getString(R.string.exit)
770 798
                     enterTv.setOnClickListener {
771 799
                         val code = editText.text
772
-                        if ((!code.isNullOrBlank())&&code.length>=6&&code.length<=16) {
800
+                        if ((!code.isNullOrBlank()) && code.length >= 6 && code.length <= 16) {
773 801
                             dialog.dismiss()
774 802
                             try {
775 803
                                 val userBean = spUtils.getFromJson(
@@ -803,7 +831,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
803 831
                         titleTv.text = msgBean.title
804 832
                         contentTv.text = msgBean.content
805 833
                     } catch (e: Exception) {
806
-                        LogShow("解析失败"+e.toString())
834
+                        LogShow("解析失败" + e.toString())
807 835
                     }
808 836
                     closeBtn.setOnClickListener {
809 837
                         dialog.dismiss()
@@ -823,8 +851,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
823 851
         viewModel.eventLog(data)
824 852
         WorkManager.getInstance(this).cancelAllWork()
825 853
         deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
826
-        Const.USERID=null
827
-        Const.USERNAME=""
854
+        Const.USERID = null
855
+        Const.USERNAME = ""
828 856
         startIntentActivity(LoginActivity().javaClass)
829 857
         finish()
830 858
     }
@@ -832,9 +860,9 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
832 860
 
833 861
     override fun onDestroy() {
834 862
         super.onDestroy()
835
-        if (timer!=null){
863
+        if (timer != null) {
836 864
             timer?.cancel()
837
-            timer=null
865
+            timer = null
838 866
         }
839 867
         mMyInstallReceiver?.let {
840 868
             unregisterReceiver(it)

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

@@ -351,6 +351,8 @@ object StrategyUtils {
351 351
               ManageApplication.enableMassStorage(true)
352 352
               //允许OTG
353 353
               ManageApplication.setCustomOTG(true)
354
+              //关闭网络白名单
355
+              ManageApplication.setUrlWhiteListEnable(false)
354 356
               //设置默认启动器
355 357
               ManageApplication.setCustomLauncher("com.tblenovo.launcher","com.android.iotlauncher.IotLauncher")
356 358
           }catch (e:Exception){

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

@@ -56,7 +56,6 @@
56 56
                 android:layout_height="wrap_content"
57 57
                 android:layout_marginLeft="21dp"
58 58
                 android:layout_marginRight="21dp"
59
-                android:text="学校"
60 59
                 android:textColor="#798CB5"
61 60
                 android:textSize="15sp" />
62 61
 

+ 5
- 0
corelib/src/main/java/com/xhly/corelib/Const.kt View File

@@ -9,6 +9,11 @@ object Const {
9 9
      */
10 10
     const val CURRENTAPPPKG="com.xhkjedu.manageapp"
11 11
 
12
+    /**
13
+     * 商店包名
14
+     */
15
+    const val STOREAPPPKG="com.xhkjedu.xh_control_appstore"
16
+
12 17
     //用户id
13 18
     var USERID :Long?= 1L
14 19
 

+ 10
- 4
corelib/src/main/java/com/xhly/corelib/utils/SystemUtil.java View File

@@ -6,6 +6,7 @@ import android.content.Context;
6 6
 import android.content.pm.PackageInfo;
7 7
 import android.content.pm.PackageManager;
8 8
 import android.location.Location;
9
+import android.location.LocationListener;
9 10
 import android.location.LocationManager;
10 11
 import android.net.wifi.WifiInfo;
11 12
 import android.net.wifi.WifiManager;
@@ -262,13 +263,15 @@ public class SystemUtil {
262 263
     public static Location getLocation(Context context) {
263 264
         Location data = null;
264 265
         try {
265
-            LocationManager systemService = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
266
+            LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
266 267
                   String bestProvider = "";
267
-            List<String> providers = systemService.getProviders(true);
268
+            List<String> providers = locationManager.getProviders(true);
268 269
             if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
269
-                    ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
270
+                    ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
271
+               &&ActivityCompat.checkSelfPermission(context,Manifest.permission.ACCESS_BACKGROUND_LOCATION)== PackageManager.PERMISSION_GRANTED
272
+            ) {
270 273
                 for (String provider : providers) {
271
-                    Location lastKnownLocation = systemService.getLastKnownLocation(provider);
274
+                    Location lastKnownLocation =locationManager.getLastKnownLocation(provider);
272 275
                     if (lastKnownLocation==null){
273 276
                         continue;
274 277
                     }
@@ -289,6 +292,9 @@ public class SystemUtil {
289 292
         return data;
290 293
     }
291 294
 
295
+    // 获取定位信息
296
+
297
+
292 298
     // 检查屏幕是否允许旋转
293 299
     public static boolean isRotationAllowed(Context context) {
294 300
         try{

Loading…
Cancel
Save