Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android usb host api and USB storage

I am trying to use the android host api for USB storage. I have many doubts regarding same.

  1. What all things are possible using host api. I want to see the content of USB and if possible so the normal file operation. I didnt find any documentation help regarding this.

  2. I am able to claimInterface using UsbDeviceConnection class API but I'm unable to understand how the bulkTransfer works so if anyone can guide me or give some reference I will try myself.

I tried reading the USB specification also, I understood how bulkTransfer works at USB level but unable to relate how android/java file operations are possible using bulkTransfer which using UsbEndpoint not the File Descriptor.

Thanks in Advance !!

like image 216
Brijesh Masrani Avatar asked Oct 09 '14 16:10

Brijesh Masrani


People also ask

What is the difference between USB and USB host?

USB host is the USB on the PC side in most cases and USB Device is the USB in your mouse ,keyboard, flash memory and so on. All USB transactions are managed by the Host. and the Device only responses to the Host transactions. Hope that helps.

What is the difference between USB host and OTG?

– Unlike a standard USB host in a PC, an OTG device may not have a simple way to add drivers for “unrecognized” devices. – An OTG device must supply what is called a Targeted Peripheral List that allows the device manufacturer to specify exactly what devices they will support.

What is Android USB host?

When your Android-powered device is in USB host mode, it acts as the USB host, powers the bus, and enumerates connected USB devices. USB host mode is supported in Android 3.1 and higher.

What is USB host and USB client?

USB host is the system that connects to multiple USB clients. For example, the PC is a USB host and it can connect to multiple USB clients like mice, keyboards, and mass storage devices. Implementing a USB client is rather simple but implementing a host is far more complicated.


1 Answers

The Android USB Host APIs do not include USB Mass Storage filesystem code, nor as of this writing in 2014 will "stock" Android mount a USB Mass Storage volume at operating system level.

To access a USB Mass Storage device using the stock Android USB Host APIs, you must therefore implement in your Application code both the necessary raw-USB operations to achieve block-level device access, and the appropriate filesystem logic itself. Needless to say, the details of such are of a complexity beyond the scope of an answer here, but you could start by studying documentation or existing implementations of USB Mass Storage drivers and filesystem drivers for other platforms.


It appears the situation in Android 6 may be different, and access via the USB host apis to something that version recognizes as a storage device might even no longer be permitted. Those targeting Android 6+ may need to look elsewhere, but older devices will remain in use for some time.

like image 122
Chris Stratton Avatar answered Sep 27 '22 20:09

Chris Stratton