From 0fb25c303714bf3d54eb57360fd639e791285546 Mon Sep 17 00:00:00 2001 From: kai-morich Date: Mon, 13 Sep 2021 22:08:43 +0200 Subject: [PATCH] persist USB permission --- FAQ.mediawiki | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/FAQ.mediawiki b/FAQ.mediawiki index 796ee2c..dd7570e 100644 --- a/FAQ.mediawiki +++ b/FAQ.mediawiki @@ -38,6 +38,36 @@ Most Arduinos with CDC driver use the DTR line to determine serial channel readi You don't. /dev/tty* is the Linux kernel's driver interface to various serial devices. Certain devices and custom ROMs ''may'' expose serial devices this way, but this library does not use this interface. +== How to persist USB permission? == + +After adding vendor-id and device-id to [https://github.com/mik3y/usb-serial-for-android/blob/master/usbSerialExamples/src/main/res/xml/device_filter.xml device_filter.xml] +the USB device connection dialog has a ''"Always open {app} when {device} is attached"'' checkbox and the permission dialog has a ''"Use by default for this USB device"'' checkbox. + +When the checkbox is selected, the permission is retained over USB device re-attach, also after Android reboot. + +'''If the device remains attached during Android reboot, the permission is only retained in some cases:''' + +The issue is identified in [https://issuetracker.google.com/issues/77658221 Bug 77658221], but set to ''Won't Fix'' by Google. + +The persisted permission file is only loaded when attaching an USB device, so starting the App after reboot without re-attaching any device, the App again asks for permission. +The bug recommends to add android:directBootAware="true" to your activity in AndroidManifest.xml, which improves the situation for some Android devices, e.g.: + +{| +! USB device attached after boot !! colspan="2"|USB device attached during reboot !! !! +|- +! Permission retained on App start !! Permission retained
on App start !! App autostart !! [https://developer.android.com/guide/topics/manifest/activity-element#directBootAware directBootAware] !! Device +|- +| 🟢 || 🟢 || 🟢 || - || Android 11 / Samsung +|- +| 🟢 || 🟢 || 🟢 || true || Android 8 / Samsung +|- +| 🟢 || 🟢 || 🔴 || true || Android 11 / Lineage OS +|- +| 🟢 || 🔴 || 🔴 || false || Android 11 / Lineage OS
Android 8 / Samsung
... +|- +|} + + == Can I open multiple connections in one application? == You can connect to multiple devices and to multiple ports of a multi-port device in one App.