Android Usb Host Problem with Samsung Galaxy 10.1 Tablet
Asked Answered
S

6

6

I am attempting to leverage the USB host capability on the Samsung Galaxy Tablet. I purchased the attachment dongle from samsung (http://www.samsung.com/us/mobile/galaxy-tab-accessories/EPL-1PL0BEGSTA). When I first connected a usb device via this dongle, I had a high power error from the Galaxy Tablet -- FYI use an externally powered USB hub and you can bipass this.

Now that the device itself is acknowledging the existance of a USB peripheral when I attach it, I attempted to use Android's android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; library. I saw that there are two methods for recognizing a USB device, registering a broadcast receiver to listen for the intents via

IntentFilter usbIntentFilter = new IntentFilter();
usbIntentFilter.addAction("android.hardware.usb.action.USB_DEVICE_ATTACHED");          
usbIntentFilter.addAction("android.hardware.usb.action.USB_DEVICE_DETACHED"); 
registerReceiver(mUsbReceiver,usbIntentFilter);

This is not firing any intents when I attach any devices, strange...ok. So I went on to try the next method: explicitly querying for a device list via the UsbManager -- this was accomplished as follows:

HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
    int count = deviceList.size();
    Iterator<UsbDevice> iterator = deviceList.values().iterator();

    if(iterator.hasNext()){
    UsbDevice deviceVal = iterator.next();
    testTxtView1.setText("set device " + deviceVal); 
    }

This would presumably grab the one (only one USB device currently supported per Google Documentation) USB device that is currently connected. To test this I would call the above code upon a button click and display the device results. For some reason, I am getting a device from the device list every time, whether a USB dongle is connected or not. Furthermore, the device is the same every time regardless of the USB dongle (or lack thereof). The output is as follows:

device usbDevice[mName=/dev/bus/usb/001/002,mVendorId=1256,mProductId=27033,mClass=0,mSubClass=0,mProtocol=0,mInterfaces=[Landroid.os.Parcelable;@406ff4d8]

^^ the @406ff4d8 value changes every time I query this code (I just put a single instance of it up)

I have searched everywhere and have not been able to find any similar problems or solutions that may apply to my situation. I have tried implementing google's USB examples (which is exactly what I have essentially, I ripped theirs) and am running into these problems.

I should also mention the makeup of my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="edu.mit.ll.drm4000"
  android:versionCode="1"
  android:versionName="1.0">
<uses-feature android:name="android.hardware.usb.host" />
<uses-sdk android:minSdkVersion="12" />

<application android:icon="@drawable/icon" android:label="@string/app_name">


    <activity android:name=".DRM4000Activity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
        </intent-filter>

        <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
            android:resource="@xml/device_filter" />

    </activity>

</application>

and device filter:


(I removed criteria on the device filter but have also tried inserting specific information about the device I am looking for...both to no avail.)

Any help regarding this problem would be much appreciated!


Another update: The device I complained about always being enumerated on the device list

device usbDevice[mName=/dev/bus/usb/001/002,mVendorId=1256,mProductId=27033,mClass=0,mSubClass=0,mProtocol=0,mInterfaces=[Landroid.os.Parcelable;@406ff4d8]

must be the android side usb port or something...because I started attaching a bunch of different devices to my code and found that (similar to this link: USB_DEVICE_ATTACHED Intent not firing) HID devices, arduino devices..and sadly... my USB device do not appear to fire an intent or get enumerated by the USB hub. I tried with a USB flash drive and it DID enumerate it and worked...however it shows up as the SECOND device on the list, the first being the ever-present usbDevice listed above. Intents do fire with it though.

Does anyone know a workaround to making intents fire with HID devices and other USB devices except the select few android seems to do now?

Sibie answered 23/9, 2011 at 21:8 Comment(3)
can you verify that USB host works for any other apps? Try connecting a PTP camera and see if gallery notices the intent being broadcasted. I assume youve tried rebooting and have updated your Tab to the latest version.Aleishaalejandra
When I plug in a keyboard, it seems to work. I get a "USB Device Connected" message when I plug it in. However, the above code gives me the same output with a keyboard, other usb device plugged in, or nothing plugged in. I dont understand why it is claiming to see a usb device regardless. I know it must be something with my code since keyboard is recognized just fine. BTW : when I connect other device it says "Unknown USB Device Connected"Sibie
Another update: The device I complained about always being enumerated on the device list must be the android usb port or something...because I started attaching a bunch of different devices to my code and found that (similar to this link: USB_DEVICE_ATTACHED Intent not firing) HID devices, arduino devices,and my USB device do not to fire an intent or get enumerated by the USB hub. I tried with a USB flash drive and it DID enumerate it and worked...however it shows up as the SECOND device on the list, the first being the ever-present usbDevice listed above. Intents do fire with it though.Sibie
S
5

SOO unfortunately it looks like the Samsung Galaxy Tablet just does not play nicely with the UsbManager and about half of the USB devices in the world. The kernel in Samsung seems to fire intents for storage devices and the like, but not for HID and other random devices (such as arduino, and my usb sensor, and HID devices as well.) It seems to be a bug in samsung kernel. Interestingly, the HID devices WORK on the tablet, but are not enumerated on the UsbManager. I have found several links of the same problem, and it seems like a kernel patch (or the acer tablet) are the only ways around this atm. hopefully samsung will fix in the future. Here is a link to a guy who did a kernel patch if rebuilding the kernel is your thing and you really need to get UsbManager working. I have not tested but plan to eventually, and will leave a comment on my thoughts. http://forum.xda-developers.com/showthread.php?t=1233072

Sibie answered 28/9, 2011 at 17:28 Comment(2)
The kernel patch you linked to does not apply here. It's for the Samsung Galaxy Tab 7", but the parent is talking about the Samsung Galaxy Tab 10.1 since he's he's targeting Honeycomb as the minimum SDK in his Manifest.Yukikoyukio
Is there REALLY still no update available to get USB host mode to work on Samsung without any tinkering? I am using an Acer Iconia 500, and there everything works without any problems - I would love to have it on a Samsung tooVerdha
E
1

I am facing same problem but you can use one method deviceName(), after enumerating device you can store device name in a string using device.getdeviceName() method.

you will get exact device name appart from full information of device.

Equi answered 13/2, 2012 at 9:24 Comment(0)
B
0

Samsung has removed the USB API from the Android Kernal

Barone answered 2/10, 2011 at 21:33 Comment(0)
M
0

i think you should define the device you want to recognize in resource/xml/device_filter.xml. you can referring the android api.

Mama answered 13/6, 2013 at 7:28 Comment(0)
N
0

There may be another (nasty) reason why you can't see your HID device.

UsbHostManager.beginUsbDeviceAdded() "Called from JNI in monitorUsbHostBus() to report new USB devices". This method calls a private method isBlackListed() which will unconditionally filter out all HUB's, and HID's with subclass BOOT. This may be the reason why you don't see HID devices when you do a getDeviceList()

If anyone has a workaround to this, I think that there are a fair amount of users out there who would appreciate see this.

Nominal answered 27/3, 2017 at 21:52 Comment(0)
R
-2

I have had succesfully attached my Arduino Uno to my samsung galaxy tab 10 P7500. If you have a problem connecting it, It is because the tablet deny permission for the usb devices that doesn't have external power. Try to power your device externally using 5 or 3.3 Volt AC/DC Adaptor, for the first time, if you find your device attached and fire the intent, unplug the power adaptor, and your device would operate without external power, the tablet itself would give the power through USB OTG

Resuscitate answered 16/12, 2014 at 4:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.