I have a device admin app that uses the following device-admin.xml
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<watch-login />
<reset-password />
<force-lock />
<wipe-data />
</uses-policies>
</device-admin>
Some users has already activated the device admin permissions. Now, in an update of the app, I want to add a new uses-policy
<limit-password />
I am wondering how to detect that new use policies have been added programmatically so that we push the reactivation of the device admin permissions?
AFAIK the only way is read your device-admin.xml from your apk, and you can do it in this way (from an Activity):
To check if your active admin has granted policy, you can use https://developer.android.com/reference/android/app/admin/DevicePolicyManager#hasGrantedPolicy(android.content.ComponentName,%20int)
To verify uses policies from device-admin.xml I prefer to use https://developer.android.google.cn/reference/android/app/admin/DeviceAdminInfo.html?hl=zh-cn#usesPolicy(int) but when
usesPolicy
returntrue
it doesn't mean that the active admin can use it.