I want to write tests for an application that uses the android device administration API . My problem is that the user needs to manually grant one-time approval for the application to have admin rights, otherwise a SecurityException
is thrown at runtime.
a user can manually enable/disable admin rights for applications by going to settings->location & security -> select device administators.开发者_运维知识库 I would like to do it programmatically from within an AndroidTestCase
.
I did not find a way to grant admin automatically.
Luckily, however, the AVD remembers that the application was granted admin and does not revoke it after installing a later version of the same app. Thus, after a manual one-time process of enabling admin on the emulator I can run all my tests that require admin, as long as i don't switch to another AVD.
精彩评论