Browse Source

1.添加解除限制的密码判断接口。

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
bfd4061e60

+ 5
- 0
app/src/main/java/com/xhly/manageapp/network/UriAdress.kt View File

70
      * 获得壁纸
70
      * 获得壁纸
71
      */
71
      */
72
     const val WALLPAPERPAD="/wallpaper/detail_pad"
72
     const val WALLPAPERPAD="/wallpaper/detail_pad"
73
+
74
+    /**
75
+     * 解除当前锁屏
76
+     */
77
+    const val PWD_DEATIL_USERPAD="/password/detail_userpad"
73
 }
78
 }

+ 26
- 0
app/src/main/java/com/xhly/manageapp/ui/login/activity/LoginActivity.kt View File

57
                }
57
                }
58
            }
58
            }
59
        }
59
        }
60
+        viewModel.pwdResultData.observe(this){
61
+            if (it){
62
+                unBindBlock()
63
+            }else{
64
+                Toast(getString(R.string.codeerror))
65
+            }
66
+        }
60
         startWorkManager()
67
         startWorkManager()
61
     }
68
     }
62
 
69
 
66
         setSoftInput(mBinding.root)
73
         setSoftInput(mBinding.root)
67
         mBinding.loginBtn.setOnClickListener {
74
         mBinding.loginBtn.setOnClickListener {
68
             val rxPermissions = RxPermissions(this)
75
             val rxPermissions = RxPermissions(this)
76
+            //有无权限都要登录
69
             val request = rxPermissions.request(Manifest.permission.READ_PHONE_STATE)
77
             val request = rxPermissions.request(Manifest.permission.READ_PHONE_STATE)
70
             request.subscribe({
78
             request.subscribe({
71
                 login()
79
                 login()
76
         mBinding.codeLoginIv.setOnClickListener {
84
         mBinding.codeLoginIv.setOnClickListener {
77
             showEditDialog()
85
             showEditDialog()
78
         }
86
         }
87
+        mBinding.codeenterCv.setOnClickListener {
88
+            //如果密码一致,则解锁
89
+            val code = mBinding.lockEt.text.toString()
90
+            if (code.isNullOrBlank()){
91
+                return@setOnClickListener
92
+            }
93
+            ManageApplication.getDeviceInfo()?.let {
94
+                viewModel.postPwdDetail(code,it)
95
+            }
96
+        }
79
         onBackPressedDispatcher.addCallback {
97
         onBackPressedDispatcher.addCallback {
80
             //屏蔽返回
98
             //屏蔽返回
81
         }
99
         }
142
         finish()
160
         finish()
143
     }
161
     }
144
 
162
 
163
+    private fun unBindBlock() {
164
+        spUtils.setParam(Const.DISABLEPAD, false)
165
+        useTimeStrategy()
166
+        if (mBinding.loginMainLlayout.visibility == View.GONE) {
167
+            Toast(getString(R.string.padtimestoptips))
168
+        }
169
+    }
170
+
145
     override fun onResume() {
171
     override fun onResume() {
146
         super.onResume()
172
         super.onResume()
147
         useTimeStrategy()
173
         useTimeStrategy()

+ 6
- 0
app/src/main/java/com/xhly/manageapp/ui/login/netservice/LoginService.kt View File

21
      */
21
      */
22
     @POST(UriAdress.ULOGIN_LOGIN_OUT)
22
     @POST(UriAdress.ULOGIN_LOGIN_OUT)
23
     suspend fun postLoginOut(@Body map:HashMap<String,Any>): ResponseData<Any>
23
     suspend fun postLoginOut(@Body map:HashMap<String,Any>): ResponseData<Any>
24
+
25
+    /**
26
+     * 解除当前锁屏
27
+     */
28
+    @POST(UriAdress.PWD_DEATIL_USERPAD)
29
+    suspend fun postPwdDetail(@Body map:HashMap<String,Any>):ResponseData<Any>
24
 }
30
 }

+ 18
- 0
app/src/main/java/com/xhly/manageapp/ui/login/viewmodel/LoginViewModel.kt View File

16
     private var service=RetrofitService.create<LoginService>()
16
     private var service=RetrofitService.create<LoginService>()
17
     private val loginResult=MutableLiveData<UserBean>()
17
     private val loginResult=MutableLiveData<UserBean>()
18
     val loginData:LiveData<UserBean> =loginResult
18
     val loginData:LiveData<UserBean> =loginResult
19
+    private val pwdResult = MutableLiveData<Boolean>()
20
+    val pwdResultData: LiveData<Boolean> = pwdResult
19
     fun getTest(){
21
     fun getTest(){
20
         launchUI {
22
         launchUI {
21
             val test = service.getTest()
23
             val test = service.getTest()
46
             logService.postLogdoperateAdd(operateBean)
48
             logService.postLogdoperateAdd(operateBean)
47
         }
49
         }
48
     }
50
     }
51
+
52
+    /**
53
+     * 解除当前锁屏
54
+     */
55
+    fun postPwdDetail(code: String, sn: String) {
56
+        launchUI {
57
+            val map = HashMap<String, Any>()
58
+            map["sn"] = sn
59
+            val result = service.postPwdDetail(map)
60
+            if (result.code == 0) {
61
+                pwdResult.value = result.obj.toString().contains(code)
62
+            } else {
63
+                pwdResult.value = false
64
+            }
65
+        }
66
+    }
49
 }
67
 }

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

179
         viewModel.loginOutData.observe(this) {
179
         viewModel.loginOutData.observe(this) {
180
             if (it) {
180
             if (it) {
181
                 loginOut()
181
                 loginOut()
182
+            }else{
183
+                Toast(getString(R.string.codeerror))
182
             }
184
             }
183
         }
185
         }
184
         viewModel.updateInfoData.observe(this) {
186
         viewModel.updateInfoData.observe(this) {
219
         viewModel.netWhiteListData.observe(this){
221
         viewModel.netWhiteListData.observe(this){
220
            StrategyUtils.setNetWhiteList(it)
222
            StrategyUtils.setNetWhiteList(it)
221
         }
223
         }
224
+        viewModel.pwdResultData.observe(this){
225
+            if (it){
226
+                unBindBlock()
227
+            }else{
228
+                Toast(getString(R.string.codeerror))
229
+            }
230
+        }
222
         startWorkManager()
231
         startWorkManager()
223
     }
232
     }
224
 
233
 
243
         }
252
         }
