Code Monkey home page Code Monkey logo

android-proxy-toggle's Introduction

Build Check Codecov report Android Version License

Proxy Toggle

Small application to help Android and Test Engineers to quickly enable/disable global proxy settings without the faff of going through the annoying Network Settings path.


It's everyone's responsibility to keep this document up to date as part of each release, or if you find something that needs updating.

App installation

If you're only interested in using the app, you can grab the latest release, connect your device and execute the installation script from your Terminal:

./installAndGrantPermission.sh

Android 5.x

Because of old adb limitations, if you want to install the app in devices running Android 5.x, you must run two commands separately:

adb install -t -r proxy-toggle.apk
adb shell pm grant com.kinandcarta.create.proxytoggle android.permission.WRITE_SECURE_SETTINGS

Project setup

No special setup required. Just clone the repository and it should build out of the box. At the moment of writing this, the project is being created using Android Studio 4.2 Canary 3.

About the app

Supported devices

This app supports Android 5.0 and above.

Architecture

The project has a small app module and the different features (manager screen, widget, tile) each have their own module. Things used by several modules are included in core module. Finally, there's a test-utils module for things shared by many modules' test source-trees.

The app follows MVVM Clean Architecture principles.

Dependency Injection

We currently use Hilt for Dependency Injection.
Each Activity and Fragment that use DI must be annotated with @AndroidEntryPoint.
Each ViewModel must be injected using @ViewModelInject in order to be provided using by viewModels().

Testing

We use Github Actions to execute all Unit Tests in the project for every PR against the main branch. JaCoCo is setup to run test coverage. We should aim to increase test coverage on each PR. At the moment of writing this, Hilt and JaCoCo are not totally compatible, so the total coverage shown is not accurate.

Features

Quick proxy setup

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

Home Screen Widget

The app features a Home Screen widget that the user can use to quickly toggle the proxy with the last used setup, without having to even open the app. It will also allow the user to launch the app to configure the proxy settings, if needed.

Quick Setting Tile

Similarly to the widget, Android 7.0 and above users will have the option to add a Quick Settings Tile in their Notification Drawer. This tile will allow the users to toggle the proxy even without having to leave the current application they are using.

Caveats

WRITE_SECURE_SETTINGS permission

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 special permission.

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

In order to grant this permission once the app is 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

Alternatively, you can grant the permission when installing the app via the command adb install -g App.apk or just use the provided installAndGrantPermission.sh script.

Be careful when uninstalling the app

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, we also provide 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

License

Proxy Toggle is available under the MIT license. See the LICENSE file for more info.

android-proxy-toggle's People

Contributors

christos-christidis avatar christos-christidis-kac avatar fmontesino avatar kleinsenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-proxy-toggle's Issues

Will there be updates?

Hello, this application, this solution is very important to me. I have a question and suggestion.

Is it possible to add in future updates the ability to set username and password for the proxy?

On the other hand, is it possible to make the application system administrator so that permissions can be granted without having to connect to the PC and use the terminal?

Thanks

cannot proxy all apps

my issue is only a small number of apps can be proxied in the HarmonyOS 3.0 . I'm sure the proxy toggle is being run effectively, but many apps are not being proxied by it or going through its tunnels. may you update the app and fix this issue?

The cleanup after uninstalling the app doesn't work for me

Instead of the commands provided in the Readme:

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

I had to use this one, and only after that the internet connection started working again:

adb shell settings put global http_proxy :0 

Is this global

Hi I've seen a few other proxy apps that can't seem to make ALL traffic run through the proxy, does this occur with this apk?
Or is it only certain apps
thank you

Old version under Releases

After installing the first version/releave, I have the app with no icon, and a main screen with "Enable" button. IP and port are automatically detected (not possible to configure)
Also, the widget is just a button to Enable the proxy.

The installed app has nothing to do with the one showing on Readme. Looks like under release, you have the first draft of the app.

URL support for proxy.pac

HI,

I would like to know if it was possible to set up an option or I could indicate a url proxy.pac so that all network traffic goes through the proxy.

Android 7, 8 and 9 are giving us errors (err proxy not supported) randomly, and your app would help us a lot.

Thank you for your reply.

Best regards,

Christophe

disabling forgets the last used ip address

I've installed the app on Pixel 4, Android 11 using the adb command
The address text field doesn't appear to be editable.
I can change it using adb shell settings put global http_proxy 192.168.0.110:8888

After disabling and enabling it via the toggle, it changes the label text to an IP address of another value. example: 192.128.1.215 as seen in screenshot

sometimes when it's enabled, the address value in the app remains 192.128.1.215, instead of showing 192.168.0.110
when I tap on disable, the proxy remains enabled. I confirmed it by inspecting Charles app, which continued to display traffic from the device.

android-screenshot-13

Edit host and port

I installed the app and it was clear what I need to do to enable/disable the proxy.
However, my laptop IP is different than the defined one.

Should we change the design a little and change from TextView to EditText
so we can allow the user to change the proxy host and port.

I was thinking to show edit option only if the proxy is disabled.
If I am missing something or this is not an issue please say.

App crash when enabling proxy in Android 5.1

Using Motorola XT1033, Android 5.1 and First stable release of the app.

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

After filling in the IP address and port number, click on the enable button and then the app crashed:

02-04 12:11:13.236 6803-6803/com.kinandcarta.create.proxytoggle E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.kinandcarta.create.proxytoggle, PID: 6803
    java.lang.SecurityException: Permission denial: writing to settings requires android.permission.WRITE_SETTINGS
        at android.os.Parcel.readException(Parcel.java:1546)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
        at android.content.ContentProviderProxy.call(ContentProviderNative.java:645)
        at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1094)
        at android.provider.Settings$Global.putStringForUser(Settings.java:6744)
        at android.provider.Settings$Global.putString(Settings.java:6728)
        at com.kinandcarta.create.proxytoggle.android.DeviceSettingsManager.enableProxy(DeviceSettingsManager.kt:32)
        at com.kinandcarta.create.proxytoggle.feature.manager.viewmodel.ProxyManagerViewModel.enableProxy(ProxyManagerViewModel.kt:42)
        at com.kinandcarta.create.proxytoggle.feature.manager.view.ProxyManagerFragment$showProxyDisabled$$inlined$with$lambda$1.onClick(ProxyManagerFragment.kt:107)
        at android.view.View.performClick(View.java:4785)
        at android.view.View$PerformClick.run(View.java:19884)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5343)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
02-04 12:11:26.262 6803-6803/com.kinandcarta.create.proxytoggle I/Process: Sending signal. PID: 6803 SIG: 9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.