In an Android app, I need permission for a specific USB device (known vendor/product ID), which is permanently plugged on the Android device.
So far I've made the following observations:
when using UsbManager.requestPermission() the permission is dismissed when replugging/rebooting and the popup's checkbox seems to have no effect at all on this behavior
when using intent filters, the permission is properly re-granted when replugging the USB device (even when replugging after a reboot, if the popup's checkbox was checked) BUT the permission is not re-granted after reboot unless I unplug & replug the USB device.
Is it possible to make sure that the permission popup is displayed only once ? (especially in the scenario when the Android device is rebooted and the USB device remains plugged in)
NB: the app isn't installed in the system folder and therefore cannot use the MANAGE_USB permission.
The solution is to use intent filters and add the android:directBootAware="true" attribute on the associated activity so that the USB_DEVICE_ATTACHED event is correctly received after boot.
Persisting USB Permission is not possible, as the reboot option is stopping everything forcefully generally it makes the USB also unplugged.
There is one possibility to ask for replugging USB on reboot.
Is it possible to make sure that the permission popup is displayed only once? No
Because If your are connecting the usb which makes a deadlock situation for taking care of that they make it unplugged, rather than disturbing the system.
So it is not possible to make it USB Plugged-in.
Related
I'm working on a B2B app, using a USB device as part of the product.
We are running the app in a kiosk mode through an EMM provider and almost everything works nicely.
The only issue at the moment is that every time the tablet restarts or if the app is updated, the app will ask for permission to access the connected USB device.
Since we know exactly which USB device will be plugged into the devices (vendor-id and such), is there a way to allow the app to have permission to this specific usb device?
Through the EMM kiosk mode we can provide all other permissions automatically, except the USB permission.
Hope that someone can help me out, thanks!
Struggling a bit with Android >=10's UsbDevice class and detecting re-attachment of the same USB device. Prior to Android 10, I could use UsbDevice.getSerialNumber to get a unique handle for a USB device (if it had one). UsbDevice.getDeviceName tends to change from attach to attach e.g. /dev/bus/usb/001/002, /dev/bus/usb/001/003. For Android >=10 you need to ask for user USB permission before calling getSerialNumber. Without having a manifest intent filter for the USB device type and saving the App as the preferred client this is now very messy - a new Permission Request dialogue is needed for each re-attach. Has anyone found a workaround for this? USB OTG connectors are not the most secure so yank then re-plug is a reasonable thing to want to do.
So I have an application that is pinned to the device with startLockTask command and it has several restrictions so the user cannot escape from the application or change settings of the device.
However, the user should be able to transfer files from the device to a computer via USB, but when the device is connected to a "new" PC, the USB permission dialog: Allow access to device data is not shown because of the LockTask mode.
Is there any way to open that dialog in front of my application?
Faced the same problem today,
in my case I solved it by adding com.android.systemui package, while adding my whitelist application's in setLockTaskPackages DPM's method.
After this I can see the dialogue which was blocking up in LockTask mode.
My device is such that my android app is always connected to an Arduino board through a USB. On device reboot my Android app forgets the USB permissions granted using intent filter in the manifest. I want my app to remember permissions for communicating with the Arduino board across power on/off cycles (Something that it is currently not doing).
So I found out that there isn't a way to go about it yet. So thank you for your time.
I am working on a project where I need to put a USB device in to a reprogramming state and then send a software update to the device. I have been able to make this work by having the user disconnect and reconnect the USB cable between the android device and the USB device I am reprogramming. I have attempted many combinations of releasing interface and then trying to loop through the USBManager getDeviceList and then requestPermission on that device again. I have tried modifying the PendingIntent to be different than the original PendingIntent. I thought I had it once but it seems to have been a faulty OTG cable. In a last ditch effort I tried to craft my own android.hardware.usb.action.USB_DEVICE_ATTACH/DETACH message (which I got a Permission Denial on) Any other ideas out there or is it just not possible?