Unlocking the emulator or device for Android test -
Unlocking the emulator or device for Android test -
i writing android functional tests. need device awake , application visualized in order them work. have consulted android developers that. however, there several problems proposed solution:
the proposed method has several deprecated methods. android api advises me utilize flags on window:this class deprecated in api level 13. utilize flag_dismiss_keyguard and/or flag_show_when_locked instead; allows seamlessly hide keyguard application moves in , out of foreground , not require special permissions requested. handle returned newkeyguardlock(string) allows disable / reenable keyguard.
i tried suggestion, however, opposed deprecated solution, flag 1 jsut not work me - not unlock device. found sources confirming instability of flag solution (e.g. comments on this answer).
the sec problem need add together permissions application under test. find quite wrong approach (modifying code under test in order able test it). found several places advise me utilizesrc/debug/androidmanifest.xml
(this one , this one example). however, not happen stated - debug mainfest not included deployed things on device. related way build , deploy? utilize eclipse development (adt). manifest injection work if utilize build tool ant? all in - can advise on stable solution unlcoking , keeping awake device while test beingness executed?
edit
i have found robotium included unlockscreen
method in latest version of framework. uses window flags proposed above , not working on device.
i've had same problems unreliable unlocking when running robotium tests. did not find solution programmaticly unlock devices worked reliably, there 2 things did work-around.
just disable lock screen (settings -> security -> screen lock -> none
). not ideal @ end of day, reliable tests of import thing.
enable "stay awake" settings maintain screen turning off due inactivity (settings -> developer options -> remain awake
). oem/phones either don't have alternative or still turn off anyways, pesky devices installed keepscreenon app.
warning: leaving screen on, sitting on home screen, 24 hours day may cause screen burn-in/ghosting. i'm not sure if permanent, aware of this. in our case, using dedicated test devices not big deal.
also note since phones have screen on @ times, may want dim brightness utilize less battery powerfulness (charging on usb can slow sometimes).
android android-manifest robotium android-testing keyguard
Comments
Post a Comment