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
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>
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
I know this is an old question, but I had a hell of a time undoing my proxy hack so I figured I'd share.
I passed permissions to the device using ADB that would let me change the values to my proxy settings with my own custom application.
The problem is once I used my app with
Settings.Secure.putString(getContentResolver(), Settings.Secure.HTTP_PROXY, "127.0.0.1:8007");
It wouldn't let me set it back to default (No Proxy) no matter what I tried (null, blank, "NONE") basically if I wasn't connected through the proxy it wouldn't talk to the outside world. Even after restart.
SOLUTION I FOUND:
These settings are stored in a SQL database so when the phone restarts it applies them. You just need to go into the database and delete these rows from the table. What I did:
~user$ adb shell
shell@cinco:/ $ su -
FYI...Not sure if you need super user but it can't hurt right . . .
root@cinco:/ $ sqlite3 /data/data/com.android.providers.settings/databases/settings.db
you can see the full list of what's in the global table by doing:
sqlite> select * from global;
in the list you should be able to see the values you wrote in for http_proxy, global_http_proxy_host, and global_http_proxy_port, maybe you know what magic values to set these to so that it works properly, but I do not... my solution, just delete them:
sqlite> delete from global where name="global_http_proxy_host";
sqlite> delete from global where name="global_http_proxy_port";
sqlite> delete from global where name="http_proxy";
restart the phone and like magic there is no more proxy and I get the interwebs!!
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.
use like this
Settings.Secure.putString(getContentResolver(),
Settings.Secure.HTTP_PROXY, "127.0.0.1:8007");
note 'Settings.Secure.putString()'