소스 검색

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

20241218TB223FC(测试jar包)
wangwanlei 9 달 전
부모
커밋
bfd4061e60

+ 5
- 0
app/src/main/java/com/xhly/manageapp/network/UriAdress.kt 파일 보기

@@ -70,4 +70,9 @@ object UriAdress {
70 70
      * 获得壁纸
71 71
      */
72 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 파일 보기

@@ -57,6 +57,13 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
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 67
         startWorkManager()
61 68
     }
62 69
 
@@ -66,6 +73,7 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
66 73
         setSoftInput(mBinding.root)
67 74
         mBinding.loginBtn.setOnClickListener {
68 75
             val rxPermissions = RxPermissions(this)
76
+            //有无权限都要登录
69 77
             val request = rxPermissions.request(Manifest.permission.READ_PHONE_STATE)
70 78
             request.subscribe({
71 79
                 login()
@@ -76,6 +84,16 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
76 84
         mBinding.codeLoginIv.setOnClickListener {
77 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 97
         onBackPressedDispatcher.addCallback {
80 98
             //屏蔽返回
81 99
         }
@@ -142,6 +160,14 @@ class LoginActivity : BaseActivity<LoginViewModel, ActivityLoginBinding>() {
142 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 171
     override fun onResume() {
146 172
         super.onResume()
147 173
         useTimeStrategy()

+ 6
- 0
app/src/main/java/com/xhly/manageapp/ui/login/netservice/LoginService.kt 파일 보기

@@ -21,4 +21,10 @@ interface LoginService {
21 21
      */
22 22
     @POST(UriAdress.ULOGIN_LOGIN_OUT)
23 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 파일 보기

@@ -16,6 +16,8 @@ class LoginViewModel: CommonBaseViewModel() {
16 16
     private var service=RetrofitService.create<LoginService>()
17 17
     private val loginResult=MutableLiveData<UserBean>()
18 18
     val loginData:LiveData<UserBean> =loginResult
19
+    private val pwdResult = MutableLiveData<Boolean>()
20
+    val pwdResultData: LiveData<Boolean> = pwdResult
19 21
     fun getTest(){
20 22
         launchUI {
21 23
             val test = service.getTest()
@@ -46,4 +48,20 @@ class LoginViewModel: CommonBaseViewModel() {
46 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 파일 보기

@@ -179,6 +179,8 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
179 179
         viewModel.loginOutData.observe(this) {
180 180
             if (it) {
181 181
                 loginOut()
182
+            }else{
183
+                Toast(getString(R.string.codeerror))
182 184
             }
183 185
         }
184 186
         viewModel.updateInfoData.observe(this) {
@@ -219,6 +221,13 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
219 221
         viewModel.netWhiteListData.observe(this){
220 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 231
         startWorkManager()
223 232
     }
224 233
 
@@ -243,10 +252,12 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
243 252
         }
244 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 263
         onBackPressedDispatcher.addCallback {
@@ -255,6 +266,15 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
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 278
     private fun getChangeCodeListener():AppAdapter.ChangePwdListener{
259 279
         return object :AppAdapter.ChangePwdListener{
260 280
             override fun changeCode() {
@@ -446,7 +466,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
446 466
                 mBinding.mainLlayout.visibility = View.VISIBLE
447 467
                 mBinding.lockLlayout.visibility = View.GONE
448 468
             }
449
-            changeWhiteList()
469
+            mBinding.lockEt.setText("")
450 470
         } catch (e: Exception) {
451 471
             val param = spUtils.getParam(Const.DISABLEPAD, false) as Boolean
452 472
             if (param) {
@@ -459,26 +479,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
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 482
     private fun initSchoolSet(schoolDeviceSetBean: SchoolDeviceSetBean? = null) {
483 483
         schoolDeviceSetBean?.let {bean->
484 484
             //是否启用截屏:1是0否

+ 46
- 28
app/src/main/java/com/xhly/manageapp/ui/main/viewmodel/MainViewModel.kt 파일 보기

@@ -38,12 +38,14 @@ class MainViewModel : CommonBaseViewModel() {
38 38
     val updateInfoData: LiveData<Boolean> = updateInfo
39 39
     private val loginOut = MutableLiveData<Boolean>()
40 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 50
     fun getAppList() {
49 51
         launchUI {
@@ -60,21 +62,21 @@ class MainViewModel : CommonBaseViewModel() {
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 81
     fun updateStrategy() {
80 82
         launchUI {
@@ -154,13 +156,13 @@ class MainViewModel : CommonBaseViewModel() {
154 156
     /**
155 157
      * 获得设备设置管理
156 158
      */
157
-    fun postDevicesetDetail(schoolid:Long) {
159
+    fun postDevicesetDetail(schoolid: Long) {
158 160
         launchUI {
159 161
             val map = HashMap<String, Any>()
160 162
             map["schoolid"] = schoolid
161 163
             val result = strategyService.postDevicesetDetail(map)
162 164
             if (result.code == 0) {
163
-               schoolSet.value=result.obj
165
+                schoolSet.value = result.obj
164 166
             } else {
165 167
                 netMessage.value = result.msg
166 168
             }
@@ -170,11 +172,11 @@ class MainViewModel : CommonBaseViewModel() {
170 172
     /**
171 173
      * 获得壁纸
172 174
      */
173
-    fun postWallpaperPad(){
175
+    fun postWallpaperPad() {
174 176
         launchUI {
175 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,21 +184,37 @@ class MainViewModel : CommonBaseViewModel() {
182 184
     /**
183 185
      * 获得网址白名单
184 186
      */
185
-    fun postAppNetWhiteList(){
187
+    fun postAppNetWhiteList() {
186 188
         launchUI {
187 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 192
                 postAppNetWhiteList.obj.forEach {
191
-                    if (it.contains(";")){
192
-                        it.split(";").forEach {str->
193
+                    if (it.contains(";")) {
194
+                        it.split(";").forEach { str ->
193 195
                             urlList.add(str)
194 196
                         }
195
-                    }else{
197
+                    } else {
196 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 파일 보기

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

Loading…
취소
저장