Skip to content

sawaYch/usb-debug-toggle

Repository files navigation

USB Debug Toggle

An Android home screen widget to toggle USB debugging on and off.

App preview

Main App

USB Debug Toggle — screenshot 1

Quick Setting Toggle Button

USB Debug Toggle — screenshot 2

Screen Widget

USB Debug Toggle — screenshot 3

Features

  • Simple icon widget that changes color based on USB debugging state (green for ON, red for OFF)
  • Clicking the widget toggles USB debugging (requires WRITE_SECURE_SETTINGS permission)
  • Quick Settings tile for fast toggle from notification panel
  • Minimal launcher activity showing permission status and instructions
  • Automatic widget updates after device reboot

Requirements

  • Android 8.0 (API level 26) or higher
  • WRITE_SECURE_SETTINGS permission granted via ADB

Installation

  1. Build and install the APK via command line:
    ./gradlew buildAndInstall

Granting Permission

To toggle USB debugging, the app needs the WRITE_SECURE_SETTINGS permission, which is a system-level permission that cannot be granted via normal installation. You must grant it via ADB:

adb shell pm grant io.github.sawa.usbdebugtoggle android.permission.WRITE_SECURE_SETTINGS

After running the above command, you may need to re-add the widget to your home screen.

Usage

  1. Add the widget to your home screen:
    • Long press on the home screen → Widgets → USB Debug Toggle
  2. Tap the widget icon to toggle USB debugging.
  3. The icon color indicates the current state:
    • Green: USB debugging is ON
    • Red: USB debugging is OFF

Adding Quick Settings Tile

  1. Grant the WRITE_SECURE_SETTINGS permission (see above)
  2. Open Quick Settings panel (swipe down from the top of the screen)
  3. Long press the edit button or tap the pencil icon
  4. Find "USB Debug" in the available tiles
  5. Drag it to your active Quick Settings panel

Notes

  • The app watches Settings.Global.ADB_ENABLED with a ContentObserver while the process is running, then refreshes the home screen widget, requests a Quick Settings tile refresh, and updates the main screen (via a shared StateFlow). Changes from Developer options, this app’s widget/tile/activity, or ADB should stay in sync without re-adding the widget. If a device does not notify that setting correctly, open the main activity once or toggle from this app to force a refresh.
  • On some devices, battery saver may prevent widget updates. To fix this, go to App Info → Battery usage → Unrestricted.

License

MIT License

About

simple android widget that toggle developer options usb debug mode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages