Background
I'm trying to create an app that can grant and revoke permissions of other apps.
To do this I'm using adb commands:
pm grant packageName permissionName
This works great if I call it through a shell with root permissions.
Problem
The problem is that when I call this command without root permissions, I receive
Operation not allowed: java.lang.SecurityException: grantRuntimePermission: Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS
This is to be expected (it would be a big problem otherwise).
Question
Is it possible to allow my app to manage other apps permissions through Android settings?
I'm looking for something like granting USAGE_STATS permission to an app going to Settings -> Security -> "App with usage access", but for GRANT_RUNTIME_PERMISSIONS (and REVOKE_RUNTIME_PERMISSIONS).