From 3c8f067048cff5a0d85bcde8936d0412038b0db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Imhof?= Date: Thu, 12 Sep 2024 11:59:29 +0200 Subject: [PATCH] Fix for USB forwarding on Opaque Android 13 See https://github.com/iiordanov/remote-desktop-clients/issues/526 --- .../main/java/com/undatech/opaque/util/UsbDeviceManager.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/remoteClientLib/src/main/java/com/undatech/opaque/util/UsbDeviceManager.kt b/remoteClientLib/src/main/java/com/undatech/opaque/util/UsbDeviceManager.kt index 199a1f7be..9e803374a 100644 --- a/remoteClientLib/src/main/java/com/undatech/opaque/util/UsbDeviceManager.kt +++ b/remoteClientLib/src/main/java/com/undatech/opaque/util/UsbDeviceManager.kt @@ -70,8 +70,13 @@ class UsbDeviceManager(val context: Context, val usbEnabled: Boolean) { Log.i(TAG, "Requesting permissions for all USB devices") val d = this.getUnrequested() if (d != null) { - val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + val flags = if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) { PendingIntent.FLAG_IMMUTABLE + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + // Special case for Android 13, because for some reasons FLAG_IMMUTABLE causes + // issues with USB forwarding. + // See https://github.com/iiordanov/remote-desktop-clients/issues/526 + PendingIntent.FLAG_MUTABLE } else { 0 };