Search code examples
androidandroid-emulatoradblockscreen

android: manipulate screen lock settings via adb?


I'm in the process of setting up an automated testing environment which uses android emulators to test apps. This is a headless setup where the emulators are run under Xvfb, so manual interaction is not possible.

I need a programatic way to change (via adb or telnet) the screen lock settings on the emulator to never lock (equivalent to manually changing settings in the "screen lock" menu to "None"), particularly the emulator must be in the unlocked state right after startup.

Snapshots won't do because they must be taken after the change has been done, and reusing snapshots from other AVDs is not desireable because this setup must accommodate new android releases.

In other words, setup of a new AVD must be completely unattended.

I'm wondering if something like this would work, but I haven't been able to figure out how to get into the "Screen lock" sub-menu:

adb shell am start -a android.intent.action.MAIN -n com.android.settings/.SecuritySettings

Either way, is there a better way to achieve this?


Solution

  • I eventually figured it out:

    adb -s $SERIAL shell rm -f /data/system/locksettings.db*
    

    This will remove any lockscreen, setting it to "None" in the system settings.