DivestOS/Patches/LineageOS-18.1/android_frameworks_base/408445.patch
Tavi 7ecc843451
Churn
Signed-off-by: Tavi <tavi@divested.dev>
2024-11-13 08:02:54 -05:00

54 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ashish Kumar Gupta <kumarashishg@google.com>
Date: Wed, 31 Jul 2024 16:02:29 +0000
Subject: [PATCH] Set no data transfer on function switch timeout for accessory
mode
In case of function switch times out, we will check whether
the last function set was accessory. If this is the case, it is
recommended to set the function to NONE(No data transfer) rather than
setting it to the default USB function.
Bug: 353712853
Test: Build the code, flash the device and test it.
Test: atest CtsUsbManagerTestCases
Test: run CtsVerifier tool
Test: atest CtsUsbTests
(cherry picked from commit 7c6ec68537ba8abf798afd9ab7c3e5889841171f)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b032a602cdad00687e1fe089d66a6c4fa6925d79)
Merged-In: I698e9df0333cbb51dd9bd5917a94d81273a2784a
Change-Id: I698e9df0333cbb51dd9bd5917a94d81273a2784a
---
.../java/com/android/server/usb/UsbDeviceManager.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index a7a51a151b97..8a6731e2e5ee 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -659,7 +659,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
}
}
- private void notifyAccessoryModeExit() {
+ protected void notifyAccessoryModeExit() {
// make sure accessory mode is off
// and restore default functions
Slog.d(TAG, "exited USB accessory mode");
@@ -1791,8 +1791,13 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
* Dont force to default when the configuration is already set to default.
*/
if (msg.arg1 != 1) {
- // Set this since default function may be selected from Developer options
- setEnabledFunctions(mScreenUnlockedFunctions, false);
+ if (mCurrentFunctions == UsbManager.FUNCTION_ACCESSORY) {
+ notifyAccessoryModeExit();
+ } else {
+ // Set this since default function may be selected from Developer
+ // options
+ setEnabledFunctions(mScreenUnlockedFunctions, false);
+ }
}
break;
case MSG_GADGET_HAL_REGISTERED: