简体   繁体   中英

Update policy on a device owner app on Android

I have a device owner app on Android, and would like to add an additional policy to device-admin.xml file. This is required because I want to disable camera on keyguard, which requires <disable-keyguard-features /> to be available inside the device-admin.xml. The app was initially installed using NFC and a new version of the app can be installed through a locally saved apk file, which can be downloaded from our private server, however, when the new version of app is installed it seems to have no impact on the addition of <disable-keyguard-features /> to device-admin.xml because we get a SecurityException on calling

aDevicePolicyManager.setKeyguardDisabledFeatures(aDeviceAdmin,
    DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA);

Now, if we re-provision a device with new version of the owner app, using NFC then everything goes well, but I am looking for a way to apply this change to existing app, how can this be achieved?

In other words, how can we update policy requirements of a device owner app on an Android device without re-provisioning?

You can not add a new policy to device-admin.xml and update the application to get the required policy activated.

You have to re-request the permission for the permission to get activated.

So either go for a update handling mechanism with version codes or just check if the permission exists as explained on this link .

And also do not forget to add a check for any line of code or function which depends on the new admin policy.

If you feel its expensive to check if you have got the permission every time when you try to run a code have a flag and reset it on onEnabled call back of your DeviceAdminReceiver

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM