Ranjan
Ranjan

Reputation: 1356

Permission regarding Android EMM

I am making an EMM application. This application will only be installed in firm's devices only. Is there any way to grant below permissions programmatically through DevicePolicyManager.

  1. android.permission.SYSTEM_ALERT_WINDOW (Display over other apps)
  2. android.permission.BIND_ACCESSIBILITY_SERVICE (Accessibility service)
  3. android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS (Ignore battery optimization)

I want to grant above permissions through DevicePolicyManager as my app is a system owner app. But, I can't grant them through devicePolicyManager.setPermissionGrantState. As I have also tried devicePolicyManager.setPermittedAccessibilityServices for granting ACCESSIBILY_SERVICE programmatically, but it also didn't work. So, is there is any way I can grant above all permissions programmatically without navigating to that screen and turn in on manually. Or Is there is a way so that user cannot be able to disable the above features anyway. Like when I enable location and other permissions through DevicePolicyManager user is unable to turn it off.

Upvotes: 1

Views: 756

Answers (1)

Morrison Chang
Morrison Chang

Reputation: 12121

So reviewing: https://developers.google.com/android/work/requirements#4.2.-runtime-permission-grant-state-management_1

and https://developers.google.com/android/management/reference/rest/v1/enterprises.policies#permissionpolicy

seem to indicate at you can create a policy which will automatically grant permissions.

I do see: PERMISSION_POLICY_AUTO_GRANT

Permission policy to always grant new permission requests for runtime permissions. Already granted or denied permissions are not affected by this.

and

PERMISSION_GRANT_STATE_GRANTED

Runtime permission state: The permission is granted to the app and the user cannot manage the permission through the UI.

which sounds like what you want.

Upvotes: 2

Related Questions