2

I have an android application that connects to a USB device using an OTG connection. When plugging in the device, it shows a popup where you can select allow and a checkbox where you can remember this decision. I encountered an issue where it would not remember permissions, as explained in this topic:

USB device access pop-up supression?

The solution given in the topic fixed the issue perfectly for my Moto G with android 4.4.4 installed. As a side effect, whenever the permissions are remembered, it launches the application whenever its not open and the device is attached which is cool!

However when I try the same thing on my Sony Xperia Z1 Compact, with android 5.0.2, it does not remember my preference, nor does the application launch automatically and the dialogue keeps popping up every time permissions are requested by the app. So it seems like the remember check-box does not work!

The activity in my manifest:

<activity
    android:name="--removed--"
    android:screenOrientation="portrait"
    android:configChanges="orientation|keyboardHidden"
    android:label="@string/titlebar_text" >
    <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/config" />
</activity>

Config.xml:

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

So to be clear; this works as expected on my 4.4.4 phone, but not on my 5.0.2 phone. To me this seems to be a android 5 related issue, where permissions may work a bit differently. Is this fixable in my manifest somehow?

Basez
  • 23
  • 5
  • I tested on various other phones using Android 5.0+ and so far this doesn't seem to be related to a specific phone, but instead is an issue that is specific to 5.0. Maybe it has to do with the full enforcement of SELinux on Android 5+ ? – Basez Jun 12 '15 at 15:03
  • Did anyone find a solution to this. We have an issue whereby if the USB printer we're using looses power the tablet then asks for permission again before it can be used. When in kiosk mode this permission prompt fails. – fraserh Dec 22 '15 at 13:32

0 Answers0