The new Android Lollipop API provides a new pair of methods for getting and setting restrictions on other apps: DevicePolicyManager.getApplicationRestrictions and DevicePolicyManager.setApplicationRestrictions
There's an example of them being used in the BasicManagedProfile sample app to set restrictions on the Chrome app by passing a set of key/value pairs that seem to correlate to the Chrome's published policy list. This works perfectly for me.
But I can't find any documentation on any other apps that can be restricted in this way. Does anyone know of any other apps that can be restricted with these methods, and the keys that can be set?
DevicePolicyManager.getApplicationRestrictions only seems to return the restrictions you've already set for that app, not a list of all available restrictions. I also tried using RestrictionsManager.getManifestRestrictions on Chrome but this returns an empty list, so I think this is something different.
Android Device Policy is a built-in device policy controller enabling IT administrators to directly manage Android devices via enterprise mobility management (EMM) providers that use the Android Management API.
I suggest reading Google's documentation for building a Work policy controller.
A managed application will include restrictions file that is declared in the manifest. Enterprise mobile management partner can retrieve this information using Google play APIs. Read Implementing App Restrictions
Following steps could be used to find available restrictions in an Android application:
Get the apk from the device. Example: Use these steps:
$ adb shell pm path com.android.chrome
package:/data/app/com.android.chrome-2/base.apk
$ adb pull /data/app/com.android.chrome-2/base.apk
4722 KB/s (32575247 bytes in 6.735s)
Unzip apk file. Look for app_restrictions.xml
file in res/
folder.
Use aapt
tool to retrieve content of this file from apk. Example:
aapt d xmltree DivideProductivity_1.2_RC05_6-1.apk res/xml/app_restrictions.xml
aapt d xmltree base.apk res/xml-v21/app_restrictions.xml
Note that with this mechanism, you can only view the restriction keys. You will need restriction type and other details to actually set restrictions on a managed application. The proper way is using Google play APIs from server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With