Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update policy on a device owner app on Android

Tags:

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?

like image 296
Noaman Avatar asked May 26 '17 03:05

Noaman


1 Answers

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

like image 115
Sree Vishnu Avatar answered Sep 24 '22 10:09

Sree Vishnu