USB Host & OTG Peripherals Subsystem
USB diagnostics evaluates the device's USB Host and On-The-Go (OTG) capabilities, enabling smartphones to power and communicate directly with flash drives, digital cameras, audio DACs, keyboards, and serial adapters.
Why Software USB Host Support Does Not Guarantee Hardware OTG
Many Android chipsets report software support for PackageManager.FEATURE_USB_HOST. However, this does not guarantee that plugging in an OTG cable will work. To power external USB peripherals, the phone's charging circuitry must physically supply 5V VBUS power to the USB-C or Micro-USB port. Budget phones, older budget chipsets, and certain carrier-locked variants omit the step-up 5V charge-pump hardware, rendering USB OTG non-functional despite software framework flags.
In USB Host Mode, the Android phone acts as the bus master and supplies power to peripherals (flash drives, keyboards). In Accessory Mode (AOA), the external peripheral acts as the USB host and powers the phone.
Every connected USB device exposes standardized USB-IF class codes: Mass Storage (0x08), Human Interface Device / HID (0x03), Audio (0x01), Video / UVC (0x0E), and Communications (0x02).
How Voodoo Inspects USB Hardware
1. Primary Call & API-Level Fallback Chain
Extracted from UsbCollector.kt. Queries UsbManager on API 12+, falling back to inspecting Linux sysfs nodes (/sys/bus/usb/devices/) on legacy platforms:
// Excerpt from com.tool3.hardwareinfo.categories.usb.UsbCollector.kt
val usbManager = context.getSystemService(Context.USB_SERVICE) as? UsbManager
val hasUsbHost = context.packageManager.hasSystemFeature(PackageManager.FEATURE_USB_HOST)
val deviceList = if (Build.VERSION.SDK_INT >= 12 && usbManager != null) {
ModernUsbHelper.getDeviceList(usbManager)
} else {
emptyMap()
}
for ((name, dev) in deviceList) {
val vid = dev.vendorId
val pid = dev.productId
val devClass = dev.deviceClass
val interfaceCount = dev.interfaceCount
}
2. Permission & Privilege Gate
Enumerating connected USB devices, reading VID/PID descriptors, and inspecting interfaces requires zero permissions. However, opening an active USB data pipe (usbManager.openDevice()) to transfer payload bytes requires an explicit user runtime permission prompt. Voodoo only performs descriptor inspection, requiring no intrusive dialogs.
3. Interpretation & Normalization Logic
- Class Decoding (
UsbClassHelper.kt): Converts numeric USB-IF class bytes into readable categories (e.g. Mass Storage, HID Keyboard, Audio DAC). - Hexadecimal VID/PID Conversion: Converts integer device identifiers into standard USB IDs (e.g.
0x0781:0x5583for SanDisk Ultra USB 3.0).
4. Availability-State Triggers
UsbManageron Android < 3.1 triggersAvailabilityState.UNSUPPORTED.- When no USB peripherals are physically connected, device lists report
AvailabilityState.UNAVAILABLE("No USB devices connected").
Subsystem Field Inventory
| Field ID | Display Name | Type | Primary Source / API | Min API |
|---|---|---|---|---|
| usb.host_support | USB Host Mode Support | BOOLEAN | PackageManager.hasSystemFeature(FEATURE_USB_HOST) | API 12 |
| usb.connected_devices_count | Connected USB Devices | INTEGER | UsbManager.getDeviceList().size | API 12 |
| usb.device_vid_pid | Vendor & Product ID (VID/PID) | STRING | UsbDevice.getVendorId() / getProductId() | API 12 |
| usb.device_class | USB-IF Device Class | STRING | UsbClassHelper.getClassName(dev.deviceClass) | API 12 |