Check and send usb state broadcast when devices boots

Broadcasts are not sent until BOOT_COMPLETED is received.
When the device boots with usb plugged, the UPDATE_STATE
for connted and configured would be received way before
BOOT_COMPLETED is received. Since, devices can continue
to stay in same usb configuration(set through persistent
property trigger), check and send a usb state broadcast
if needed.

BUG: 34451258
Test: Manually checked to verify the broadcasts sent.
Change-Id: I8eca5f241ad758f5c4f1afa6c9807868dfd6195a
This commit is contained in:
Badhri Jagan Sridharan
2017-01-23 16:28:38 -08:00
committed by Badhri Jagan Sridharan
parent c1bc0a844d
commit af6d473ab0

View File

@@ -150,6 +150,7 @@ public class UsbDeviceManager {
private UsbDebuggingManager mDebuggingManager;
private final UsbAlsaManager mUsbAlsaManager;
private Intent mBroadcastedIntent;
private boolean mPendingBootBroadcast;
private class AdbSettingsObserver extends ContentObserver {
public AdbSettingsObserver() {
@@ -748,6 +749,8 @@ public class UsbDeviceManager {
}
updateUsbStateBroadcastIfNeeded(false);
updateUsbFunctions();
} else {
mPendingBootBroadcast = true;
}
break;
case MSG_UPDATE_HOST_STATE:
@@ -759,6 +762,8 @@ public class UsbDeviceManager {
updateUsbNotification();
if (mBootCompleted) {
updateUsbStateBroadcastIfNeeded(false);
} else {
mPendingBootBroadcast = true;
}
break;
case MSG_ENABLE_ADB:
@@ -778,6 +783,10 @@ public class UsbDeviceManager {
break;
case MSG_BOOT_COMPLETED:
mBootCompleted = true;
if (mPendingBootBroadcast) {
updateUsbStateBroadcastIfNeeded(false);
mPendingBootBroadcast = false;
}
setEnabledFunctions(null, false, false);
if (mCurrentAccessory != null) {
getCurrentSettings().accessoryAttached(mCurrentAccessory);