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

Commit 37ffba8d authored by Ricky Niu's avatar Ricky Niu Committed by Chien Kun Niu
Browse files

usb: Add the boot completed check before broadcasting intent



Broadcasting intent is not allowed before boot completed.
Check if boot completed to broadcast accessory time out
intent to avoid exception.

Bug:229387375
Test: Reboot with head unit connected

Signed-off-by: default avatarRicky Niu <rickyniu@google.com>
Change-Id: I34bc7625bbcb9525ad25cb1538ed4138fcae8ead
parent 54a8dee1
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -556,6 +556,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
        protected boolean mCurrentUsbFunctionsReceived;
        protected int mUsbSpeed;
        protected int mCurrentGadgetHalVersion;
        protected boolean mPendingBootAccessoryHandshakeBroadcast;

        /**
         * The persistent property which stores whether adb is enabled or not.
@@ -1113,7 +1114,13 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                    if (DEBUG) {
                        Slog.v(TAG, "Accessory handshake timeout");
                    }
                    if (mBootCompleted) {
                        broadcastUsbAccessoryHandshake();
                    } else {
                        if (DEBUG) Slog.v(TAG, "Pending broadcasting intent as "
                                + "not boot completed yet.");
                        mPendingBootAccessoryHandshakeBroadcast = true;
                    }
                    break;
                }
                case MSG_INCREASE_SENDSTRING_COUNT: {
@@ -1137,8 +1144,11 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                if (mCurrentAccessory != null) {
                    mUsbDeviceManager.getCurrentSettings().accessoryAttached(mCurrentAccessory);
                    broadcastUsbAccessoryHandshake();
                } else if (mPendingBootAccessoryHandshakeBroadcast) {
                    broadcastUsbAccessoryHandshake();
                }

                mPendingBootAccessoryHandshakeBroadcast = false;
                updateUsbNotification(false);
                updateAdbNotification(false);
                updateUsbFunctions();