android adb 通过 adb 打开 wifi

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10282484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:08:42  来源:igfitidea点击:

android adb turn on wifi via adb

androidandroid-wifi

提问by pleerock

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.

我的手机已被锁定(模式尝试次数过多)。要解锁,我需要在我的 Gmail 帐户中输入用户名和密码。这是我解锁它的唯一方法。我无法启动任何活动,甚至无法打开 wifi 连接。没有互联网连接,我无法登录以恢复我的手机。

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

也许 adb 中有任何命令可以打开我的 wifi 连接,以便我可以使用我的手机?

采纳答案by pleerock

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

不幸的是,我能解决问题的唯一方法是 root 设备。

Here is a good tutorial for Nexus S:

这是一个很好的 Nexus S 教程:

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

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

回答by devin

This works really well for and is really simple

这非常适合并且非常简单

adb -s $PHONESERIAL shell "svc wifi enable"

adb -s $PHONESERIAL shell "svc wifi enable"

回答by D__

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

可以通过像这样更改 settings.db 来启用 WiFi:

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.

您可能需要在更改此设置后重新启动才能真正打开 WiFi。

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

此解决方案来自一篇博客文章,该文章指出它适用于 Android 4.0。不知道之前的版本是不是一样。

回答by Thiago

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.

您可以打开 wifi: - 在电脑上连接 USB;- 将显示警报对话框“连接 UMS 模式或 KIES” - 不要点击,不要取消 - 拉通知栏并打开 wifi。

回答by 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
  1. 打开设备
  2. 插入 USB 数据线
  3. 您将看到打开 USB 存储的屏幕。
  4. 拉下通知抽屉
  5. 打开wifi/数据

Tested on AT&T Fusion working fine.

在 AT&T Fusion 上测试工作正常。

Method 2:

方法二:

Use the method given by shkschneider

使用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.

这仅在您打开 USB 调试时才有效。如果您没有在开发下打开 USB 调试,请执行以下操作。

  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
  1. 关闭设备。
  2. 启动进入恢复模式(电源按钮 + 音量调高)
  3. 将设备插入计算机。
  4. 使用 ADB 工具执行 shkschneider 给出的相同命令

Tested on AT&T fusion working fine.

在 AT&T 融合上测试工作正常。

回答by Tim

See these answers:

看到这些答案:

How to turn off Wifi via ADB?

如何通过 ADB 关闭 Wifi?

Connecting to wi-fi using adb shell

使用 adb shell 连接到 wi-fi

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.

但是,我很确定 Google 实际上会在此类时间存储您的电子邮件和密码(在保存到设备时)。因此,当需要解锁时,它不需要互联网连接。

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.

祝你好运。

回答by shkschneider

You should start the WiFi activity from adbthen simulate inputs:

您应该从adb然后模拟输入开始 WiFi 活动:

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 adbinputs: #7789826

这是adb输入列表:#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".

我不确定这些关键事件是否适合您的情况,但我认为可以。它模拟了“向下”选择第一个复选框,然后是“输入”。

回答by Dar

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:

在我的 ROM 中,它存储在“全局”数据库中,而不是“安全”数据库中。所以 D__ 的答案是正确的,但是 sql 行需要连接到不同的数据库:

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

回答by 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.

这太容易了,伙计。只需按下电源按钮,直到您看到“电话选项”屏幕并打开移动数据。之后,您可以登录您的帐户或远程解锁您的设备。

回答by user4552386

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.

问题是手机没有 wifi 连接被锁定,没有 root 和 USB 调试禁用(地狱,可能的情况更糟)。无法使用 ADB,因为“Adb 设备”无法检测禁用 USB 调试的设备。尝试恢复模式(无法进入)。尝试紧急模式(Adb 仍然没有检测到设备)。当我几乎放弃并且距离硬重置仅一英寸时,发生了一些奇怪的事情。当我像往常一样将手机连接到 USB 时,出现了 USB 输入屏幕。没什么新鲜的。我当时注意到的是,在这个屏幕中,实际上可以降低下拉栏和宾果游戏……我能够打开 wifi。然后刚刚输入谷歌帐户和手机被解锁。

Hope I helped someone.

希望我帮助了某人。

回答by Noel Carriqui

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

无需直接编辑任何数据库,它有一个命令:)

svc wifi [enable|disable]

svc wifi [启用|禁用]