0

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.

  1. 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;

  2. I tried to caught the crash implementing the UncaughtExceptionHandler, and seems no exception was thrown;

  3. 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.

  • "It seems that a revoked permission kills the application processes (like a SIGSTOP is performed), no matter which resource" -- since Android terminates the affected process when the user toggles the permission off in Settings, I would expect the same thing to be done here. Beyond that, what "suddenly crashes" -- your code, or the app whose process is being terminated? If the latter, there is nothing that you can do about that, other than not revoking the permission. If your code is crashing, examine the stack trace, and post it here if you do not understand what you are seeing. – CommonsWare Sep 14 '16 at 19:11
  • Thanks for your reply. I just tested and you are right, and I was not aware that revoking in settings a permission manually would crash an app. What I meant is that the application process are terminated just as revoking in settings. There is no way around this then? – fvcpinheiro Sep 14 '16 at 20:06
  • "would crash an app" -- I assume that you mean "terminate the process". "There is no way around this then?" -- short of building your own version of Android where you change this behavior? No, AFAIK. – CommonsWare Sep 14 '16 at 20:15
  • This is an example of why i always set target SDK = 22. :) – Nerdy Bunz Sep 14 '16 at 23:29
  • I don't understand what you mean. SDK = 22 doesn't have this function... – fvcpinheiro Sep 14 '16 at 23:43

0 Answers0