5

I develop an app and support Android 6.0. When I reset app preferences in Settings -> Apps -> Reset app preferences, all permissions of my app are revoked and the app is not restarted. Failure to restart the app after revoking its permissions can cause many unexpected crashes.

How should I handle this case?

The app is restarted when I revoke its permissions manually (Settings -> Apps -> My app -> Permissions).

wwang
  • 605
  • 1
  • 5
  • 13
Maksim Dmitriev
  • 5,985
  • 12
  • 73
  • 138

1 Answers1

5

I can reproduce the problem. I have filed an issue in regards to it.

How should I handle this case?

Since this is a fairly low-probability event (how many users are ever going to find that option, let alone blow past the warning dialog and actually do it?), personally, I wouldn't worry about it too much.

Since there is no documented setOnPermissionChangeListener() or ACTION_DUDE_YOUR_PERMS_WUZ_WHACKED or anything to find out about the permission change, there is not a lot you can really do here. Having checkSelfPermission() calls as close as possible to calling the protected APIs will help reduce the window of time where you are at risk of a permission being revoked behind your back.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 2
    BTW, I wrote [a blog post](https://commonsware.com/blog/2015/11/24/securityexceptions-runtime-permissions-reset-app-preferences.html) with a little more about the situation. – CommonsWare Nov 24 '15 at 18:21
  • 1
    Per the bug report, looks like this has been resolved in Android 7.0. – mike47 Jan 02 '17 at 23:20
  • @CommonsWare can you suggest me how to clear ongoing call notification when user revoke the permission. – Ajit Kumar Dubey Jul 14 '17 at 08:40
  • @AjitKumarDubey: If you are saying that the `Notification` survives the process termination, I have no good solution for that. However, this is very much an edge case, and if the user revokes a permission, the user will have to deal with a possibly-pointless `Notification`. – CommonsWare Jul 14 '17 at 11:01