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

Commit c584d77b authored by Badhri Jagan Sridharan's avatar 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.

Bug: 34972898
Test: notification should not be queued for a pixel-c charger not connected
to the power outlet.
Change-Id: I4aa19f9f864fe5b77e65f6a07a3184d8aba1f5fc
parent 1b8e847a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -442,7 +442,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) {