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?
The method shouldShowRequestPermissionRationale() can be used to check whether the user selected the 'never asked again' option and denied the permission.
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 .
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.
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 ......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With