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

Commit 615d5d65 authored by James Wei's avatar James Wei
Browse files

USB: Increase debounce time for DISCONNECT processing (revised)



Original patch: aosp/1539944

Bug: 207057578
Test: See details in b/209342433
Change-Id: I7ff58a1a9755939ccb26dad61969902ec91f2225
Signed-off-by: default avatarJames Wei <jameswei@google.com>
(cherry picked from commit 06626cef)
Merged-In: I7ff58a1a9755939ccb26dad61969902ec91f2225
parent 6fb87bd8
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -175,7 +175,11 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
    // Delay for debouncing USB disconnects.
    // We often get rapid connect/disconnect events when enabling USB functions,
    // which need debouncing.
    private static final int UPDATE_DELAY = 1000;
    private static final int DEVICE_STATE_UPDATE_DELAY_EXT = 3000;
    private static final int DEVICE_STATE_UPDATE_DELAY = 1000;

    // Delay for debouncing USB disconnects on Type-C ports in host mode
    private static final int HOST_STATE_UPDATE_DELAY = 1000;

    // Timeout for entering USB request mode.
    // Request is cancelled if host does not configure device within 10 seconds.
@@ -636,7 +640,9 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
            msg.arg1 = connected;
            msg.arg2 = configured;
            // debounce disconnects to avoid problems bringing up USB tethering
            sendMessageDelayed(msg, (connected == 0) ? UPDATE_DELAY : 0);
            sendMessageDelayed(msg,
                    (connected == 0) ? (mScreenLocked ? DEVICE_STATE_UPDATE_DELAY
                                                      : DEVICE_STATE_UPDATE_DELAY_EXT) : 0);
        }

        public void updateHostState(UsbPort port, UsbPortStatus status) {
@@ -651,7 +657,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
            removeMessages(MSG_UPDATE_PORT_STATE);
            Message msg = obtainMessage(MSG_UPDATE_PORT_STATE, args);
            // debounce rapid transitions of connect/disconnect on type-c ports
            sendMessageDelayed(msg, UPDATE_DELAY);
            sendMessageDelayed(msg, HOST_STATE_UPDATE_DELAY);
        }

        private void setAdbEnabled(boolean enable) {