4

I found these commands to add/remove proxy using ADB:

#To Add Proxy
adb shell settings put global http_proxy 192.168.1.252:8080

#To Remove Proxy
adb shell settings put global http_proxy :0

Is possible to also add in the same command or another, the proxy username and password?

Atm it pops a window asking to input this info, but I would like to also add it using ADB.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Cesar
  • 41
  • 2
  • 5
  • 16
  • 1
    According to the documentation there is only the global proxy hostname and port setting: https://developer.android.com/reference/android/provider/Settings.Global#HTTP_PROXY – Robert Aug 11 '22 at 12:11
  • @Robert While googling about i found many places pointing to `global_http_proxy_username`, `global_http_proxy_password`, i tried both, but it still is asking for authentication. – Cesar Aug 12 '22 at 23:30
  • 1
    Have you found a post where a user states that this setting has worked? Another possibility is that these options are only present on certain devices as the manufacturer has added this settings (because I don't find any reference to `global_http_proxy_username, global_http_proxy_password` in Android sources AOSP).. – Robert Aug 13 '22 at 10:36

2 Answers2

2

Have you tried:

Enable http proxy with authentication:

adb shell settings put global http_proxy 192.168.225.100:3128
adb shell settings put global global_http_proxy_host 192.168.225.100
adb shell settings put global global_http_proxy_port 3128
adb shell settings put global global_http_proxy_username foo
adb shell settings put global global_http_proxy_password bar

And to disable proxy:

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
adb shell settings delete global global_http_proxy_username
adb shell settings delete global global_http_proxy_password
adb shell settings delete global global_http_proxy_exclusion_list
adb shell settings delete global global_proxy_pac_url
adb shell reboot

Relevant sources:

DialFrost
  • 1,610
  • 1
  • 8
  • 28
1

An android app that sets the proxy settings for a wifi access point by using adb. This DOES NOT require root and will work with any device that has USB debugging on or any emulator (including Genymotion).

link

sample

adb shell am start -n tk.elevenk.proxysetter/.MainActivity -e host 192.168.56.1 -e port 8080 -e ssid PublicWifi -e bypass test.com,test2.com -e reset-wifi true
Arda Kazancı
  • 8,341
  • 4
  • 28
  • 50