Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓USB主机和隐藏设备_Android_Api_Usb_Host - Fatal编程技术网

Android 安卓USB主机和隐藏设备

Android 安卓USB主机和隐藏设备,android,api,usb,host,Android,Api,Usb,Host,我正在开发一个Android应用程序,其中我必须与USB设备通信。我尝试在我的应用程序中使用standart google API,但设备列表总是空的 同样的事情,如果我使用USB设备信息与谷歌api。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 0

我正在开发一个Android应用程序,其中我必须与USB设备通信。我尝试在我的应用程序中使用standart google API,但设备列表总是空的

同样的事情,如果我使用USB设备信息与谷歌api。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
我的设备是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
如果我插入诸如rs232适配器、蓝牙加密狗之类的设备,什么都不会发生,API和lsusb也不会产生任何结果

设备的Prtocol基于ezusb库。 安卓版本: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

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

要启用USB主机API支持,您应该添加一个名为
android.hardware.usb.host.xml 并包含以下行:

<permissions>
 <feature name="android.hardware.usb.host"/>
</permissions>
<permissions>
 <feature name="android.hardware.usb.host"/>
</permissions>
在该文件夹中找到名为

handheld_core_hardware.xml or tablet_core_hardware.xml 
handheld_core_hardware.xml or tablet_core_hardware.xml 

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

进入
部分

重新启动设备。Usb主机api应该可以工作


使用android 4在CUBE U30GT上测试。

非常好!这在运行安卓4.0.4的Envizen V700NA上起到了作用

轻微打字错误:

应该是:

程序:

  • adb pull/system/etc/permissions/tablet\u core\u hardware.xml
  • 更新该文件并按照Greg-q的指定创建android.hardware.usb.host.xml
  • adb推送android.hardware.usb.host.xml/system/etc/permissions
  • adb push tablet_core_hardware.xml/system/etc/permissions
  • 重新启动

  • 我在MK809、Android 4.1 Jelly Bean上使用了adb,命令如下:

    adb remount/./../file.xml rw 亚洲开发银行推动

    使用普通命令i'vent权限,文件为只读


    对不起,我的英语不好:p

    在micromax A120 canvas 2手机(kitkat 4.4.2)上工作得很好。现在我可以控制我的Arduino了!我使用busybox工具来完成所有命令行工作(否则chmod将无法工作)。我的步骤(可能有些不是必需的):

    (0)在我的Windows 8计算机上安装PDAnet驱动程序()。 (1) 在上使用Vroot(现在称为iRoot)为手机设置根目录。很简单,唯一的问题是su grant/deny页面部分是中文的,没什么大不了的。 (2) 安装busybox和jackpal的Android终端仿真器(请参阅github或play store)

    (3) 打开终端窗口并成为超级用户:

    # su
    
    (4) 文件系统可能是只读的,因此您可能必须重新安装它:

    # mount -o rw,remount -t yaffs2 /
    

    看 另外,请参见 而且

    (5) 将default.prop设为读/写:

    chmod 666 /default.prop
    
    (6) 编辑/default.prop,进行以下更改:

    ro.secure=0
    ro.debuggable=1
    persist.service.adb.enable=1
    
    看 或

    最后,为了完整起见,正如上面的答案所说():

    (7) 要启用USB主机API支持,您应该添加一个名为 android.hardware.usb.host.xml并包含以下行:

    <permissions>
     <feature name="android.hardware.usb.host"/>
    </permissions>
    
    <permissions>
     <feature name="android.hardware.usb.host"/>
    </permissions>
    
    在该文件夹中找到名为

    handheld_core_hardware.xml or tablet_core_hardware.xml 
    
    handheld_core_hardware.xml or tablet_core_hardware.xml 
    

    <feature name="android.hardware.usb.host" />
    
    
    
    分为三个部分


    (8) 重新启动设备。Usb主机api应该可以正常工作。

    @Greg-q:photoball\u core\u hardware.xml或tablet\u core\u hardware.xml在哪里。我没有得到这些文件。在做了这些更改之后,DeviceList对我来说仍然是空的,尽管我可以在运行dmesgIt时看到我的HID设备正在连接。应该声明,只有当您是ROM开发人员或者您有根和可写(通过重新安装)系统分区时,才可以进行这些更改,只有在硬件支持的情况下才有价值。@Droider您是如何编辑它的?我面临着同样的问题:只读文件system@Gaurav我有一个根设备,所以它不会给我带来任何问题。