Skip to content

Commit

Permalink
Set no data transfer on function switch timeout for accessory mode
Browse files Browse the repository at this point in the history
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:3c16bf88ed7896af98f669246c21b17f1018068b)
Merged-In: I698e9df0333cbb51dd9bd5917a94d81273a2784a
Change-Id: I698e9df0333cbb51dd9bd5917a94d81273a2784a
  • Loading branch information
199ashish authored and aoleary committed Nov 18, 2024
1 parent 8648665 commit 851fc47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions services/usb/java/com/android/server/usb/UsbDeviceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ private void updateCurrentAccessory() {
}
}

private void notifyAccessoryModeExit() {
protected void notifyAccessoryModeExit() {
// make sure accessory mode is off
// and restore default functions
Slog.d(TAG, "exited USB accessory mode");
Expand Down Expand Up @@ -2002,8 +2002,13 @@ public void handleMessage(Message msg) {
* 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:
Expand Down

0 comments on commit 851fc47

Please sign in to comment.