I want to use android in industry,
I can connect to Profilic and Ftdi USB to Serial chips with slickdevlabs.com library without any problem.
The application has a service and it starts on boot,connect to the usb serial port and do the other things.
my problem is that the host device does not have any interaction with user,
so when the android asks
Allow the app "MyAPP" to access the USB device ?
[checkmark]Use by default for this USB device
Cancel OK
there is no person to click on ok.
even when I check the use by default... checkbox,If I reinsert the USB ,or reboot the host device, it asks again on next boot.
I ran the service and app with SuperUser mode,but no difference,it asks again.
I added intent filter but no difference,it asks me every time.
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
android:resource="@xml/device_filter" />
Any opinion how to bypass or disable it ?
I have root and SU access.
I think we can do this by making some modifications in
/etc/udev
. We could add the vendor id and device id into the51-android.rules
file.At the first time, when it needs confirm, you can select "always", then even if the Android device is powered down, and powered up, your app still has permission to access the USB2Serial. Just to say, only one time confirm!
If you have the option to compile the android system, then there's nothing you cannot do.
You can add
to frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java
to bypass the the permission confirmation popup.
I think white-listing the accessory you are using in advance will be the best solution. To do this you need to add the file usb_device_manager.xml at this location /data/system/users/0
// Note that 0 is user ID, it will probably be 0 if you didn't add more users in Android but if you did change this ID accordingly
This is how file should look:
For a board like this http://www.embeddedartists.com/products/app/aoa_kit.php it is:
One way to achieve this, note that this does not actually get rid of the confirmation, would be to pinpoint the location of the
checkbox
and use the Android equivalent of the Robot class to select it and then selectOK
. You could write a application that runs in the background, it could even be called by that startup service that you mentioned, specifically for this purpose.According to the documentation on Android Developers you already have permission to the attached USB device when your app gets started trough your manifest intent filter. Perhaps you should try this approach and write a filter to exact match the device you want to use, to prevent that other apps also want to communicate with the device.
See the "Note" on http://developer.android.com/guide/topics/connectivity/usb/host.html#permission-d