一、使用全局命令
設置代理:
adb shell settings put global http_proxy 代理IP地址:端口號
如:
adb shell settings put global http_proxy 127.0.0.1:8888
移除代理:
adb shell settings delete global http_proxy
adb shell settings delete global global_http_proxy_host
adb shell settings delete global global_http_proxy_port
二、使用第三方apk
AndroidProxySetter工具可以幫助我們使用adb命令可以快速進行wifi代理的設置和清除
GitHub地址:
https://github.com/jpkrause/AndroidProxySetter
下好apk后,安裝到手機
adb install proxy-setter-debug-0.2.1.apk
設置代理:
adb shell am start -n tk.elevenk.proxysetter/.MainActivity -e host 代理IP地址 -e port 端口號 -e ssid WIFI名稱 -e reset-wifi true -e key WIFI密碼
如:
adb shell am start -n tk.elevenk.proxysetter/.MainActivity -e host 127.0.0.1 -e port 8888 -e ssid YOUR-WIFI-NAME -e reset-wifi true -e key YOUR-WIFI-PASSWORD