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
                 }
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
     override fun onCreate() {
532
     override fun onCreate() {
530
             addInstallPackageWhiteList(
552
             addInstallPackageWhiteList(
531
                 arrayListOf(
553
                 arrayListOf(
532
                     Const.CURRENTAPPPKG,
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
            // setRuntimePermissions(true)
561
            // setRuntimePermissions(true)
538
             disableStatusBarPanel(true)
562
             disableStatusBarPanel(true)

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

6
     //记录登录返回的msg
6
     //记录登录返回的msg
7
     var xhlyLoginMessage:String?=""
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
     var username: String? = null
17
     var username: String? = null
18
+
19
+    /**
20
+     * 账号
21
+     */
16
     var loginname: String? = null
22
     var loginname: String? = null
17
-    var classid: Long? = null
23
+
24
+    /**
25
+     * 密码
26
+     */
18
     var loginpwd:String=""
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
      * 管控状态1管控中2解除管控
42
      * 管控状态1管控中2解除管控
22
      */
43
      */
23
     var control=1
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
     var rversion=0L
58
     var rversion=0L
34
 
59
 
60
+
35
     /**
61
     /**
36
-     * Xh-Token-Key
62
+     * tokenKey
37
      */
63
      */
38
     var Xh_Token_Key:String?=null
64
     var Xh_Token_Key:String?=null
39
-
65
+    /**
66
+     * token
67
+     */
40
     var Xh_Token_Value:String?=null
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
 import android.content.pm.PackageManager
10
 import android.content.pm.PackageManager
11
 import android.graphics.Color
11
 import android.graphics.Color
12
 import android.graphics.drawable.Drawable
12
 import android.graphics.drawable.Drawable
13
+import android.os.Build
13
 import android.provider.Settings
14
 import android.provider.Settings
15
+import android.text.TextUtils
14
 import android.view.View
16
 import android.view.View
15
 import android.widget.Button
17
 import android.widget.Button
16
 import android.widget.EditText
18
 import android.widget.EditText
44
 import com.xhly.manageapp.ManageApplication
46
 import com.xhly.manageapp.ManageApplication
45
 import com.xhly.manageapp.bean.EventLog
47
 import com.xhly.manageapp.bean.EventLog
46
 import com.xhly.manageapp.bean.SocketMsgBean
48
 import com.xhly.manageapp.bean.SocketMsgBean
47
-import com.xhly.manageapp.bean.log.UpdateBean
48
 import com.xhly.manageapp.bean.log.LogPushBean
49
 import com.xhly.manageapp.bean.log.LogPushBean
49
 import com.xhly.manageapp.bean.log.LogdOperateBean
50
 import com.xhly.manageapp.bean.log.LogdOperateBean
51
+import com.xhly.manageapp.bean.log.UpdateBean
50
 import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
52
 import com.xhly.manageapp.bean.school.SchoolDeviceSetBean
51
 import com.xhly.manageapp.bean.strategy.StrategyBean
53
 import com.xhly.manageapp.bean.strategy.StrategyBean
52
 import com.xhly.manageapp.bean.user.UserBean
54
 import com.xhly.manageapp.bean.user.UserBean
74
     private var mMyInstallReceiver: AppInstallReceiver? = null
76
     private var mMyInstallReceiver: AppInstallReceiver? = null
75
     private var dataList: ArrayList<AppInfo> = arrayListOf()
77
     private var dataList: ArrayList<AppInfo> = arrayListOf()
76
     private var userBean: UserBean? = null
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
     override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
81
     override fun getBinding() = ActivityMainBinding.inflate(layoutInflater)
80
 
82
 
81
     override fun initData() {
83
     override fun initData() {
88
         }
90
         }
89
         adapter = AppAdapter(this, dataList)
91
         adapter = AppAdapter(this, dataList)
90
         mBinding.rv.layoutManager = GridLayoutManager(this, 6, GridLayoutManager.VERTICAL, false)
92
         mBinding.rv.layoutManager = GridLayoutManager(this, 6, GridLayoutManager.VERTICAL, false)
91
-        adapter?.changePwdListener=getChangeCodeListener()
93
+        adapter?.changePwdListener = getChangeCodeListener()
92
         mBinding.rv.adapter = adapter
94
         mBinding.rv.adapter = adapter
93
         updateAppRv()
95
         updateAppRv()
94
         // checkAccessibility(this)
96
         // checkAccessibility(this)
103
 
105
 
104
         viewModel.listAppData.observe(this) { modelList ->
106
         viewModel.listAppData.observe(this) { modelList ->
105
             //存储商店应用包名到本地
107
             //存储商店应用包名到本地
106
-            val appNameList= arrayListOf<String>()
108
+            val appNameList = arrayListOf<String>()
109
+            val whiteList= arrayListOf<String>()
107
             modelList.forEach {
110
             modelList.forEach {
108
                 appNameList.add(it.appPackage)
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
             //获得应用集合,必装应用和推荐应用,再加上预装应用,其余应用需要静默卸载,必装应用需要进行静默下载和安装。安装应用从forceapp接口获取
118
             //获得应用集合,必装应用和推荐应用,再加上预装应用,其余应用需要静默卸载,必装应用需要进行静默下载和安装。安装应用从forceapp接口获取
112
             val appList = AppUtils.GetAppList(this)
119
             val appList = AppUtils.GetAppList(this)
113
-            val firstAppList= arrayListOf<String>()
120
+            val firstAppList = arrayListOf<String>()
114
             try {
121
             try {
115
                 //获得预装应用的包名
122
                 //获得预装应用的包名
116
                 val currentList =
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
                 firstAppList.addAll(currentList)
128
                 firstAppList.addAll(currentList)
119
-            }catch (e:Exception){
120
-               LogShow("冻结失败"+e.toString())
129
+            } catch (e: Exception) {
130
+                LogShow("冻结失败" + e.toString())
121
             }
131
             }
122
             appList.forEach { app ->
132
             appList.forEach { app ->
123
                 val filter = modelList.filter { it.appPackage.equals(app.packageName) }
133
                 val filter = modelList.filter { it.appPackage.equals(app.packageName) }
124
                 val appInfos = firstAppList.filter { app.packageName.equals(it) }
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
         viewModel.loginOutData.observe(this) {
186
         viewModel.loginOutData.observe(this) {
177
             if (it) {
187
             if (it) {
178
                 loginOut()
188
                 loginOut()
179
-            }else{
189
+            } else {
180
                 Toast(getString(R.string.codeerror))
190
                 Toast(getString(R.string.codeerror))
181
             }
191
             }
182
         }
192
         }
191
             initSchoolSet(it)
201
             initSchoolSet(it)
192
             updateAppRv()
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
                 unBindBlock()
235
                 unBindBlock()
224
-            }else{
236
+            } else {
225
                 Toast(getString(R.string.codeerror))
237
                 Toast(getString(R.string.codeerror))
226
             }
238
             }
227
         }
239
         }
240
         }
252
         }
241
         mBinding.loginoutIv.setOnClickListener {
253
         mBinding.loginoutIv.setOnClickListener {
242
             val schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this@MainActivity)
254
             val schoolDeviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this@MainActivity)
243
-            if (schoolDeviceSetBean !=null&&schoolDeviceSetBean.logout==1){
255
+            if (schoolDeviceSetBean != null && schoolDeviceSetBean.logout == 1) {
244
                 //禁用注销
256
                 //禁用注销
245
                 return@setOnClickListener
257
                 return@setOnClickListener
246
-            }else{
258
+            } else {
247
                 showEditDialog()
259
                 showEditDialog()
248
             }
260
             }
249
         }
261
         }
250
         mBinding.codeenterCv.setOnClickListener {
262
         mBinding.codeenterCv.setOnClickListener {
251
             //如果密码一致,则解锁
263
             //如果密码一致,则解锁
252
             val code = mBinding.lockEt.text.toString()
264
             val code = mBinding.lockEt.text.toString()
253
-            if (code.isNullOrBlank()){
265
+            if (code.isNullOrBlank()) {
254
                 return@setOnClickListener
266
                 return@setOnClickListener
255
             }
267
             }
256
             ManageApplication.getDeviceInfo()?.let {
268
             ManageApplication.getDeviceInfo()?.let {
257
-                viewModel.postPwdDetail(code,it)
269
+                viewModel.postPwdDetail(code, it)
258
             }
270
             }
259
         }
271
         }
260
         onBackPressedDispatcher.addCallback {
272
         onBackPressedDispatcher.addCallback {
261
             //屏蔽返回键
273
             //屏蔽返回键
262
-           getLocation()
274
+            getLocation()
263
         }
275
         }
264
     }
276
     }
265
 
277
 
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
             override fun changeCode() {
289
             override fun changeCode() {
278
                 val deviceSetBean = StrategyUtils.getSchoolDeviceSetBean(this@MainActivity)
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
                     showChangeCodeDialog()
297
                     showChangeCodeDialog()
286
                 }
298
                 }
287
             }
299
             }
