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
# 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.
If the OTG drive is plugged in at the time of the command, you can also detect OTG by querying these directories:
/storage/UsbDriveA (Samsung devices) /storage/USBstorage1 (LG G4, V10, G3, G2, LG devices) /storage/usbdisk (Moto Maxx, Turbo 2, Moto X Pure, Motorola devices) /storage/usbotg (Sony Xperia devices, Lenovo Tabs) /storage/UDiskA (Oppo devices) /storage/usb-storage (Acer Iconia Tabs) /storage/usbcard (Dell Venue -- Vanilla Android 4.3 tablet) /storage/usb (HTC One M7, some Vanilla Android tablets)
Tested on my collection of devices and a quick trip to Bestbuy for testing the latest flagships listed above. Edited to add input from other members here.