[Q] UsbDevice.java - Android Software/Hacking General [Developers Only]

I really want usb host capabilities on my phone.
Honeycomb 3.1 has this as does (if I understand correctly) Samsung Galaxy S2, where it is backported to gingerbread.
So first thing to do of course was to look at the galaxy s2 source code.
But there is nothing there. No UsbDevice.java, no additional drivers, nothing.
Do I miss anything? Isn't Samsung required by GPL to publish such modifications?
Thanks,
quietNaN

So far USB host mode doesn't work for Androids < 3.1
For 2.3.4 there's only an external library to support the USB accessory mode but it needs to be built into the OS. From latest news this is included in CyanogenMod 7.1 so as soon as this is released for your phone you can at least connect peripherals to S2.
See also this link for more details on Android USB support:
http://developer.android.com/guide/topics/usb/index.html

Thanks ramdroid77 for your answer.
I am aware that the feature I am asking for is not available before 3.1 .
And I am also aware of the "accessory mode".
However, there are two reasons why I am pretty sure that the S2 does not use the accessory mode.
1. From what I gathered around the internet (mostly from the exact link you mentioned) the handshake in accessory mode is quite different from the usual usb host mode. An android phone in accessory mode will for example not be able to provide an identifier for the client. The accessory is supposed to do this.
So (please correct me here, this point is halfway guessed) I think it will not be possible to plug an usb device into your phone and expect things to work. An "usb accessory" is something you actually have to develop to work with android. There are videos on youtube however that show people just plugging in a stick into their S2...
2. Usb accesory mode is introduced as an optional feature in 2.3.4 . The S2 runs 2.3.3 .
The README_platform.txt provided with the S2 source gives instructions how to build the code. It says to download 2.3.3(r1) and replace some files by the files provided by Samsung before make. The usb handling is not part of 2.3.3(r1) and (as far as I can see) not part of the modified files they offer for download.
The modifications were actually what I was looking for. I was hoping that Samsung backported the true usb host mode which is introduced with 3.1 (but not published yet by google) to 2.3.3 so that I can have a look and also backport it to the pre-CM7.1 (build from source) I am using on my legend. Well, at least try to figure out which informations I need to gather before I even can start to think about backporting it.
Since the S2 does not use accessory mode (I think) they either use a host mode and hold the code out on us (since my original question) or they use something completely different (neither the android accessory mode nor the android usb host mode) which then I must have missed in the kernel code. If I remember correctly the tiamat kernel for example has support for usb mass storage devices (which I cannot test on my legend).
I have some projects on my mind which (from what I gathered about the accessory mode) requires a real host mode.
So my question persists (or has to be reformulated): What does the S2 use to communicate with a usb device?
quietNaN

Related

USB Keyboard support

