27

My phone has been locked (too many pattern attempts). To unlock I need to enter username and password on my gmail account. This is the only way I can unlock it. I cant launch any activities, even to turn on wifi connection. Without internet connection I can't sign in to restore my phone.

Maybe there is any command in adb to turn on my wifi connection, so I can use my phone?

pleerock
  • 18,322
  • 16
  • 103
  • 128

14 Answers14

51

This works really well for and is really simple

adb -s $PHONESERIAL shell "svc wifi enable"

devin
  • 6,407
  • 14
  • 48
  • 53
  • 3
    `adb devices` to display the serial number... – saiy2k Jan 26 '14 at 15:47
  • 3
    not working on all devices, a few Samsung devices displaying devices dumpstate instead of changing the wifi state. – Hayi Nukman Apr 14 '15 at 07:53
  • 1
    Can confirm that it doesnt work on 3 of my devices which are samsung ones. Samsung Tab 3 is one of them – fedmich Jan 23 '17 at 10:04
  • It looks like these days either the phone must be rooted or SELinux needs to be "Permissive" (not usually the default) in order for this command to work. Otherwise it just comes back with "Killed". Source: https://forum.xda-developers.com/showthread.php?t=2438174 – Ben Jul 29 '17 at 22:32
11

WiFi can be enabled by altering the settings.db like so:

adb shell
sqlite3 /data/data/com.android.providers.settings/databases/settings.db
update secure set value=1 where name='wifi_on';

You may need to reboot after altering this to get it to actually turn WiFi on.

This solution comes from a blog post that remarks it works for Android 4.0. I don't know if the earlier versions are the same.

D__
  • 127
  • 2
  • 6
  • 4
    Yes you are right. But you can access the data folder only if your device is ROOTed. So, my device wasn't. Ive rooted it and it cleared all the data including this lock – pleerock Jun 27 '12 at 07:48
  • Ah. I had the same exact problem as the question, although with a rooted device. This was the only solution short of factory reset once you're stuck on the Google account unlock screen. – D__ Jun 28 '12 at 18:27
  • 1
    Dude ... you just saved my phone from a factory reset... Big thanks! :D – tftd Oct 23 '12 at 00:11
  • 1
    You should really use adb shell scv wifi enabled for this instead of monkeying directly with the database. – rharter Nov 25 '13 at 14:00
  • 1
    this works... but do you know a better way instead rebooting the device for apply the edit? – BQuadra Jan 31 '14 at 03:00
7

You can turn on wifi : - connect usb on pc; - will show alert dialog "connect UMS mode or KIES" - do not click, do not cancel - pull notification bar and turn on wifi.

Thiago
  • 71
  • 1
  • 2
  • 1
    THIS GUY! You deserve a medal! Very nice solution (certainly for my situation). Need to get this answer out there more, much nicer than resetting a phone and perfect if WiFi is off and phones locked out! Perfect! – Chris Apr 29 '13 at 18:27
  • This trick will work for all Samsung Android devices? I have s2! – LOG_TAG Aug 26 '13 at 04:08
7

Try out the following which did work for me.

Method 1:

  1. Turn on the device
  2. Plug in the USB cable
  3. You will get the screen for turn on USB storage.
  4. Pull down the notification drawer
  5. Turn on wifi/Data

Tested on AT&T Fusion working fine.

Method 2:

Use the method given by shkschneider

adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
adb shell input keyevent 20 & adb shell input keyevent 23

This works only if you have USB debugging turned on. If you do not have USB debugging turned on under Development do the following.

  1. Turn off the device.
  2. Boot into recovery mode (Power button + Volume up)
  3. Plug the device into computer.
  4. Use the ADB tool to execute the same commands given by shkschneider

Tested on AT&T fusion working fine.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
varunarl
  • 291
  • 3
  • 4
3

See these answers:

How to turn off Wifi via ADB?

Connecting to wi-fi using adb shell

However, I'm pretty sure that Google actually stores your email and password (at the time of saving to the device) for times like these. So when it needs to be unlocked, it won't require an internet connection.

I could be wrong. Either way, when I had this issue, I had internet connectivity, and I knew my username and password and it didn't care, kept saying they were wrong (even though I was logging into my email). Had to format the phone at the time!

Good luck.

Community
  • 1
  • 1
