I'm running Android Pie on a rooted OnePlus 6, and I wanted to know how I can enable OTG with a shell command. I need this in order to automate some tasks.

There is a setting that can toggle OTG, found in settings > system > OTG storage, so I figured something like this would work:

settings put global otg_enabled 1

However I'm unsure what the setting for OTG is actually called; I tried a bunch of possibilities but none seemed to work. Also tried googling it, but found nothing.

Anyone able to help me out here?


Note: the solution is tested on a rooted OnePlus 6 running OxygenOS (Android 8, 9, 10).

The command I use is:

adb shell su -c 'setprop persist.sys.oem.otg_support true'

Some folks on some forums suggested to toggle the value for the global settings key oneplus_otg_auto_disable, but it never worked out for me. My solution survives reboot and OTG would work even when decryption password is not supplied.

I automate the solution for fail-safe scenario (in case something disable the OTG) using Tasker app. My task is:

Code → Run Shell:

  • setprop persist.sys.oem.otg_support true
  • enable Use Root

I then assign the task to a boot event profile so that the task runs during startup.

  • 1
    I think both - property and settings key - are OEM specific, not part of AOSP. Aug 28 '19 at 11:34
  • 1
    Yes, I agree. I didn't see such keys in my Nexus 6 running Android 7, back when I had it.
    – Firelord
    Aug 28 '19 at 11:35
  • setprop worked, but resetprop didn't. Says /system/bin/sh: resetprop: not found (Rooted with magisk). What's the difference setprop and resetprop? Aug 30 '19 at 13:29
  • 1
    @AbrahamMurcianoBenzadon resetprop can make changes into read-only properties too while setprop cannot. I have edited it out to remove any confusion.
    – Firelord
    Aug 30 '19 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.