Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo setting proxy via Settings.Global in Android

Tags:

android

proxy

I am writing system app, which sets global http proxy via

Settings.Global.putString(getContentResolver(), Settings.Global.HTTP_PROXY, "127.0.0.1");

How can I revert this change?
This don't work:

Settings.Global.putString(getContentResolver(), Settings.Global.HTTP_PROXY, null);

Any ideas?
Thanks in advance

like image 744
Artur Latoszewski Avatar asked Aug 04 '15 11:08

Artur Latoszewski


People also ask

How do I get rid of proxy settings?

At the bottom of the screen, click Show advanced settings… This will bring up the Windows Internet Options. Click the Connections tab and then LAN Settings. In the Proxy server settings, uncheck the box that says Use a proxy server for your LAN.

What is global proxy settings?

Global Proxy ConfigurationExecutes a proxy autoconfiguration script to determine the best proxy to use to retrieve a specified URL.


2 Answers

Andrews answer works but only for rooted devices, here's my solution for non-rooted devices.

I added the proxy with the following command:

adb shell settings put global http_proxy <ip>:<port>

Update: To remove it you can use the following command (thanks to Rohit Patel for providing this):

adb shell settings put global http_proxy :0 

To remove it I used these commands:

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

Restart the device and you should be good to go

like image 132
Scott Cooper Avatar answered Sep 19 '22 12:09

Scott Cooper


Below is the normal command to remove proxy settings which will be applied without device reboot. You can use it in your script or app relatively.

adb shell settings put global http_proxy :0

You don't need to run all three of those commands. It will work with just the one command above. All proxy settings will be removed instantly.

like image 44
Rohit Patel Avatar answered Sep 22 '22 12:09

Rohit Patel