Mad, Beautiful Ideas
Undoing a Lockout on an Android Phone

Over the weekend I ran into a major problem with my Android-based phone. While we were moving into our new condo, I had the phone in my pocket, and had somehow triggered the touch screen pattern-unlock mechanism, and proceeded to accidentally lock out my phone badly enough that it was demanding my username and password to unlock the device.

Unfortunately, I apparently can't remember that password.

Fortunately, if you have debugging over USB enabled, you can hack your way into the phone.

Yes, this is a security vulnerability, but most any device has some security problems when you have physical access to it, and at least in this case, you have to enable USB Debugging, which is only enabled by default on developer firmwares.

To perform this fix, you need to have the Android SDK, and your phone needs to appear on the output of adb devices. Google provides a Windows Driver, and most Linux distributions should work fine. Once you have the device attached, just execute the following.

        $ adb -d shell
        # sqlite3 data/data/com.android.providers.settings/databases/settings.db    
        sqlite> update system set value=0 where name='lockscreen.lockedoutpermanently';
        sqlite> .exit
        # exit
        

The effect should be almost immediate. Press the 'Menu' button on your phone, and you'll be prompted for your pattern. If you've, for some reason, forgotten what your pattern is, you can follow these instructions to disable the pattern prompt, which was the basis for my solution.