I need to disable the OTG (USB) on Android 8. I already did it on Android 6 by disabling a permission on the file android.hardware.usb.host.xml but it is not working anymore on Android 8.1.


1 Answer 1


android.hardware.usb.host.xml file - located under /vendor/etc/permissions/ or /system/etc/permissions/ before Treble - contains feature name="android.hardware.usb.host" which indicates that the device can communicate with USB devices as the USB host. This feature is evaluated by PackageManager (along with other software / hardware features) and used by Google Play to filter (in)compatible apps based on the value <uses-feature android:name="android.hardware.usb.host" /> in AndroidManifest.xml. See details here.

Also if the device doesn't support USB host mode, UsbHostManager service is not started, so apps like this which use USB host APIs cannot connect to USB devices. But any connected device is still detected by kernel and appears under /sys and /dev.

To confirm if the device supports USB host mode:

~$ pm list features | grep usb.host
~$ dumpsys usb | grep host_manager

These lines shouldn't appear after you delete android.hardware.usb.host.xml file.

However since Android 6 USB storage devices such as a USB stick are handled by vold, which doesn't depend on the feature discussed above. vold listens to kernel through a netlink socket for block device uevent (1) and matches that with some entry in fstab (2). Then it creates disk and partition nodes in /dev/block/vold/ (3), checks filesystem for errors and mounts in /mnt/media_rw/ (also emulates SD cards in /mnt/runtime/) (4). After that ExternalStorageProvider (a content provider) is triggered which grants apps URI access to OTG storage through SAF or Scoped Directory Access.

So in order to disable auto-mounting of USB storage devices by vold, you need to remove the corresponding entry from fstab as referenced here:

/devices/*/xhci-hcd.0.auto/usb*    auto    auto    defaults    voldmanaged=usb:auto

fstab is found under /odm/etc/ or /vendor/etc/. Before Treble it was in rootfs (/). See details in this answer.

  • At least for Android 7 (fstab in /) this does not seem so easy, because the root partition gets rewritten on every reboot, so changing fstab does nothing. It seems you have to unpack boot.img change fstab and pack it again, because on boot, this filesystem gets written to root.
    – user136036
    Commented Jul 31, 2022 at 11:21
  • @user136036 correct. Commented Jul 31, 2022 at 13:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .