Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find an app's available restrictions for DevicePolicyManager.setApplicationRestrictions

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.

like image 288
stevev Avatar asked Nov 01 '14 13:11

stevev


People also ask

What is device policy manager in android?

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.


1 Answers

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.

like image 63
user802467 Avatar answered Oct 08 '22 03:10

user802467