Tim
  • 8,932
  • 4
  • 43
  • 64
  • Ive already seen this answers. They didn't help me. And sign in requires Internet connection, since Google doesn't store your email and password. Its bad politics – pleerock Apr 23 '12 at 14:38
  • What I'm saying, to unlock your phone after too many attempts, doesn't actually sign-in to the Google service. If it needed to, your particular use-case makes the feature useless. And the use-case is pretty obvious. Password would not be stored, a hash would be. – Tim Apr 23 '12 at 14:43
  • Unfortunately I fill in my sign in data but nothing happens. And I cant turn on my wifi connection – pleerock Apr 23 '12 at 14:47
  • http://www.androidtablets.net/forum/android-tablet-usage-tips-tricks/6280-forgot-your-unlock-pattern.html See the adb commands. Could be useful if unable to enable WiFi? – Tim Apr 23 '12 at 14:52
  • I saw this too. I need root access to access the data/ folder. But my device hasn't root access – pleerock Apr 23 '12 at 15:06
  • Could be your only option to get back into your phone without factory resetting it then, if the other WiFi options aren't working. Browse http://www.xda-developers.com/ they may even have a better solution. But if all fails, root your phone and then try that androidtablets.net article – Tim Apr 23 '12 at 15:11
  • Obvious point, assumed you have already tried... but can you not use 3G to connect the network? On my S2 for example, even when locked I can hold the power button and enable/disable data that way. – Tim Apr 23 '12 at 15:22
  • Unfortunately no. I have nexus S and its pure android 4 which hasn't this option – pleerock Apr 23 '12 at 15:25
3

You should start the WiFi activity from adb then simulate inputs:

adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
adb shell input keyevent 20 && adb shell input keyevent 23

Here is the list of adb inputs: #7789826

I'm not sure if those keyevents are the right one for your case, but I think it will do. It simulated a "down" to select the first checkbox, then an "enter".

shkschneider
  • 17,833
  • 13
  • 59
  • 112
2

In my ROM, it's stored in the "global" database, rather than "secure". So D__'s answer is correct, but the sql line needs to connect to a different database:

sqlite3 /data/data/com.android.providers.settings/databases/settings.db
update global set value=1 where name='wifi_on';
Dar
  • 21
  • 1
1

It's so easy, man. Just press on the power button until you see the "Phone Options" screen and turn on mobile data. After that you can sign into your account or remotely unlock your device.

Ian Hazzard
  • 7,661
  • 7
  • 34
  • 60
braa
  • 11
  • 1
0

Unfortunately the only way I could resolve my problem is to root the device.

Here is a good tutorial for Nexus S:

http://nexusshacks.com/nexus-s-root/how-to-root-nexus-s-or-nexus-s-4g-on-ics-or-gingerbread/

pleerock
  • 18,322
  • 16
  • 103
  • 128
0

I was having the same problem. my phone was locked and the wi-fi was off, but I signed into my gmail account and it was unlocked.

Hope this helps someone :)

Marko
  • 20,385
  • 13
  • 48
  • 64
Androidian
  • 11
  • 2
  • maybe you had another type of connection. 3g or something else?... – pleerock Aug 14 '12 at 03:43
  • no. i was offline but when i logged-in to the account, it was successful. i think the phone remember the user name and password. i was happy to see that :) – Androidian Aug 15 '12 at 07:12
0

If you are locked out and WiFi is turned off in your Androud device then one solution is to connect your phone to a PC (connected to internet) and try to login with your google account. - it worked for me.

ramz
  • 1
0

I was in the same situation on a Samsung Mini II. I got around it eventually by holding down the power button until the "power off" menu appeared. From this menu it was possible to enable the network data connection.

Then signing in to my google account using @googlemail.com (rather than @gmail.com) seemed to do the trick. Though the change of address may just have given the phone time to warm up the 3g connection rather than making any real difference.

Matt
  • 1
0

Not sure if this rather simple solution is already posted here somewhere.

The problem is locked phone w/o wifi connection, not rooted and USB debugging disable (hell, worse possible situation). ADB can not be used since "Adb devices" do not detect device with USB debugging disabled. Tried recovery mode (can not enter it). Tried emergency mode (Adb still don't detect device). When I almost gave up and was like an inch from hard reset something strange happens. When I connect a phone to USB as usual USB entry screen appeared. Nothing new. What I noticed then is that in this screen it is actually possible to lower a drop down bar and bingo....I was able to turn wifi ON. And then just entered google account and phone was unlocked.

Hope I helped someone.

0

No need to edit any database directly, there is a command for it :)

svc wifi [enable|disable]