Posts Tagged With: Pattern lock

Unlock an Android Device without Internet Access – Using ADB commands


Problem

My Android tablet is  locked because too many wrong pattern attempts.  When entering a wrong pattern 20 times (you may be not stupid to enter it wrong 20 times, but your child or someone else who wants to lock your device what happen ? ) your devices is locked and asking to unlock it via your google username and password. You are lucky if the device locked with Wifi on or mobile data network on. Then you can simply log into the google account and unlock it. But I’m not that much lucky and my tablet was in “Airplane mode on” with “Wifi off”.

Android device lock with too many pattern attempts

Android device is locked with too many pattern attempts

Android should have a method to turn on wifi or mobile networks when device is locked. But no, there is no such a method :-/

Solution

I did lot of google searches and most of them end up with hard resetting the device. If you hard reset all the data are gone. I tried it too, but because of some problem(it may be the device model), my resetting was stuck in middle of the process. Finally I found a solution to access the device from a PC via a USB cable (ADB Commands). For this method you have to have enabled USB Debugging on the device before it is locked. Luckily I had enabled it before it is locked.  (As I saw, for rooted users USB Debugging is not required — but you might need to manually mount the/data partition. Actually I didn’t try it and don’t know how to do it as my USB debugging is enabled.)

Ok here is the solution for devices which have enabled USB debugging ,

Open the command prompt (cmd) in Windows

Change directory to the android SDK platform tools (cd C:\Program Files\Android\android-sdk\platform-tools)

Type following commands in cmd

  • adb devices (verify device is identified by pc. If not reconnect device and try again. it should display “device” with a serial no)
  • adb shell
  • cd /data/data/com.android.providers.settings/databases
  • sqlite3 settings.db
  • update system set value=0 where name='lock_pattern_autolock';
  • update secure set value=0 where name='lock_pattern_autolock'; (for some devices update “system” is enough but I had to update “secure” too)
  • update system set value=0 where name='lockscreen.lockedoutpermanently';
  • update secure set value=0 where name='lockscreen.lockedoutpermanently';
  • .quit
  • exit
  • adb reboot

Now your device should be unlocked. If not do this step too,

  • adb shell rm /data/system/gesture.key (I didn’t have to do it. But it had mentioned here)

Here what I have done is clear lock patterns and remove the permanent lock from the database. Yes here I have break the security, but saved my device as can be used again. If you are concern about the security of your device “Always keep off USB debugging mode“. But I don’t know what will happen to your important data when someone locked your device.

So did you solve your problem and save your device ? Then don’t forget to like my fb page. ONLY IF YOU HAD A SOLUTION FROM THIS 😉

If you know about a better solution, add it as a comment here. It will help others too.

Update 18-05-2013

Important Comments

ryo : https://chethaka.wordpress.com/2013/02/28/unlock-an-android-device/#comment-87

Ashutosh : https://chethaka.wordpress.com/2013/02/28/unlock-an-android-device/#comment-110

checky : https://chethaka.wordpress.com/2013/02/28/unlock-an-android-device/#comment-114

Categories: Android | Tags: , , , , , , , , , , , | 281 Comments

Create a free website or blog at WordPress.com.