Hi! Does anyone know how to revoke a permission be...
# android
a
Hi! Does anyone know how to revoke a permission before a UI test? I use GrantPermissionRule to grant Location permission but once granted it stays granted and I can’t test the case when permission is not granted.
m
adb shell pm revoke com.name.app android.permission.READ_PROFILE
a
and you can it in @after method during instrumented tests?
m
a
Hum... perfect, I’ll try it. It’s crazy that there’s almost no resources about testing permissions on the web.
If anyway you heard about nice articles about it I’ll be really interested
I managed to have it working after lot of researches (not well documented). Here is how I revoke permission:
Copy code
val uiAutomation = InstrumentationRegistry.getInstrumentation().uiAutomation
uiAutomation.executeShellCommand("pm revoke ${getTargetContext().packageName} $ACCESS_FINE_LOCATION")