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

Commit abd229b7 authored by Badhri Jagan Sridharan's avatar Badhri Jagan Sridharan Committed by Badhri Jagan Sridharan
Browse files

Introduce debounce to filter rapidly toggling type-c ports

Type-c ports can quickly toggle between connected/disconnected
states. Introduce debounce to prevent sending spurious notifications.

Cherry-pick: https://android-review.googlesource.com/#/c/338266/
Bug: 34972898
Test: notification should not be queued for a pixel-c charger not connected
to the power outlet.
Change-Id: I4aa19f9f864fe5b77e65f6a07a3184d8aba1f5fc
parent 843aba77
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -470,7 +470,10 @@ public class UsbDeviceManager {
            args.argi2 = sourcePower ? 1 :0;
            args.argi3 = sinkPower ? 1 :0;

            obtainMessage(MSG_UPDATE_HOST_STATE, args).sendToTarget();
            removeMessages(MSG_UPDATE_HOST_STATE);
            Message msg = obtainMessage(MSG_UPDATE_HOST_STATE, args);
            // debounce rapid transitions of connect/disconnect on type-c ports
            sendMessageDelayed(msg, UPDATE_DELAY);
        }

        private boolean waitForState(String state) {