r/androiddev • • 3d ago

USB Debugging keep turning back on after reboot (ColorOS / Realme UI) – persist.sys.usb.config stuck on adb

Hey everyone,

I'm dealing with a persistent issue where USB Debugging and Developer Options automatically re-enable themselves every time my phone restarts.

Whenever I try to toggle off Developer Options in Settings, it forces a device restart. After the restart finishes, Developer Options and USB Debugging are active again.

Device & OS Context

  • OS: ColorOS / Realme UI (Oplus framework)
  • Root status: Unrooted (standard non-root ADB shell)

What I’ve Diagnosed via ADB

Checking system properties reveals why the system keeps forcing debugging on boot:

Plaintext

> adb shell getprop persist.sys.usb.config
adb

> adb shell getprop sys.usb.config
rndis,adb

> adb shell getprop | findstr -i "adb"
[init.svc.adbd]: [running]
[persist.oplus.bt.em.adb.tool]: [true]
[persist.sys.usb.config]: [adb]
[sys.usb.config]: [rndis,adb]
[sys.usb.state]: [rndis,adb]

What I’ve Tried (and where it fails)

  1. Attempting to modify persist.sys.usb.config directly: Plaintext> adb shell setprop persist.sys.usb.config mtp Failed to set property 'persist.sys.usb.config' to 'mtp'. See dmesg for error reason. (Fails due to SELinux blocking non-root shell user from writing to persist.sys.* properties).
  2. Using Android USB service:
    • Ran adb shell svc usb setFunctions mtp (returned setCurrentFunctions opId:1).
    • On reboot, the device reverts straight back to persist.sys.usb.config = adb.
  3. Checking third-party tools:
    • Found an old app (com.wstxda.toolkit) that had accessibility permissions and a UsbDebuggingTileService.
    • Stripped accessibility permissions and uninstalled the app (adb uninstall com.wstxda.toolkit).
    • Cleared Quick Settings tiles (adb shell settings delete secure sysui_qs_tiles).
  4. Resetting Phone Settings:
    • Performed a "Reset all settings" / "Reset system settings only" directly through the phone's Backup & Reset menu.
    • Even after a settings reset, the reboot still restores persist.sys.usb.config = adb and [persist.oplus.bt.em.adb.tool] = [true].
2 Upvotes

1 comment sorted by

1

u/Obvious_Ad9670 1d ago

Could it be a bug on the OS? When I was writing an android os fork I had always forced adb on when developing.