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

Commit 24242628 authored by Ray Chi's avatar Ray Chi
Browse files

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
parent a83857b9
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -492,6 +492,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser


        // current USB state
        // current USB state
        private boolean mHostConnected;
        private boolean mHostConnected;
        private boolean mUsbAccessoryConnected;
        private boolean mSourcePower;
        private boolean mSourcePower;
        private boolean mSinkPower;
        private boolean mSinkPower;
        private boolean mConfigured;
        private boolean mConfigured;
@@ -961,10 +962,10 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                    break;
                    break;
                case MSG_UPDATE_HOST_STATE:
                case MSG_UPDATE_HOST_STATE:
                    Iterator devices = (Iterator) msg.obj;
                    Iterator devices = (Iterator) msg.obj;
                    boolean connected = (msg.arg1 == 1);
                    mUsbAccessoryConnected = (msg.arg1 == 1);


                    if (DEBUG) {
                    if (DEBUG) {
                        Slog.i(TAG, "HOST_STATE connected:" + connected);
                        Slog.i(TAG, "HOST_STATE connected:" + mUsbAccessoryConnected);
                    }
                    }


                    mHideUsbNotification = false;
                    mHideUsbNotification = false;
@@ -1218,7 +1219,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
            } else if (mSourcePower) {
            } else if (mSourcePower) {
                titleRes = com.android.internal.R.string.usb_supplying_notification_title;
                titleRes = com.android.internal.R.string.usb_supplying_notification_title;
                id = SystemMessage.NOTE_USB_SUPPLYING;
                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;
                titleRes = com.android.internal.R.string.usb_charging_notification_title;
                id = SystemMessage.NOTE_USB_CHARGING;
                id = SystemMessage.NOTE_USB_CHARGING;
            }
            }