Check device admin policies enforced on the device

652 views Asked by At

Can we check which policies are enforced on the device by the device admin.I want to enable/disable certain features and show prompt to the user based on policies enforced on device.

For eg: I want to disable camera option in my app when the camera restriction policy has being enabled by an admin on the device.This will help to improve the usability.

Please note my app is not device admin app.

2

There are 2 answers

0
CommonsWare On

The getter methods on DevicePolicyManager are available to all apps, AFAIK. So, getCameraDisabled(null) should tell you if the camera is disabled. Only an appropriate device admin can change the camera-disabled setting, though.

0
rupesh jain On

Found out there is UserManager api which will help me do that. refer here

public boolean hasUserRestriction (String restrictionKey)
Added in API level 21

Returns whether the current user has been disallowed from performing certain actions or setting certain settings.
Parameters
restrictionKey  The string key representing the restriction.
Returns

    true if the current user has the given restriction, false otherwise. 


  [1]: http://developer.android.com/reference/android/os/UserManager.html#hasUserRestriction%28java.lang.String%29