Android: Too Many Pattern Attempts. Phone is locked.

There you are, showing off your Android and that funky pattern lock feature. But you didn’t think that some joker would try too many times and lock your phone for good. Not to bad, since you just need to wait 30 seconds to retry – or?

Not quite, if you do it too often, the phone will lock you out for good and you can only unlock by either wiping your phone or by logging into your Google account. The Google account feature sounds reasonable and easy — but wait, your Wifi switch is not on (and you can only turn it on when unlocked).

Not all is lost, provided your phone is rooted and you have the Android toolkit installed (if “adb” means something to you, then read on):

Do the following:

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

The above commands will connect to your settings-database and then disable the autolock as well as reset the permanent lock.

Your Android phone does not have sqlite3

If you Android does not have sqlite3, download a pre-built binary from http://www.sqlite.org/download.html and then run the following commands (you will need to copy the pre-built sqlite3 first to your Android phone)

> ./adb push sqlite3 /cache/sqlite3
> ./adb shell
chmod 777 /cache/sqlite3
/cache/sqlite3 /data/data/com.android.providers.settings/databases/settings.db
sqlite> update system set value=0 where name='lock_pattern_autolock';
sqlite> update system set value=0 where name='lockscreen.lockedoutpermanently';
sqlite> .exit
rm /cache/sqlite3 # optional