30

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?

0

14 Answers 14

60

This works really well for and is really simple

adb -s $PHONESERIAL shell "svc wifi enable"

Sign up to request clarification or add additional context in comments.

4 Comments

adb devices to display the serial number...
not working on all devices, a few Samsung devices displaying devices dumpstate instead of changing the wifi state.
Can confirm that it doesnt work on 3 of my devices which are samsung ones. Samsung Tab 3 is one of them
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: forum.xda-developers.com/showthread.php?t=2438174
12

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.

5 Comments

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
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.
Dude ... you just saved my phone from a factory reset... Big thanks! :D
You should really use adb shell scv wifi enabled for this instead of monkeying directly with the database.
this works... but do you know a better way instead rebooting the device for apply the edit?
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.

2 Comments

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!
This trick will work for all Samsung Android devices? I have s2!
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.

2 Comments

how would i click the switch ? the input you suggested click on the first network for , where can i see the key event options ?
your '&' should be a '&&'; ie adb shell input keyevent 20 && adb shell input keyevent 23
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.

8 Comments

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
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.
Unfortunately I fill in my sign in data but nothing happens. And I cant turn on my wifi connection
androidtablets.net/forum/android-tablet-usage-tips-tricks/… See the adb commands. Could be useful if unable to enable WiFi?
I saw this too. I need root access to access the data/ folder. But my device hasn't root access
|
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".

4 Comments

Ive already tried it. Maybe its not working because "too many pattern attempts" screen locks screen? Or may be its because I have android 4 installed
Well, if this is the Google policy regarding privacy on your Android phone, you'll need internet or a factory reset. Sorry.
your '&' should be '&&'
indeed Max, thx: edited
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';

1 Comment

this works... but do you know a better way instead rebooting the device for apply the edit?
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.

1 Comment

Some/old versions of android dont have "mobile data" in the power off menu
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/

Comments

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 :)

2 Comments

maybe you had another type of connection. 3g or something else?...
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 :)
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.

Comments

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.

1 Comment

It was not possible to me to enable it from stock android 4 version
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.

Comments

0

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

svc wifi [enable|disable]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.