Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

USB Host Mode - device access permission granted but not remembered

Tags:

android

host

usb

I have a USB Host Mode application that works perfectly. I plug in the device, Android pops up the Allow the app APPNAME to access the USB device? permission request window, I check the Use by default for this USB device tick box and tap OK, then up comes my app and it communicates with the USB device perfectly.

BUT...

Then I unplug the device and plug it back in. Android pops up the Allow the app APPNAME to access the USB device? dialog again. WTH? I've already told Android to do this by default, so why is it asking me again?

This happens both with Icecream Sandwich 4.0.3 and Jellybean 4.1.

Ideally I want Android to remember I've granted permission for this particular USB device even after I've rebooted the Android device.

So why isn't Android remembering that I've granted permission?

like image 800
kbro Avatar asked Mar 01 '13 22:03

kbro


People also ask

How do I check USB host mode?

Connect the Android-powered device via USB to your computer. From your SDK platform-tools/ directory, enter adb tcpip 5555 at the command prompt. Enter adb connect <device-ip-address>:5555 You should now be connected to the Android-powered device and can issue the usual adb commands like adb logcat .

What is OTG host mode?

USB On-The-Go (OTG) is a standardized specification that allows a device to read data from a USB device without requiring a PC. With an OTG cable, the device itself becomes the USB host. You can do a lot over an OTG connection, like connecting a USB flash drive or a video game controller to your phone.


2 Answers

This is a dup of USB device access pop-up supression?. Basically the answer is to use an intent-filter on USB_DEVICE_ATTACHED and steer clear of the RequestPermission USB Host Mode API call.

like image 184
kbro Avatar answered Oct 07 '22 18:10

kbro


I answered this here, although I gather that duplicates across other SE sites are permitted.

In answer to why, it is as you surmised in said thread; because with your hardware you get different identifiers each time you connect, e.g. /dev/bus/usb/001/, /dev/bus/usb/002/ and so on.

like image 22
Rob Pridham Avatar answered Oct 07 '22 18:10

Rob Pridham