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

Commit 9a2686ae authored by Ashish Kumar Gupta's avatar Ashish Kumar Gupta
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
Change-Id: I698e9df0333cbb51dd9bd5917a94d81273a2784a
Merged-In: I698e9df0333cbb51dd9bd5917a94d81273a2784a
(cherry picked from commit 7c6ec685)
parent e4dddd33
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -753,7 +753,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");
@@ -2002,9 +2002,14 @@ 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
                        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:
                    boolean preexisting = msg.arg1 == 1;