298
                     val enterTv = v.findViewById<TextView>(R.id.dialog_enter_tv)
310
                     val enterTv = v.findViewById<TextView>(R.id.dialog_enter_tv)
299
                     val cancelTv = v.findViewById<TextView>(R.id.dialog_cancel_tv)
311
                     val cancelTv = v.findViewById<TextView>(R.id.dialog_cancel_tv)
300
                     val editText = v.findViewById<EditText>(R.id.dialog_et)
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
                     enterTv.setOnClickListener {
315
                     enterTv.setOnClickListener {
304
                         val enterCode = editText.text.toString()
316
                         val enterCode = editText.text.toString()
305
                         val oldCode = oldCodeEt.text.toString()
317
                         val oldCode = oldCodeEt.text.toString()
306
                         val newCode = newCodeEt.text.toString()
318
                         val newCode = newCodeEt.text.toString()
307
-                        if (!getTextFlag(enterCode)||!getTextFlag(oldCode)||!getTextFlag(newCode)){
319
+                        if (!getTextFlag(enterCode) || !getTextFlag(oldCode) || !getTextFlag(newCode)) {
308
                             Toast("密码不符合规则")
320
                             Toast("密码不符合规则")
309
                             return@setOnClickListener
321
                             return@setOnClickListener
310
                         }
322
                         }
311
-                        if (oldCode.equals(newCode)){
323
+                        if (oldCode.equals(newCode)) {
312
                             Toast("新密码不能和旧密码一致。")
324
                             Toast("新密码不能和旧密码一致。")
313
                             return@setOnClickListener
325
                             return@setOnClickListener
314
                         }
326
                         }
315
 
327
 
316
-                        if (!newCode.equals(enterCode)){
328
+                        if (!newCode.equals(enterCode)) {
317
                             Toast("两次输入的新密码不一致。")
329
                             Toast("两次输入的新密码不一致。")
318
                             return@setOnClickListener
330
                             return@setOnClickListener
319
                         }
331
                         }
323
                             val userBean = spUtils.getFromJson(
335
                             val userBean = spUtils.getFromJson(
324
                                 Const.USERINFO, UserBean().javaClass
336
                                 Const.USERINFO, UserBean().javaClass
325
                             ) as UserBean
337
                             ) as UserBean
326
-                            viewModel.postEditPwd(userBean.userid,newCode,oldCode)
338
+                            viewModel.postEditPwd(userBean.userid, newCode, oldCode)
327
                         } catch (e: Exception) {
339
                         } catch (e: Exception) {
328
 
340
 
329
                         }
341
                         }
