Can I use adb shell command to detect the phone support OTG to transmission the files with an USB Flash Drive with OTG function?
Can I use adb shell command to detect the phone support OTG to transmission the files with an USB Flash Drive with OTG function?
Yes. All you need to do is test for the presence of the file that enables it. On devices that do:
# adb shell ls /system/etc/permissions/android.hardware.usb.host.xml
/system/etc/permissions/android.hardware.usb.host.xml
And otherwise:
# adb shell ls /system/etc/permissions/android.hardware.usb.host.xml
/system/etc/permissions/android.hardware.usb.host.xml: No such file or directory
Of course, it's possible for a device to be misconfigured — but you have to actually physcially test OTG to determine that.
Q & A