The question is: how to determine (programmatically) which USB port was used when the USB flash drive was plugged in?
Context:
I am developing an app for an Android TV Box that lets you view files from a Pendrive. My device has 3 USB ports. I would like to know which of the port was used (some kind of ID, port name, whatever that could help me identify it in the code).
What have I done:
- I read the android docs regarding USB as a host. None of the classes contains such information. The API is listing only devices which are plugged in but there is no information about the USB sockets. The
deviceNameis a string containing the path to a device file created in the android system but it is changing every time I plug in a USB flash drive (it looks like this/dev/bus/usb/007/008the numbers, in the end, are different each time). - Looked into android sys files by
adb shellcommand but couldn't find anything that describes the USB ports and says which one is currently in use.
Maybe someone encountered a similar problem? I'd really appreciate any help. Thanks in advance!