diff options
| author | 2024-07-31 16:02:29 +0000 | |
|---|---|---|
| committer | 2024-08-08 13:44:26 +0000 | |
| commit | 2d5001df3ead38dc88752d291ca6fb8a63c44ef7 (patch) | |
| tree | 6b3c8326ef3625b0e7ac1593719e335948f858e5 | |
| parent | 6774b759ae411f6305f95f2865745b370f59d855 (diff) | |
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
Change-Id: I698e9df0333cbb51dd9bd5917a94d81273a2784a
Merged-In: I698e9df0333cbb51dd9bd5917a94d81273a2784a
(cherry picked from commit 7c6ec68537ba8abf798afd9ab7c3e5889841171f)
| -rw-r--r-- | services/usb/java/com/android/server/usb/UsbDeviceManager.java | 11 |
1 files 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 77b263824b78..3d012f6eacc0 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -819,7 +819,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser } } - private void notifyAccessoryModeExit(int operationId) { + protected void notifyAccessoryModeExit(int operationId) { // make sure accessory mode is off // and restore default functions Slog.d(TAG, "exited USB accessory mode"); @@ -2145,8 +2145,13 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser */ operationId = sUsbOperationCount.incrementAndGet(); if (msg.arg1 != 1) { - // Set this since default function may be selected from Developer options - setEnabledFunctions(mScreenUnlockedFunctions, false, operationId); + if (mCurrentFunctions == UsbManager.FUNCTION_ACCESSORY) { + notifyAccessoryModeExit(operationId); + } else { + // Set this since default function may be selected from Developer + // options + setEnabledFunctions(mScreenUnlockedFunctions, false, operationId); + } } break; case MSG_GADGET_HAL_REGISTERED: |