The Android API level 23 (Marshmallow) introduced a new set of methods to deal with permissions in its new run-time permission model. From the class DevicePolicyManager (which only can be called by profile/device owner), there is a method called setPermissionGrantState(admin, packageName, permission, grantState). This method works perfectly for enforcing policies over application's permissions, but I found out that when a permission is denied, e. i., PERMISSION_GRANT_STATE_DENIED is used as a grantState value and the application which is being revoked the permission is running, suddenly crashes. I did some research and tried many possible ways for understanding what is happening... It seems that a revoked permission kills the application processes (like a SIGSTOP is performed), no matter which resource.
It doesn't happen because an application cannot handle the fact of not having a resource (for example location). After the application crash, if I launch the application again is works perfectly without the resource in question;
I tried to caught the crash implementing the UncaughtExceptionHandler, and seems no exception was thrown;
If PERMISSION_GRANT_STATE_GRANTED is used, the application doesn't crash. Application 1 ---> (PERMISSION_GRANT_STATE_GRANTED) - no crash.
I don't know if this is supposed to be working like this or if it is a bug?
I'm seeking help for circumventing the crash, which is making impact in my project.