質問

I am working on a custom hardware for an Android-tablet using the VNC2 chip.

On the VNC2 chip I have flashed some custom firmware I have made. I have set the USB VendorID to 0403 and USB ProductId to 6001.

I also have an Android-app I am working on. I have added the following to the in the manifest:

<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" />      

device_filter.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <usb-device/>
</resources>

My goal is that this app should start if I connect the USB device. This does not work however. I have downloaded a tool from Google Play called "USB Host Controller" and this app showed me that the USB device was connected so some parts seem to work.

I have also seen output in logcat while connecting the device:

I/USB3G   (   91): event { 'add', '/devices/platform/sw_hcd_host0/usb1/1-1', 'usb', '', 189, 12 }
I/USB3G   (   91): path : '/sys/devices/platform/sw_hcd_host0/usb1/1-1'
I/USB3G   (   91): VID :size 5,vid_path '/sys/devices/platform/sw_hcd_host0/usb1/1-1/idVendor',VID  '0403
I/USB3G   (   91): '.
I/USB3G   (   91): PID :size 5,Pid_path '/sys/devices/platform/sw_hcd_host0/usb1/1-1/idProduct',PID  '6001
I/USB3G   (   91): '.
I/USB3G   (   91): cmd=/system/etc/usb_modeswitch.sh /system/etc/usb_modeswitch.d/0403_6001 &,
I/USB3G   (   91): excute ret : 0,err:No such file or directory

Digging into modeswitch it seem like a tool to switch state on mainly USB 3G modems. My first guess is that I have a very crippled image on my device (Allwinner A10 based). But it might also be some error in my app even though I find it unlikely. According to my understanding I should be presented with some kind of dialog when inserting an OTG hardware regardless if I have an app installed with a matching intent-filter, or am I wrong?

Any ideas would be appreciated. I can change the apk in any way if required. The tablet is rooted and I can change files in any way possible. Would be happy to try any ideas that you have.

役に立ちましたか?

解決

Now I have finally solved the issue. The main problem seem to be that I need to have an application installed with the intent-filter for anything to happen. It is a bit odd since hardware using AOA (Android Open Accessory Protocol) will show a dialog and direct you to Google Play for download if you don't have an app that can handle the accessory.

USB OTG devices will however silently ignore that you connect them to your Android device if you have no app with an intent-filter matching the USB vendor and device Ids. When testing I had an app without the intent-filter installed. Thought I would get a dialog like in AOA, but here I was wrong.

The only thing I needed to add to the rom for OTG to work was the android.hardware.usb.host.xml into /system/etc/permissions. Then it all worked perfectly.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top