本文介绍了与三星Galaxy 10.1平板电脑的Andr​​oid USB主机问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图利用对三星Galaxy平板电脑的USB主机功能。我购买三星(http://www.samsung.com/us/mobile/galaxy-tab-accessories/EPL-1PL0BEGSTA)附件加密狗。当我第一次通过该适配器连接的USB设备,我从银河平板电脑的高功率错误 - 仅供参考使用外部电源的USB集线器,您可以bipass这种

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.

现在,本身就是承认,当我将其附加一个USB外围设备是否存在等设备,我试图使用Android的android.hardware.usb.UsbDevice;进口android.hardware.usb.UsbManager;图书馆。我看到有两种方法可以识别USB设备,注册一个广播接收器监听意图通过

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);

这在不触发任何意图,当我连接任何设备,奇怪... OK。所以,我继续尝试下一个方法:明确的查询通过UsbManager设备列表 - 这是这样进行的:

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);
    }

这将presumably抢一个是当前连接的USB设备(目前为谷歌文档只支持一个USB设备)。为了验证这一点,我将呼吁一个按钮,点击上面的code和显示设备的效果。出于某种原因,我每次都得到一个设备,从设备列表中,无论是USB适配器连接与否。此外,该装置是相同的,无论在USB加密狗(或缺乏)的每一次。所述输出如下:

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:

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

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

^^的@ 406ff4d8值更改每次我查询这个code时间(我只是把它的单个实例)

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

我已到处搜寻,并一直没能找到任何类似的问题或解决方案,可以适用于我的情况。我曾尝试推行谷歌的USB例子(这正是我有本质上,我撕开他们的)和我遇到了这些问题。

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>

和设备过滤器:


   

(我删除了标准的设备筛选器,但也试图插入约我在寻找......既没有用该设备的具体信息。)

(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.)

任何有关此问题的帮助将是非常美联社preciated!

Any help regarding this problem would be much appreciated!

另一个更新:我抱怨总是被列举的设备列表

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

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

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

必须在机器人侧的USB端口或东西...因为我开始安装了一堆不同的设备来我的code和发现(类似于此链接:USB_DEVICE_ATTACHED意图不烧)HID设备,Arduino的devices..and可悲的是...我的USB设备似乎不火的意图或获得由USB集线器枚举。我试着用USB闪存驱动器,它并列举它和工作......但它显示为列表中的第二个设备,第一个是ever- present上面列出usbDevice。意图不火与它虽然。

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.

有谁知道一个变通方法来制作意图火与HID设备和其他USB设备,除了少数的Andr​​oid似乎现在怎么办?

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?

推荐答案

SOO不幸的是,它看起来像三星Galaxy平板电脑只是没有很好地与UsbManager和大约一半的USB设备在世界上的发挥。在三星内核似乎火意图为存储装置等,但并不适用于HID和其他随机设备(如阿尔杜伊诺,以及我的USB传感器,和HID器件。)这似乎是在三星内核中的错误。有趣的是,HID设备工作的平板电脑,但没有列举的UsbManager。我发现了同样的问题的几个环节,这似乎是一个内核补丁(或宏碁平板电脑)都是围绕该ATM的唯一途径。希望三星将在未来解决。这里是一个链接到一个人谁做了一个内核补丁,如果重新编译内核是你的事情,你真的需要得到UsbManager工作。我没有测试过,但计划最终,并留下我的想法评论。 http://forum.xda-developers.com/showthread.php?t=1233072

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

祝大家

这篇关于与三星Galaxy 10.1平板电脑的Andr​​oid USB主机问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-09 20:33