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

Commit 6f9dbb12 authored by Jerry Zhang's avatar Jerry Zhang
Browse files

Reorder USB_STATE updates so config_changed is not replaced.

Because of flag INTENT.ACTION_REPLACE_PENDING, intents
sent in rapid succession could replace previous intents
that have not been processed, and it is unreliable when
or whether this happens. Since CONFIG_CHANGED cannot afford
to be lost, make sure it is sent last, so it is always
processed.

Bug: 34873000
Test: lots of unplugging/plugging
Change-Id: I9264d5129139cf3f433bbcd068e8b292fec6cd31
parent 740ca0f9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -909,18 +909,20 @@ public class UsbDeviceManager {

                    updateUsbNotification(false);
                    updateAdbNotification(false);
                    if (mBootCompleted) {
                        Slog.i(TAG, "update state " + mConnected + " " + mConfigured);
                        updateUsbStateBroadcastIfNeeded(false);
                    }
                    if (UsbManager.containsFunction(mCurrentFunctions,
                            UsbManager.USB_FUNCTION_ACCESSORY)) {
                        updateCurrentAccessory();
                    }
                    if (mBootCompleted) {
                        Slog.i(TAG, "update state " + mConnected + " " + mConfigured);
                        if (!mConnected) {
                            // restore defaults when USB is disconnected
                            Slog.i(TAG, "Disconnect, setting usb functions to null");
                            setEnabledFunctions(null, false, false);
                        }
                        updateUsbStateBroadcastIfNeeded(false);
                        updateUsbFunctions();
                    } else {
                        mPendingBootBroadcast = true;