How to easily proxy your Android device

Fidel Montesino
Kin + Carta Created
5 min readJul 10, 2020

If you’re a mobile engineer, during both development and testing you probably use some of the most common tools out there to debug, intercept or rewrite your network calls, like Charles Proxy or Fiddler.

You will also probably find the process of setting up the proxy in your devices quite annoying: go to Settings > Network Settings > Select your WiFi network > Modify Network > Add proxy. Every. Single. Time. Phew!

If you’re working with a set of different devices, you probably also noticed small differences between Android versions, manufacturers, etc., that might add or modify the steps you take for setting up the proxy.

There’s a small adb command you can run from your Terminal to enable a global proxy on your connected device:

adb shell settings put global http_proxy YOUR_IP:YOUR_PORT

But this won’t give you any visual indicator to know whether the device is using a proxy or not. It also requires the device to be connected to a computer with adb installed every single time you want to enable or disable the proxy… which probably makes using this workaround not the most ideal solution.

Well, I have good news for you.

Introducing Proxy Toggle

Proxy Toggle is a small utility application compatible with Android 5.0 and above that will allow you to quickly enable and disable your proxy settings, as well as unifying and simplifying the process across platform versions, devices, manufacturers, etc.

Proxy Toggle allows you to configure your global proxy with one tap

Easy setup: just add your desired IP and port, enable the proxy and voilà! all done, your whole device will be proxied.

Making it even easier

I know this is all exciting news. But I also feel that having to open the app every time you want to enable the proxy might be also a long process… right?

That’s why I also added two optional shortcuts for you to use: a home screen widget and a quick settings tile.

Home Screen Widget

This shortcut’s very helpful for enabling and disabling your last used proxy quickly from your home screen.

To add the widget, you’d normally long-press your home screen (depending on your launcher), select Add Widget and scroll down on your app list until you see the Proxy Toggle widget.

The home screen widget will configure the last used proxy automatically

That’s it! Toggle your proxy on and off with a single tap!

Quick Settings Tile

If your device is running Android 7.0 or higher, you’ll have access to another amazing shortcut: a Quick Settings Tile. This shortcut will live inside your Notification Drawer, next to some other handy shortcuts like WiFi, Location, Bluetooth, Airplane Mode, etc.

To enable it, simply expand your Navigation Drawer, click on the Edit icon and drag the Proxy Toggle icon wherever you want to place it.

Once enabled, the quick settings tile is a great shortcut for toggling your proxy

Done! You can toggle on and off your proxy without even leaving the current app!

Note: if you have any ongoing network calls, they might take a few seconds to complete and update with the new setting.

All that glitters is not gold

Although the app perfectly accomplishes its goal and makes our life easier, there’s a couple of caveats that I want to highlight about this shiny app.

Using system restricted permissions

The app will make use of Settings.Global. Since this is a system setting, it’s normally a read-only setting. This small inconvenience is bypassed by granting the app WRITE_SECURE_SETTINGS restricted permission.

Note: this is a protected permission that only System apps should be granted. Be extra careful when you grant this permission for apps from unknown sources.

I know this might raise some concerns, and I understand them.
That’s why I decided to open-source the project: to prove that it’s completely safe to grant this permission, as you will have complete control and knowledge of what’s going on behind the scenes.

Granting system restricted permissions

Since this is a restricted permission, we can’t request it on runtime as we would normally do, so you’ll need to manually grant it from our computer.

If you just want to install the app without building it from Android Studio, there’s a small script that will be bundled with the app. Just download the zip file and execute the installAndGrantPermission.sh script.
Alternatively, you can manually install the app by running adb install -g App.apk on your Terminal.

To grant this permission once the app is already installed, connect the device to your computer and execute the following command on your Terminal:

adb shell pm grant com.kinandcarta.create.proxytoggle android.permission.WRITE_SECURE_SETTINGS

Be careful when uninstalling the app

Sadly, as developers, we can’t run any code when the app is being uninstalled. Therefore, uninstalling the app with the proxy enabled will permanently leave your device with this setup (as it’s a Settings.Global configuration!).

You should make sure the proxy is disabled before uninstalling the app. Since we can’t guarantee this is going to happen, there’s also the uninstallAndCleanUp.sh script for making sure everything is in a clean state after uninstalling the app.

Alternatively, you could run the following commands on your Terminal to clean up the proxy setting:

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

Convenience at your fingertips

Proxy Toggle makes it easier to set up a global proxy on any Android phone, as well as providing different shortcuts for enabling and disabling the proxy with a single tap on the screen. I hope this tool will be as useful to your team as it’s been to our internal apps team, both developers and testers!

You can download the latest version from here, or clone the project from Github.

Many thanks to the unique and amazing Flor Novello for her invaluable help with the app design!

--

--