Android revoke permission at start of each test

后端 未结 6 850
花落未央
花落未央 2021-01-17 11:49

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

6条回答
  •  离开以前
    2021-01-17 12:00

    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?

提交回复
热议问题