• 某些安卓设备没有实体键盘,甚至没有屏幕,要让其连接到wifi有很多方法,这儿列举两个无需使用硬件设备的方法。
  1. 使用adb工具,以修改wpa_supplicant.conf来实现(不是所有系统版本和设备都适用)
#!/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=ssid_name
WIRELESS_KEY_MGMT="WPA-EAP IEEE8021X"
WIRELESS_EAP=PEAP
WIRELESS_USER=Turgon
WIRELESS_PASSWORD=wifi_password

adb start-server
adb wait-for-device
echo"adb connection....[CONNECTED]"
adb root
adb wait-for-device
adb remount
adb wait-for-device

pushd /tmp
rm wpa_supplicant.conf 2>/dev/null # Remove any old one
adbpull_status=`$ADB_PULL 2>&1`
echo -e"\
Attempting: $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""
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""
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)"
  1. 使用应用程序和adb工具
    下载帮助联网的应用apk https://github.com/steinwurf/adb-join-wifi
    在使用adb命令安装apk后,在使用一些命令连接到wifi网络
adb shell am start -n com.steinwurf.adbjoinwifi/.MainActivity \ -e ssid SSID -e password_type WEP|WPA -e password PASSWORD

连接速度可能会很慢,可能需要等待或多次尝试

文章作者: LrMaker
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 最上级
工具 安卓
喜欢就支持一下吧