Android USB主机和隐藏设备

Ale*_*kov 24 api usb android host

我正在开发一个Android应用程序,我必须在其中与USB设备进行通信.我尝试在我的应用中使用标准谷歌API,但设备列表总是空的.

如果我使用谷歌API的USB设备信息相同的事情.google api搜索到的设备列表为空,

lsusb给出以下结果:

Bus 001 Device 001: ID 1d6b:0001
Bus 002 Device 001: ID 1d6b:0002
Bus 003 Device 001: ID 1d6b:0001
Bus 002 Device 002: ID 2226:0014
Run Code Online (Sandbox Code Playgroud)

我的设备是2226:0014

日食日志:

I/USB3G(92): event { 'add', '/devices/platform/sw-ehci.1/usb2/2-1', 'usb', '', 189, 133 }
I/USB3G(92): path : '/sys/devices/platform/sw-ehci.1/usb2/2-1'
I/USB3G(92): VID :size 5,vid_path '/sys/devices/platform/sw-ehci.1/usb2/2-1/idVendor',VID  '2226
I/USB3G(92): '.
I/USB3G(92): PID :size 5,Pid_path '/sys/devices/platform/sw-ehci.1/usb2/2-1/idProduct',PID  '0014
I/USB3G(92): '.
I/USB3G(92): cmd=/system/etc/usb_modeswitch.sh /system/etc/usb_modeswitch.d/2226_0014 &,
I/USB3G(92): excute ret : 0,err:No such file or directory
Run Code Online (Sandbox Code Playgroud)

如果我插入像rs232适配器,蓝牙加密狗这样的设备,没有任何反应,API和lsusb没有任何结果.

设备的Prtocol基于ezusb库.Android v.:4.0.3内核版本:3.0.8固件版本:crane_evb-eng 4.0.3 IMLK74k 20120330

有没有办法通过API访问隐藏的USB设备,还是应该通过编写驱动程序并将其修补到固件来实现对该设备的支持?

更新:即使我在*system/etc/usb_modeswitch.d/*中创建包含名称2226_0014的信息文件

DefaultVendor= 0x2226
DefaultProduct=0x0014
TargetVendor=  0x2226
TargetProductList="0014"
MessageEndpoint="0x00"
NeedResponse=1
CheckSuccess=20
Run Code Online (Sandbox Code Playgroud)

我得到同样的错误:"没有这样的文件或目录"

小智 43

要启用USB主机API支持,您应该添加名为
android.hardware.usb.host.xml的文件 ,其中包含以下行:

<permissions>
 <feature name="android.hardware.usb.host"/>
</permissions>
Run Code Online (Sandbox Code Playgroud)

进入文件夹

/system/etc/permissions
Run Code Online (Sandbox Code Playgroud)

在该文件夹中查找名为的文件

handheld_core_hardware.xml or tablet_core_hardware.xml 
Run Code Online (Sandbox Code Playgroud)

并添加

<feature name="android.hardware.usb.host" />
Run Code Online (Sandbox Code Playgroud)

进入<permissions>部分.

重启设备.Usb主机api应该工作.

使用android 4在CUBE U30GT上测试.


mar*_*les 6

优秀!这适用于运行Android 4.0.4的Envizen V700NA.

小错字: <feature name="android.hardware.usb.host">

应该: <feature name="android.hardware.usb.host"/>

程序:

  1. adb pull /system/etc/permissions/tablet_core_hardware.xml
  2. 更新该文件并创建Greg-q指定的android.hardware.usb.host.xml.
  3. adb push android.hardware.usb.host.xml/system/etc/permissions
  4. adb push tablet_core_hardware.xml/system/etc/permissions
  5. 重启.