244
         mBinding.codeenterCv.setOnClickListener {
253
         mBinding.codeenterCv.setOnClickListener {
245
             //如果密码一致,则解锁
254
             //如果密码一致,则解锁
246
-            spUtils.setParam(Const.DISABLEPAD, false)
247
-            useTimeStrategy()
248
-            if (mBinding.mainLlayout.visibility == View.GONE) {
249
-                Toast(getString(R.string.apptimestoptips))
255
+            val code = mBinding.lockEt.text.toString()
256
+            if (code.isNullOrBlank()){
257
+                return@setOnClickListener
258
+            }
259
+            ManageApplication.getDeviceInfo()?.let {
260
+                viewModel.postPwdDetail(code,it)
250
             }
261
             }
251
         }
262
         }
252
         onBackPressedDispatcher.addCallback {
263
         onBackPressedDispatcher.addCallback {
255
         }
266
         }
256
     }
267
     }
257
 
268
 
269
+    //解锁屏幕
270
+    private fun unBindBlock() {
271
+        spUtils.setParam(Const.DISABLEPAD, false)
272
+        useTimeStrategy()
273
+        if (mBinding.mainLlayout.visibility == View.GONE) {
274
+            Toast(getString(R.string.padtimestoptips))
275
+        }
276
+    }
277
+
258
     private fun getChangeCodeListener():AppAdapter.ChangePwdListener{
278
     private fun getChangeCodeListener():AppAdapter.ChangePwdListener{
259
         return object :AppAdapter.ChangePwdListener{
279
         return object :AppAdapter.ChangePwdListener{
260
             override fun changeCode() {
280
             override fun changeCode() {
446
                 mBinding.mainLlayout.visibility = View.VISIBLE
466
                 mBinding.mainLlayout.visibility = View.VISIBLE
447
                 mBinding.lockLlayout.visibility = View.GONE
467
                 mBinding.lockLlayout.visibility = View.GONE
448
             }
468
             }
449
-            changeWhiteList()
469
+            mBinding.lockEt.setText("")
450
         } catch (e: Exception) {
470
         } catch (e: Exception) {
451
             val param = spUtils.getParam(Const.DISABLEPAD, false) as Boolean
471
             val param = spUtils.getParam(Const.DISABLEPAD, false) as Boolean
452
             if (param) {
472
             if (param) {
459
         }
479
         }
460
     }
480
     }
461
 
481
 
462
-    private fun changeWhiteList() {/*        //获得当前白名单
463
-                val packageWhiteList = csdkManager.installPackageWhiteList
464
-                LogShow("当前白名单$packageWhiteList")
465
-                //获得从网络获取的白名单
466
-                val jsonArray = spUtils.getFromJson(Const.WHITELISTAPP, ArrayList<String>().javaClass)
467
-                val removeList = arrayListOf<String>()
468
-                //移除白名单外的应用,并设置新的白名单
469
-                if (jsonArray != null) {
470
-                    val whiteList = jsonArray as ArrayList<String>
471
-                    packageWhiteList.forEach { pkg ->
472
-                        val filter = whiteList.filter { it == pkg }
473
-                        if (filter.isEmpty()) {
474
-                            removeList.add(pkg)
475
-                        }
476
-                    }
477
-                    ManageApplication.addInstallPackageWhiteList(whiteList)
478
-                }
479
-                ManageApplication.removeInstallPackageWhiteList(removeList)*/
480
-    }
481
-
482
     private fun initSchoolSet(schoolDeviceSetBean: SchoolDeviceSetBean? = null) {
482
     private fun initSchoolSet(schoolDeviceSetBean: SchoolDeviceSetBean? = null) {
483
         schoolDeviceSetBean?.let {bean->
483
         schoolDeviceSetBean?.let {bean->
484
             //是否启用截屏:1是0否
484
             //是否启用截屏:1是0否

+ 46
- 28
app/src/main/java/com/xhly/manageapp/ui/main/viewmodel/MainViewModel.kt View File

38
     val updateInfoData: LiveData<Boolean> = updateInfo
38
     val updateInfoData: LiveData<Boolean> = updateInfo
39
     private val loginOut = MutableLiveData<Boolean>()
39
     private val loginOut = MutableLiveData<Boolean>()
40
     val loginOutData: LiveData<Boolean> = loginOut
40
     val loginOutData: LiveData<Boolean> = loginOut
41
-    private val schoolSet=MutableLiveData<SchoolDeviceSetBean>()
42
-    val schoolSetData:LiveData<SchoolDeviceSetBean> =schoolSet
43
-    private val wallpaper=MutableLiveData<WallpaperBean>()
44
-    val wallpaperData:LiveData<WallpaperBean> =wallpaper
45
-    private val netWhiteList=MutableLiveData<ArrayList<String>>()
46
-    val netWhiteListData:LiveData<ArrayList<String>> =netWhiteList
41
+    private val schoolSet = MutableLiveData<SchoolDeviceSetBean>()
42
+    val schoolSetData: LiveData<SchoolDeviceSetBean> = schoolSet
43
+    private val wallpaper = MutableLiveData<WallpaperBean>()
44
+    val wallpaperData: LiveData<WallpaperBean> = wallpaper
45
+    private val netWhiteList = MutableLiveData<ArrayList<String>>()
46
+    val netWhiteListData: LiveData<ArrayList<String>> = netWhiteList
47
+    private val pwdResult = MutableLiveData<Boolean>()
48
+    val pwdResultData: LiveData<Boolean> = pwdResult
47
 
49
 
48
     fun getAppList() {
50
     fun getAppList() {
49
         launchUI {
51
         launchUI {
60
                 }
62
                 }
61
             }
63
             }
62
             //获得必装应用
64
             //获得必装应用
63
-            val result= appService.postForceApp()
64
-            if (result.code==0&&result.obj!=null&&result.obj.isNotEmpty()){
65
-                forceData.value=result.obj
65
+            val result = appService.postForceApp()
66
+            if (result.code == 0 && result.obj != null && result.obj.isNotEmpty()) {
67
+                forceData.value = result.obj
66
             }
68
             }
67
         }
69
         }
68
     }
70
     }
69
 
71
 
70
-/*    fun getForceAppList(){
71
-        launchUI {
72
-            val result= appService.postForceApp()
73
-            if (result.code==0&&result.obj!=null&&result.obj.isNotEmpty()){
74
-                forceData.value=result.obj
72
+    /*    fun getForceAppList(){
73
+            launchUI {
74
+                val result= appService.postForceApp()
75
+                if (result.code==0&&result.obj!=null&&result.obj.isNotEmpty()){
76
+                    forceData.value=result.obj
77
+                }
75
             }
78
             }
76
-        }
77
-    }*/
79
+        }*/
78
 
80
 
79
     fun updateStrategy() {
81
     fun updateStrategy() {
80
         launchUI {
82
         launchUI {
154
     /**
156
     /**
155
      * 获得设备设置管理
157
      * 获得设备设置管理
156
      */
158
      */
157
-    fun postDevicesetDetail(schoolid:Long) {
159
+    fun postDevicesetDetail(schoolid: Long) {
158
         launchUI {
160
         launchUI {
159
             val map = HashMap<String, Any>()
161
             val map = HashMap<String, Any>()
160
             map["schoolid"] = schoolid
162
             map["schoolid"] = schoolid
161
             val result = strategyService.postDevicesetDetail(map)
163
             val result = strategyService.postDevicesetDetail(map)
162
             if (result.code == 0) {
164
             if (result.code == 0) {
163
-               schoolSet.value=result.obj
165
+                schoolSet.value = result.obj
164
             } else {
166
             } else {
165
                 netMessage.value = result.msg
167
                 netMessage.value = result.msg
166
             }
168
             }
170
     /**
172
     /**
171
      * 获得壁纸
173
      * 获得壁纸
172
      */
174
      */
173
-    fun postWallpaperPad(){
175
+    fun postWallpaperPad() {
174
         launchUI {
176
         launchUI {
175
             val postWallpaperPad = appService.postWallpaperPad()
177
             val postWallpaperPad = appService.postWallpaperPad()
176
-            if (postWallpaperPad.code==0){
177
-                wallpaper.value=postWallpaperPad.obj
178
+            if (postWallpaperPad.code == 0) {
179
+                wallpaper.value = postWallpaperPad.obj
178
             }
180
             }
179
         }
181
         }
180
     }
182
     }
182
     /**
184
     /**
183
      * 获得网址白名单
185
      * 获得网址白名单
184
      */
186
      */
185
-    fun postAppNetWhiteList(){
187
+    fun postAppNetWhiteList() {
186
         launchUI {
188
         launchUI {
187
             val postAppNetWhiteList = strategyService.postAppNetWhiteList()
189
             val postAppNetWhiteList = strategyService.postAppNetWhiteList()
188
-            if (postAppNetWhiteList.code==0){
189
-                 val urlList= arrayListOf<String>()
190
+            if (postAppNetWhiteList.code == 0) {
191
+                val urlList = arrayListOf<String>()
190
                 postAppNetWhiteList.obj.forEach {
192
                 postAppNetWhiteList.obj.forEach {
191
-                    if (it.contains(";")){
192
-                        it.split(";").forEach {str->
193
+                    if (it.contains(";")) {
194
+                        it.split(";").forEach { str ->
193
                             urlList.add(str)
195
                             urlList.add(str)
194
                         }
196
                         }
195
-                    }else{
197
+                    } else {
196
                         urlList.add(it)
198
                         urlList.add(it)
197
                     }
199
                     }
198
                 }
200
                 }
199
-                  netWhiteList.value=urlList
201
+                netWhiteList.value = urlList
202
+            }
203
+        }
204
+    }
205
+
206
+    /**
207
+     * 解除当前锁屏
208
+     */
209
+    fun postPwdDetail(code: String, sn: String) {
210
+        launchUI {
211
+            val map = HashMap<String, Any>()
212
+            map["sn"] = sn
213
+            val result = loginService.postPwdDetail(map)
214
+            if (result.code == 0) {
215
+                pwdResult.value = result.obj.toString().contains(code)
216
+            } else {
217
+                pwdResult.value = false
200
             }
218
             }
201
         }
219
         }
202
     }
220
     }

+ 2
- 1
app/src/main/res/values/strings.xml View File

2
     <string name="app_name">XhlyManageApp</string>
2
     <string name="app_name">XhlyManageApp</string>
3
     <string name="stoptips">已被禁用,无法操作</string>
3
     <string name="stoptips">已被禁用,无法操作</string>
4
     <string name="apptimestoptips">应用不在可用时间!</string>
4
     <string name="apptimestoptips">应用不在可用时间!</string>
5
-    <string name="timestoptips">当前时段不可用</string>
5
+    <string name="padtimestoptips">平板不在可用时间!</string>
6
     <string name="inputaccount">请输入账号</string>
6
     <string name="inputaccount">请输入账号</string>
7
     <string name="inputcode">请输入密码</string>
7
     <string name="inputcode">请输入密码</string>
8
     <string name="inputregioncode">请输入区域码</string>
8
     <string name="inputregioncode">请输入区域码</string>
29
     <string name="enternewcodetips">请输入确认新密码</string>
29
     <string name="enternewcodetips">请输入确认新密码</string>
30
     <string name="codetips">密码必须是6-16位的英文字母、数字组合</string>
30
     <string name="codetips">密码必须是6-16位的英文字母、数字组合</string>
31
     <string name="locktips">您的设备已违规或者被管理员限制使用,请联系管理员</string>
31
     <string name="locktips">您的设备已违规或者被管理员限制使用,请联系管理员</string>
32
+    <string name="codeerror">密码不正确。</string>
32
     <string name="durationtips">当前使用时间过长,请休息后再使用。\n</string>
33
     <string name="durationtips">当前使用时间过长,请休息后再使用。\n</string>
33
     <string name="openrotation">自动旋转已开启</string>
34
     <string name="openrotation">自动旋转已开启</string>
34
     <string name="closerotation">自动旋转已关闭</string>
35
     <string name="closerotation">自动旋转已关闭</string>

Loading…
Cancel
Save