I am working on an application and I have access to ROM signing keys. I want to programmatically change the global settings of the Android proxy server and have run into "Settings.Global.HTTP_PROXY". My application will run on an Android KitKat device (4.4+)
Now in my code there is:
WifiManager manager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); if (!manager.isWifiEnabled()){ Log.d(LOG_TAG, "Wifi not enabled."); } else{ if (Settings.Global.putString(mContext.getContentResolver(), Settings.Global.HTTP_PROXY, proxySettings)){ Log.d(LOG_TAG, "New Proxy Settings set"); } else { Log.d(LOG_TAG, "New Proxy Settings failed to be written."); } }
And written in the application manifest file:
<uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
As stated earlier, my application is signed using system keys, so no permissions arise. I manually configured the proxy server settings in the WIFI connection to some random values ββto check whether the settings will be changed when the code changes. Logcat will return:
08-25 21:27:57.595: V/Provider/Settings(7302): Global.putString(name=http_proxy, value=localhost:8008 for 0
means that the ARE settings are saved in the database, but when I check the proxy server settings in the Settings application again, the previously configured proxy server settings will still be displayed, and the applications will still use the older proxy server settings.
Is there anything else I am missing to set the global settings of the Android proxy programmatically?
Thanks!
source share