It is my understanding that nobody has yet managed to successfully hook up a USB keyboard to an HTC Dream yet, or any other android phone. I doubt this is due to some hardware limitation as USBInput has recently been released for Windows Mobile phones (http://www.teksoftco.com/index.php?section=products&platform=1&pid=18). In fact, the Linux kernel has an HID driver built in so getting USB keyboard support on android should definitely be possible.
Would anyone know either of a project to realise the above, or anyone who might be interested in doing this?
I dont think G1 has USB hosts
and
I perfer Bluetooth Keyboard and mouse support (this seems more reasonable~)
Actually it is said to have usb host capability, but the kernel tree available for the htc dream has nothing to enable it. Documentation from Qualcomm will likely be required in order to make use of the feature.

[Q] is /dev/bus/usb/* Standard in Android

I have an ePad (Android 2.1) that mounts usb devices in the normal Linux way so that I can use libusb to access them, I have managed to control my usb robot arm using an NDK app. Before I move onto making it a proper app instead of a hack job I wanted to know if the usb device files are standard to Android or if it's specific to my system.
Put it this way, if I make a nice cuddly app is it going to fail on most devices or work on most devices? (ones with USB OTG interface)
Sorry, I understand this could be a 'how long is a piece of string' type of question.
Many thanks,
Richard e Collins.
After a few hours of routing about on the internet I found an article on an exploit on the init daemon, google "android-root-source-code-looking-at-the-c-skills". This gave enough insight for me to deduce that this functionality I am getting is present on at least anything running 2.1 and above and is not a customisation unique to my device.

USB host capabilities.

After searching and not finding what I was looking for, I always go to XDA. What android phones from Verizon have usb hosting capabilities. Specifically I want to connect and external hard drive to transfer files. I know you're probably wondering why I just don't use a computer, well my 4 year old son made my computer unusable. Thanks in advance for any help.
Sent from my DINC2
Just look at the market
Search: "usb host"
First result is okay
The problem is:
- Your hardware need to support it
- You need to be root.
But you can try!
---------------------------------
Fernando Setien
I've tried the usb host controllers app, but that was a no go. I have an incredible 2 that is rooted. I should have included this in my first post, but I failed to.
Sent from my DINC2
Also the kernel needs to support it and no stock kernel does that I know of.
Supposedly, Android 3.1 and newer support USB host mode. In some cases you'll need special adapters and/or a powered USB hub. Unfortunately, I'm too new of a user to post outside links (the forum won't let me), but there's much documentation on the Android developer site regarding host mode v. accessory mode, and at least one article/forum thread showing an Android 3.1 tablet with an Android 2.2 phone plugged into it, the tablet reading the phone's logs over the USB connection.
In other words, it's possible, but hardware limitations may make it difficult, as will whatever version of Android you're using.
YellowApple said:
Supposedly, Android 3.1 and newer support USB host mode. In some cases you'll need special adapters and/or a powered USB hub. Unfortunately, I'm too new of a user to post outside links (the forum won't let me), but there's much documentation on the Android developer site regarding host mode v. accessory mode, and at least one article/forum thread showing an Android 3.1 tablet with an Android 2.2 phone plugged into it, the tablet reading the phone's logs over the USB connection.
In other words, it's possible, but hardware limitations may make it difficult, as will whatever version of Android you're using.
Click to expand...
Click to collapse
I am running a ICS and it is not enabled by default. It maybe on Tablets but not mobile phones. A search will lead you to threads about it asking for it to be add to the kernel but you remove options when you do and there has not been alot of want for it.
Native support
At least Samsung Galaxy SII and Note does usb Host with the default ROM. You can see with cable you need (witch could be an issue too) on many blogs.

Accessing USB devices without root from Android NDK code

First up, I tried to post this in "Android Software Development" but unfortunately don't have the minimum 10 posts required to do so and didn't really feel like spamming the forums to make the count. If a moderator could move this post for me it would be greatly appreciated.
On an Android 4.0+ device (ie, contains the USB Host APIs), you can write applications that interface with USB devices that don't require root. Unfortunately I'm working with a codebase that is in C using libusb and while I've gotten a prototype working in a terminal emulator, at this stage it seems to require root to actually talk to the devices (enumerating devices seems ok though).
I had a look at the Android NDK API list but didn't see any reference to USB Host APIs leading me to believe that the only ones that exist are the underlying Linux APIs. Is there a way (without bouncing all calls to the USB Host APIs through JNI, or rewriting the entire thing in Java) to access USB devices when in USB OTG mode without root from Android NDK code?

Anyone know about USB Dev?

Hi,
Android Dev Noob and just looking at the SDK I have this question which probably someone will be able to tell be straight away.
I want to relay USB Host port data to a USB accessory port.
I am looking at the USB Host APIs >= Andriod 3.1
What I want to do is be able to relay the keyboard, mouse and touchscreen that I have connected on the host port and relay that to the OTG.
So here is my noob questions before I waste loads of time.
1... Is it possible to create device manifests on the fly.
I was thinking I could just make devices connected on the host appear as if they are on the accessory port.
If not then I guess I could create some default manifests and pick the most relevant.
2... This is hardware related but many tablets and android boxes have separate usb host & otg ports?
It is possible to have a host and accessory going at the same time.
This might makes things a little easier as the rationale is that I have a windows 8 machine and an RK3288 android box and I want to share the keyboard, mouse and touchscreen.
Video is easy as I can just swap the input between pc & hdmi.
I was thinking if I plugged all my devices into android I could just have a hot Key to redirect to windows 8 or don't capture and use devices on android.
I thought it might be a much simpler way without network needs and have read there are gesture problems with KVM products such as Synergy.
What do you think is it possible, does anyone know if this has already been done and there is an app?
Also if you have any better ideas or some pointers where to start all will be welcome.
Many Thanks
Stuart

Categories

Resources