I\'m using Espresso and UIAutomator to write my test cases. I\'m testing external storage permissions when it\'s denied and when it\'s allowed. I have different test cases w
You can't. Grant/Revoke permissions is under user control.
However, you can grant/revoke permissions via adb and you can trigger adb commands programmatically, but I have no idea if this works in combination?...
adb shell pm grant [app.package] [permission]
adb shell pm grant com.app.package.path android.permission.READ_CONTACTS
(look here)
You might map your permissions to boolean value for testing purposes?