android adb turn on wifi via adb [duplicate]

荒凉一梦 提交于 2019-11-28 16:25:11

This works really well for and is really simple

adb -s $PHONESERIAL shell "svc wifi enable"

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.

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.

varunarl

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.

Tim

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.

shkschneider

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".

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';
braa

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.

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/

Androidian

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

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.

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.

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.

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

svc wifi [enable|disable]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!