Fix handling usb notification after pr_swap complete
After the device (USB host) finished the pr_swap and the power role is changed from Source to Sink, the notification should be updated with different messages. However, the notification may be ignored since the charger type is not USB. Users may get confused when the notification is gone. If the peripheral device is still connected, UsbDeviceManager should push new notification. Bug: 212189038 Test: notification is updated Change-Id: I772c8c06a1e3a8770d0bf132c5e8fdf313bb2685
This commit is contained in:
parent
a83857b9e2
commit
2424262814
@ -492,6 +492,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
||||
|
||||
// current USB state
|
||||
private boolean mHostConnected;
|
||||
private boolean mUsbAccessoryConnected;
|
||||
private boolean mSourcePower;
|
||||
private boolean mSinkPower;
|
||||
private boolean mConfigured;
|
||||
@ -961,10 +962,10 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
||||
break;
|
||||
case MSG_UPDATE_HOST_STATE:
|
||||
Iterator devices = (Iterator) msg.obj;
|
||||
boolean connected = (msg.arg1 == 1);
|
||||
mUsbAccessoryConnected = (msg.arg1 == 1);
|
||||
|
||||
if (DEBUG) {
|
||||
Slog.i(TAG, "HOST_STATE connected:" + connected);
|
||||
Slog.i(TAG, "HOST_STATE connected:" + mUsbAccessoryConnected);
|
||||
}
|
||||
|
||||
mHideUsbNotification = false;
|
||||
@ -1218,7 +1219,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
||||
} else if (mSourcePower) {
|
||||
titleRes = com.android.internal.R.string.usb_supplying_notification_title;
|
||||
id = SystemMessage.NOTE_USB_SUPPLYING;
|
||||
} else if (mHostConnected && mSinkPower && mUsbCharging) {
|
||||
} else if (mHostConnected && mSinkPower && (mUsbCharging || mUsbAccessoryConnected)) {
|
||||
titleRes = com.android.internal.R.string.usb_charging_notification_title;
|
||||
id = SystemMessage.NOTE_USB_CHARGING;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user