我有连接到一个特定接入点的所有细节。我必须只使用那个接入点,所以我所需要的只是执行此操作的命令。
7xllpg7q1#
迟到了,但我想出了一个方法来实现这一点的设备没有根。它可能不漂亮,但它工作。基本上,我的建议是创建一个应用程序,该应用程序基于启动应用程序时给定的EXTRAS加入接入点。然后使用am命令的-e <KEY> <VALUE>参数提供EXTRAS。我已经构建了一个这样做的应用程序,它可以在这里使用:https://github.com/steinwurf/adb-join-wifi安装应用程序后,可以使用以下ADB命令加入WiFi接入点:
EXTRAS
am
-e <KEY> <VALUE>
ADB
adb shell am start -n com.steinwurf.adbjoinwifi/com.steinwurf.adbjoinwifi.MainActivity -e ssid [SSID] -e password_type [PASSWORD_TYPE] -e password [WIFI PASSWORD]
字符串在Github上的README中有更多信息。希望它能帮助某人。
vshtjzan2#
您可以自己在wpa_supplicant.conf中添加网络条目(或在脚本中)本质上手动连接一次,然后执行:
adb pull /data/misc/wifi/wpa_supplicant.conf
字符串并将网络条目集成到脚本中以实现自动化。简单脚本示例:
#!/bin/bash## Get this information by connecting manually once, and do# adb pull /data/misc/wifi/wpa_supplicant.confADB_PULL="adb pull /data/misc/wifi/wpa_supplicant.conf"WIRELESS_CTRL_INTERFACE=wlan0WIRELESS_SSID=GondolinWIRELESS_KEY_MGMT="WPA-EAP IEEE8021X"WIRELESS_EAP=PEAPWIRELESS_USER=TurgonWIRELESS_PASSWORD=IdrilCelebrindaladb start-serveradb wait-for-deviceecho "adb connection....[CONNECTED]"adb rootadb wait-for-deviceadb remountadb wait-for-devicepushd /tmprm wpa_supplicant.conf 2>/dev/null # Remove any old oneadbpull_status=`$ADB_PULL 2>&1`echo -e "\nAttempting: $ADB_PULL"if [ `echo $adbpull_status | grep -wc "does not exist"` -gt 0 ]; then echo " wpa_supplicant.conf does not exist yet on your device yet." echo "This means you have not used your wireless yet." echo "" echo "Taking our best shot at creating this file with default config.." echo "ctrl_interface=$WIRELESS_CTRL_INTERFACE" >> wpa_supplicant.conf echo "update_config=1" >> wpa_supplicant.conf echo "device_type=0-00000000-0" >> wpa_supplicant.confelse echo $adbpull_status echo " wpa_supplicant.conf exists!"fiecho ""echo "Add network entry for wpa_supplicant.conf.."echo "" >> wpa_supplicant.confecho "network={" >> wpa_supplicant.confecho " ssid=\"$WIRELESS_SSID\"" >> wpa_supplicant.confecho " key_mgmt=$WIRELESS_KEY_MGMT" >> wpa_supplicant.confecho " eap=$WIRELESS_EAP" >> wpa_supplicant.confecho " identity=\"$WIRELESS_USER\"" >> wpa_supplicant.confecho " password=\"$WIRELESS_PASSWORD\"" >> wpa_supplicant.confecho " priority=1" >> wpa_supplicant.confecho "}" >> wpa_supplicant.confecho "Pushing wpa_supplicant.conf.."adb push wpa_supplicant.conf /data/misc/wifi/wpa_supplicant.confpopd #/tmpadb shell chown system.wifi /data/misc/wifi/wpa_supplicant.confadb shell chmod 660 /data/misc/wifi/wpa_supplicant.confecho ""echo "Finished!"adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settingsecho "Please toggle wifi off/on now.. (ifconfig not sufficient, monkey this)"
#!/bin/bash
#
# Get this information by connecting manually once, and do
# adb pull /data/misc/wifi/wpa_supplicant.conf
ADB_PULL="adb pull /data/misc/wifi/wpa_supplicant.conf"
WIRELESS_CTRL_INTERFACE=wlan0
WIRELESS_SSID=Gondolin
WIRELESS_KEY_MGMT="WPA-EAP IEEE8021X"
WIRELESS_EAP=PEAP
WIRELESS_USER=Turgon
WIRELESS_PASSWORD=IdrilCelebrindal
adb start-server
adb wait-for-device
echo "adb connection....[CONNECTED]"
adb root
adb remount
pushd /tmp
rm wpa_supplicant.conf 2>/dev/null # Remove any old one
adbpull_status=`$ADB_PULL 2>&1`
echo -e "\nAttempting: $ADB_PULL"
if [ `echo $adbpull_status | grep -wc "does not exist"` -gt 0 ]; then
echo " wpa_supplicant.conf does not exist yet on your device yet."
echo "This means you have not used your wireless yet."
echo ""
echo "Taking our best shot at creating this file with default config.."
echo "ctrl_interface=$WIRELESS_CTRL_INTERFACE" >> wpa_supplicant.conf
echo "update_config=1" >> wpa_supplicant.conf
echo "device_type=0-00000000-0" >> wpa_supplicant.conf
else
echo $adbpull_status
echo " wpa_supplicant.conf exists!"
fi
echo "Add network entry for wpa_supplicant.conf.."
echo "" >> wpa_supplicant.conf
echo "network={" >> wpa_supplicant.conf
echo " ssid=\"$WIRELESS_SSID\"" >> wpa_supplicant.conf
echo " key_mgmt=$WIRELESS_KEY_MGMT" >> wpa_supplicant.conf
echo " eap=$WIRELESS_EAP" >> wpa_supplicant.conf
echo " identity=\"$WIRELESS_USER\"" >> wpa_supplicant.conf
echo " password=\"$WIRELESS_PASSWORD\"" >> wpa_supplicant.conf
echo " priority=1" >> wpa_supplicant.conf
echo "}" >> wpa_supplicant.conf
echo "Pushing wpa_supplicant.conf.."
adb push wpa_supplicant.conf /data/misc/wifi/wpa_supplicant.conf
popd #/tmp
adb shell chown system.wifi /data/misc/wifi/wpa_supplicant.conf
adb shell chmod 660 /data/misc/wifi/wpa_supplicant.conf
echo "Finished!"
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings
echo "Please toggle wifi off/on now.. (ifconfig not sufficient, monkey this)"
型
roejwanj3#
您可以使用命令adb shell cmd -w wifi connect-network和以下参数
- connect-network open|owe|wpa2|wpa3 [] [-m] [-d] [-b ] [-r auto|none|persistent|non_persistent] Connect to a network with provided params and add to saved networks list open|owe|wpa2|wpa3 - Security type of the network. - SSID of the network - Use 'open' or 'owe' for networks with no passphrase - 'open' - Open networks (Most prevalent) - 'owe' - Enhanced open networks - Use 'wpa2' or 'wpa3' for networks with passphrase - 'wpa2' - WPA-2 PSK networks (Most prevalent) -m - Mark the network metered. - 'wpa3' - WPA-3 PSK networks -d - Mark the network autojoin disabled. -h - Mark the network hidden. -p - Mark the network private (not shared). -b - Set specific BSSID. -r auto|none|persistent|non_persistent - MAC randomization scheme for the network
- connect-network open|owe|wpa2|wpa3 [] [-m] [-d] [-b ] [-r auto|none|persistent|non_persistent]
Connect to a network with provided params and add to saved networks list
open|owe|wpa2|wpa3 - Security type of the network.
- SSID of the network
- Use 'open' or 'owe' for networks with no passphrase
- 'open' - Open networks (Most prevalent)
- 'owe' - Enhanced open networks
- Use 'wpa2' or 'wpa3' for networks with passphrase
- 'wpa2' - WPA-2 PSK networks (Most prevalent)
-m - Mark the network metered.
- 'wpa3' - WPA-3 PSK networks
-d - Mark the network autojoin disabled.
-h - Mark the network hidden.
-p - Mark the network private (not shared).
-b - Set specific BSSID.
-r auto|none|persistent|non_persistent - MAC randomization scheme for the network
字符串要使用wpa2身份验证和密码“qwertyuiop”连接到wifi网络“Home”,请使用
adb shell cmd -w wifi connect-network Home wpa2 qwertyuiop
型要连接到一个开放的wifi网络“公共”使用
adb shell cmd -w wifi connect-network Public open
plupiseo4#
作为附加组件:您可以在设备上以root身份通过svc启用WiFi
svc wifi enable
字符串并通过
svc wifi disable
ghg1uchk5#
作为另一个附加组件:虽然我的设备是根我得到remote object ''/data/misc/wifi/wpa_supplicant.conf'' does not exist错误,而试图执行adb pull .它发生,因为adb本身不运行在根模式.要解决这个问题,你可以执行这样的东西
remote object ''/data/misc/wifi/wpa_supplicant.conf'' does not exist
adb pull
adb
adb shell "su -c 'cp -R /data/misc/wifi/wpa_supplicant.conf /data/misc/wpa_supplicant.conf'"adb shell "su -c 'chmod -R 777 /data/misc/wpa_supplicant.conf'"adb pull /data/misc/wpa_supplicant.confadb shell "su -c 'rm /data/misc/wpa_supplicant.conf'"
adb shell "su -c 'cp -R /data/misc/wifi/wpa_supplicant.conf /data/misc/wpa_supplicant.conf'"
adb shell "su -c 'chmod -R 777 /data/misc/wpa_supplicant.conf'"
adb pull /data/misc/wpa_supplicant.conf
adb shell "su -c 'rm /data/misc/wpa_supplicant.conf'"
字符串
qkf9rpyu6#
我通过这个解决问题:adb pull /data/misc/wifi/wpa_supplicant.conf ~/Desktop,然后编辑文件,添加网络模块,我的整个conf文件是:
adb pull /data/misc/wifi/wpa_supplicant.conf ~/Desktop
##### wpa_supplicant configuration file template #####update_config=1ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=wifieapol_version=1ap_scan=1fast_reauth=1network={ ssid="your ssid" psk="your pswd" key_mgmt=WPA-PSK priority=241}
##### wpa_supplicant configuration file template #####
update_config=1
ctrl_interface=DIR=/data/system/wpa_supplicant GROUP=wifi
eapol_version=1
ap_scan=1
fast_reauth=1
network={
ssid="your ssid"
psk="your pswd"
key_mgmt=WPA-PSK
priority=241
}
字符串然后rm原始文件,添加推到/data/misc/wifi文件夹,重新启动设备。请注意,不同的设备有不同的内容以上的网络线,不要修改这一部分。
/data/misc/wifi
o3imoua47#
虽然很晚了,但我希望这能帮助任何可能偶然发现这条线索的人。如果你正在尝试adb pull方法,但收到“remote object does not exist”,试试这个:在同一命令提示符框中,
adb shell
root@[device]:
cd /data/misc/wifi
cat wpa_supplicant.conf
这应该转储数据的WiFi你以前连接到你的手机,到你的电脑屏幕.这些命令在遇到“远程对象不存在”问题后在我的无根设备上工作。
vx6bjr1n8#
简单地用它来联系方式:
adb shell svc wifi enable
字符串断开连接:
adb shell svc wifi disable
8条答案
按热度按时间7xllpg7q1#
迟到了,但我想出了一个方法来实现这一点的设备没有根。
它可能不漂亮,但它工作。
基本上,我的建议是创建一个应用程序,该应用程序基于启动应用程序时给定的
EXTRAS
加入接入点。然后使用am
命令的-e <KEY> <VALUE>
参数提供EXTRAS
。我已经构建了一个这样做的应用程序,它可以在这里使用:https://github.com/steinwurf/adb-join-wifi
安装应用程序后,可以使用以下
ADB
命令加入WiFi接入点:字符串
在Github上的README中有更多信息。
希望它能帮助某人。
vshtjzan2#
您可以自己在wpa_supplicant.conf中添加网络条目(或在脚本中)本质上手动连接一次,然后执行:
字符串
并将网络条目集成到脚本中以实现自动化。简单脚本示例:
型
roejwanj3#
您可以使用命令adb shell cmd -w wifi connect-network和以下参数
字符串
要使用wpa2身份验证和密码“qwertyuiop”连接到wifi网络“Home”,请使用
型
要连接到一个开放的wifi网络“公共”使用
型
plupiseo4#
作为附加组件:您可以在设备上以root身份通过svc启用WiFi
字符串
并通过
型
ghg1uchk5#
作为另一个附加组件:虽然我的设备是根我得到
remote object ''/data/misc/wifi/wpa_supplicant.conf'' does not exist
错误,而试图执行adb pull
.它发生,因为adb
本身不运行在根模式.要解决这个问题,你可以执行这样的东西字符串
qkf9rpyu6#
我通过这个解决问题:
adb pull /data/misc/wifi/wpa_supplicant.conf ~/Desktop
,然后编辑文件,添加网络模块,我的整个conf文件是:字符串
然后rm原始文件,添加推到
/data/misc/wifi
文件夹,重新启动设备。请注意,不同的设备有不同的内容以上的网络线,不要修改这一部分。o3imoua47#
虽然很晚了,但我希望这能帮助任何可能偶然发现这条线索的人。
如果你正在尝试adb pull方法,但收到“remote object does not exist”,试试这个:
在同一命令提示符框中,
adb root
以root身份重新启动adb.单击回车.adb shell
,单击回车。确保提示符显示root@[device]:
cd /data/misc/wifi
,单击回车。cat wpa_supplicant.conf
,点击回车。这应该转储数据的WiFi你以前连接到你的手机,到你的电脑屏幕.
这些命令在遇到“远程对象不存在”问题后在我的无根设备上工作。
vx6bjr1n8#
简单地用它来
联系方式:
字符串
断开连接:
型