我一直在尝试在脚本中添加带有这些命令的wifi网络:
adb shell wpa_cli -p /data/misc/wifi/sockets/ -i wlan0
# Get to wpa_cli prompt
adb shell wpa_cli -p /data/misc/wifi/sockets/ -i wlan0
# Add new WiFi network
adb shell add_network
adb shell set_network 0 auth_alg OPEN
adb shell set_network 0 key_mgmt WPA-PSK
adb shell set_network 0 ssid "Password"
adb shell set_network 0 proto RSN
adb shell set_network 0 mode 0
adb shell set_network 0 psk "Mynetwork name"
# Connect to it
adb shell select_network 0
adb shell enable_network 0
adb shell reassociate
# Check the status
adb shell status
但在第一个命令之后,终端始终处于adb shell提示符状态,其他命令未执行
答案 0 :(得分:1)
WPACLI="adb shell wpa_cli -p /data/misc/wifi/sockets/ -i wlan0"
# Add new WiFi network
NETWORK=$($WPACLI add_network)
$WPACLI set_network $NETWORK auth_alg OPEN
$WPACLI set_network $NETWORK key_mgmt WPA-PSK
$WPACLI set_network $NETWORK ssid "Password"
$WPACLI set_network $NETWORK proto RSN
$WPACLI set_network $NETWORK mode 0
$WPACLI set_network $NETWORK psk "Mynetwork name"
# Connect to it
$WPACLI select_network $NETWORK
$WPACLI enable_network $NETWORK
$WPACLI reassociate
# Check the status
$WPACLI status