Authorize Android Instrumentation Test for Root Access on Emulator -
i have developed android app requires root access, , works fine. trying test app using instrumentation tests activityinstrumentationtestcase2
, cover parts of app utilize root access. tests should automated run on our ci. ci build creates fresh emulator, , roots emulator using next commands:
adb -e install superuser.apk adb shell mount -o rw,remount -t yaffs2 /dev/block/mtdblock03 /system adb force su /system/xbin/su adb shell chmod 06755 /system adb shell chmod 06755 /system/xbin/su
it works ok, @ point have click "allow" button on superuser's root access prompt when test requires it. problem how execute tests without manual clicking "allow" button , gain root access.
if seek click button instrumentation test using next code
instrumentation.sendkeydownupsync(keyevent.keycode_dpad_center);
i
java.lang.securityexception: injecting application requires inject_events permission
apparently, privilege used scheme apps, , cannot authorize apps permission. maybe doing wrong here?
another thought pre-authorize app during emulator boot command line, haven't found way this.
you going have lots of issues approach, automate button press using different framework other instrumentation (e.g. monkey/http://developer.android.com/tools/testing/testing_ui.html) vote utilise snapshots/a custom disk image emulator, create own snapshot/image has phone rooted , can should able launch emulator , tell utilize snapshot has root access already.
android android-emulator integration-testing instrumentation root-access
No comments:
Post a Comment