Check device admin policies enforced on the device

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.


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.


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
链接地址: http://www.djcxy.com/p/24616.html

上一篇: 我的设备已根植,但我的Android应用程序没有root权限(libsuperuser)

下一篇: 检查设备上执行的设备管理员策略