336
             .setAlign(CustomDialog.ALIGN.CENTER).show()
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
         try {
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
             return false
355
             return false
344
         }
356
         }
345
     }
357
     }
347
     override fun onResume() {
359
     override fun onResume() {
348
         super.onResume()
360
         super.onResume()
349
         userBean?.let {
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
             viewModel.postDevicesetDetail(it.schoolid)
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
         viewModel.postWallpaperPad()
374
         viewModel.postWallpaperPad()
355
         viewModel.updateStrategy()
375
         viewModel.updateStrategy()
427
     @SuppressLint("CheckResult")
447
     @SuppressLint("CheckResult")
428
     private fun getLocation() {
448
     private fun getLocation() {
429
         val rxPermissions = RxPermissions(this)
449
         val rxPermissions = RxPermissions(this)
450
+        //  Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS
430
         rxPermissions.request(
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
         ).subscribe({
453
         ).subscribe({
434
             if (it) {
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
             } else {
463
             } else {
437
                 LogShow("没有权限")
464
                 LogShow("没有权限")
438
             }
465
             }
478
     }
505
     }
479
 
506
 
480
     private fun initSchoolSet(schoolDeviceSetBean: SchoolDeviceSetBean? = null) {
507
     private fun initSchoolSet(schoolDeviceSetBean: SchoolDeviceSetBean? = null) {
481
-        schoolDeviceSetBean?.let {bean->
508
+        schoolDeviceSetBean?.let { bean ->
482
             //是否启用截屏:1是0否
509
             //是否启用截屏:1是0否
483
             ManageApplication.enableCaptureScreen(schoolDeviceSetBean.screenshots == 1)
510
             ManageApplication.enableCaptureScreen(schoolDeviceSetBean.screenshots == 1)
484
             if (bean.forceBind == 1) {
511
             if (bean.forceBind == 1) {
496
     }
523
     }
497
 
524
 
498
     private fun startTimeTask(bean: SchoolDeviceSetBean) {
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
             try {
528
             try {
502
                 timer?.cancel()
529
                 timer?.cancel()
503
-                timer= Timer()
504
-            }catch (e:Exception){
530
+                timer = Timer()
531
+            } catch (e: Exception) {
505
 
532
 
506
             }
533
             }
507
             timer?.let {
534
             timer?.let {
508
-                timer?.schedule( object : TimerTask() {
535
+                timer?.schedule(object : TimerTask() {
509
                     override fun run() {
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
                 timer?.cancel()
546
                 timer?.cancel()
520
-                timer=null
547
+                timer = null
521
             }
548
             }
522
         }
549
         }
523
     }
550
     }
674
                 data.doEvent = EventLog.USBDISCONNECTEVENT
701
                 data.doEvent = EventLog.USBDISCONNECTEVENT
675
                 viewModel.eventLog(data)
702
                 viewModel.eventLog(data)
676
             }
703
             }
677
-            Const.ACCOUNTLOGINOUT->{
704
+
705
+            Const.ACCOUNTLOGINOUT -> {
678
                 loginOut()
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
         Const.USERID?.let {
715
         Const.USERID?.let {
688
-            pushBean.userids= longArrayOf(it)
716
+            pushBean.userids = longArrayOf(it)
689
         }
717
         }
690
         Const.USERNAME?.let {
718
         Const.USERNAME?.let {
691
-            pushBean.pushObjname=it
719
+            pushBean.pushObjname = it
692
         }
720
         }
693
         viewModel.postLogPushAdd(pushBean)
721
         viewModel.postLogPushAdd(pushBean)
694
     }
722
     }
706
             dataList.addAll(appList)
734
             dataList.addAll(appList)
707
             if (adapter == null) {
735
             if (adapter == null) {
708
                 adapter = AppAdapter(this, dataList)
736
                 adapter = AppAdapter(this, dataList)
709
-                adapter?.changePwdListener=getChangeCodeListener()
737
+                adapter?.changePwdListener = getChangeCodeListener()
710
                 mBinding.rv.adapter = adapter
738
                 mBinding.rv.adapter = adapter
711
             }
739
             }
712
             adapter?.let {
740
             adapter?.let {
769
                     titleTv.text = getString(R.string.exit)
797
                     titleTv.text = getString(R.string.exit)
770
                     enterTv.setOnClickListener {
798
                     enterTv.setOnClickListener {
771
                         val code = editText.text
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
                             dialog.dismiss()
801
                             dialog.dismiss()
774
                             try {
802
                             try {
775
                                 val userBean = spUtils.getFromJson(
803
                                 val userBean = spUtils.getFromJson(
803
                         titleTv.text = msgBean.title
831
                         titleTv.text = msgBean.title
804
                         contentTv.text = msgBean.content
832
                         contentTv.text = msgBean.content
805
                     } catch (e: Exception) {
833
                     } catch (e: Exception) {
806
-                        LogShow("解析失败"+e.toString())
834
+                        LogShow("解析失败" + e.toString())
807
                     }
835
                     }
808
                     closeBtn.setOnClickListener {
836
                     closeBtn.setOnClickListener {
809
                         dialog.dismiss()
837
                         dialog.dismiss()
823
         viewModel.eventLog(data)
851
         viewModel.eventLog(data)
824
         WorkManager.getInstance(this).cancelAllWork()
852
         WorkManager.getInstance(this).cancelAllWork()
825
         deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
853
         deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
826
-        Const.USERID=null
827
-        Const.USERNAME=""
854
+        Const.USERID = null
855
+        Const.USERNAME = ""
828
         startIntentActivity(LoginActivity().javaClass)
856
         startIntentActivity(LoginActivity().javaClass)
829
         finish()
857
         finish()
830
     }
858
     }
832
 
860
 
833
     override fun onDestroy() {
861
     override fun onDestroy() {
834
         super.onDestroy()
862
         super.onDestroy()
835
-        if (timer!=null){
863
+        if (timer != null) {
836
             timer?.cancel()
864
             timer?.cancel()
837
-            timer=null
865
+            timer = null
838
         }
866
         }
839
         mMyInstallReceiver?.let {
867
         mMyInstallReceiver?.let {
840
             unregisterReceiver(it)
868
             unregisterReceiver(it)

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

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

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

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

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

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

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

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

Loading…
Cancel
Save