Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Marshmallow Permissions Tests

I came across this issue in our team: We want to test interactions with the calendar and we obviously need calendar write permission in order to do this. Is there a way to make sure necessary permissions are in place for instrument tests? I know you can virtually grant permissions on a specific avd but is there a better way of doing this?

like image 337
Eloy_007 Avatar asked Nov 12 '15 13:11

Eloy_007


People also ask

How do I check if permission is permanently denied Android?

The method shouldShowRequestPermissionRationale() can be used to check whether the user selected the 'never asked again' option and denied the permission.

How do you check auto start permission is enabled or disabled programmatically?

There's no way to find out whether the Auto-start option is enabled or not. You can manually check under Security permissions => Autostart => Enable Autostart .

Can Android app bypass permissions?

Once an app attempts to use a protected feature but failed to declare the required permission, the runtime system typically throws a security exception, which then terminates the app. Given these facts, it appears that the chances of bypassing permissions is slim.


1 Answers

You can grant and revoke permissions using:

adb pm grant com.package.myapp android.permission.<PERMISSION>
adb pm revoke com.package.myapp android.permission.<PERMISSION>

Update for Android Debug Bridge (adb) version 1.0.32:

You need to add shell to run these commands, e.g. ./adb shell pm grant ......

like image 98
Rahul Soni Avatar answered Oct 19 '22 19:10

Rahul Soni