美文网首页
adb脚本连接wifi

adb脚本连接wifi

作者: 默_声 | 来源:发表于2019-10-13 20:49 被阅读0次

因为要修改系统级的文件,所有手机要在root环境下执行命令

删除原有的wifi连接信息,将需要连接的wifi重新写入

#!/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 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 "\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 ""
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)"

再次触发wifi连接

adb pull /data/misc/wifi/wpa_supplicant.conf

相关文章

  • adb脚本连接wifi

    因为要修改系统级的文件,所有手机要在root环境下执行命令 删除原有的wifi连接信息,将需要连接的wifi重新写...

  • Android车载经验总结

    打开车载wifi能力,让车载设备能够连接wifi: adb root adb remount adb shell ...

  • Wifi连接adb的shell脚本

    如果usb线不稳定的话会经常用到wifi连接adb。Android Studio也有很多类似插件,但依赖不同的操作...

  • MuMu模拟器Tips

    adb连接到MuMu: 打开Wifi设置

  • adb 常用命令

    通常可以直接调用adb devices 和adb kill-server。 wifi 连接adb步骤,

  • 常用Adb命令整理

    adb 整理一些adb命令 abd wifi connect 设备拒绝连接情况 adb chmod adb屏幕录制...

  • android 通过wifi开发调试

    两种方式 使用adb命令连接wifi进行无线调试 安装as插件:Android WIFI ADB(此处不介绍) 第...

  • adb无线连接

    adb无线连接 本文讲解如何实现adb无线连接,当然你也可以使用AndroidStudio的ADB WIFI[ht...

  • MAC pro WiFi ADB使用以及连接手机调试

    两种方式: 使用adb 命令连接wifi进行无线调试 安装as 插件:Android WIFI ADB(自行百度吧...

  • adb WiFi连接

    由于需要测试adb电量消耗,usb连接的方式不太实用,改换为WiFi连接。 注:本教程无需root权限,可连接多台...

网友评论

      本文标题:adb脚本连接wifi

      本文链接:https://www.haomeiwen.com/subject/atpkmctx.html