android adb turn on wifi via adb [duplicate]

2019-01-21 06:10发布

This question already has an answer here:

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?

14条回答
该账号已被封号
2楼-- · 2019-01-21 06:28

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

svc wifi [enable|disable]

查看更多
闹够了就滚
3楼-- · 2019-01-21 06:35

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.

查看更多
我命由我不由天
4楼-- · 2019-01-21 06:39

This works really well for and is really simple

adb -s $PHONESERIAL shell "svc wifi enable"

查看更多
孤傲高冷的网名
5楼-- · 2019-01-21 06:39

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/

查看更多
看我几分像从前
6楼-- · 2019-01-21 06:39

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.

查看更多
▲ chillily
7楼-- · 2019-01-21 06:40

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.

查看更多
登录 后发表回答