Merge "usb: Add the boot completed check before broadcasting intent" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-04-22 06:27:40 +00:00
committed by Android (Google) Code Review

View File

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