Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug/reset Android 6.0 permissions?

Tags:

While migrating one of my apps to use the Android 6.0 permissions system, I found it very hard to debug permissions using the emulator.

Findings:

  • Disabling a permission in the app info screen doesn't re-show the grant permission dialog when using the requestPermissions() method.
  • Reinstalling the app seems to be the only way to make the app show the grant permission dialog again.

What is the proper method to debug permission using the Android emulator?

like image 803
Rolf ツ Avatar asked Dec 29 '15 14:12

Rolf ツ


People also ask

What are the permission protection levels in Android?

The three permission protection levels in Android are as follows: Normal Permissions. Signature Permissions. Dangerous Permissions.

How do I check permissions granted on Android?

To check if the user has already granted your app a particular permission, pass that permission into the ContextCompat. checkSelfPermission() method. This method returns either PERMISSION_GRANTED or PERMISSION_DENIED , depending on whether your app has the permission.

What are normal permissions in Android?

Normal permissions include: ACCESS_NOTIFICATION_POLICY, ACCESS_WIFI_STATE, BLUETOOTH, BLUETOOTH_ADMIN, INTERNET, KILL_BACKGROUND_PROCESSES, MANAGE_OWN_CALLS, MODIFY_AUDIO_SETTINGS, SET_ALARM, SET_WALLPAPER, VIBRATE etc.


1 Answers

It’s actually very easy to debug Android 6.0 permissions. You can reset the permissions to the "install state" for the current foreground app all apps using the following ADB shell command:

adb shell pm reset-permissions 

Note: Currently you can't reset the runtime permissions for a specific package, the package manger (pm) tool help section states:

revert all runtime permissions to their default state.

You can easily execute the reset-permissions command using the terminal interface in Android Studio. Note that ADB commands only works if the ADB directory is added to the PATH system environment variable (see: add ADB to path variable).

You can also reset/revoke a specific permissions using:

adb shell pm revoke com.your.package android.permission.WRITE_EXTERNAL_STORAGE 

A downside of this command is that it will restart your app, but this doesn't reset the runtime permissions for all apps. To grant a permission replace revoke with grant.

like image 154
Rolf ツ Avatar answered Oct 03 '22 21:10

Rolf ツ