Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc51b1be authored by Ashish Kumar Gupta's avatar Ashish Kumar Gupta Committed by Android Build Coastguard Worker
Browse files

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 https://googleplex-android-review.googlesource.com/q/commit:7c6ec68537ba8abf798afd9ab7c3e5889841171f)
Merged-In: I698e9df0333cbb51dd9bd5917a94d81273a2784a
Change-Id: I698e9df0333cbb51dd9bd5917a94d81273a2784a
parent bd19f063
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -78,9 +78,9 @@ import android.os.storage.StorageVolume;
import android.provider.Settings;
import android.service.usb.UsbDeviceManagerProto;
import android.service.usb.UsbHandlerProto;
import android.text.TextUtils;
import android.util.Pair;
import android.util.Slog;
import android.text.TextUtils;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
@@ -838,7 +838,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");
@@ -2271,9 +2271,14 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                     */
                    operationId = sUsbOperationCount.incrementAndGet();
                    if (msg.arg1 != 1) {
                        // Set this since default function may be selected from Developer options
                        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:
                    boolean preexisting = msg.arg1 == 1;