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

Commit eb4b2880 authored by Khoa Hong's avatar Khoa Hong Committed by Android (Google) Code Review
Browse files

Merge "Show charging notification when device is being charged via USB, with USB data disabled."

parents b201fff6 a13e3779
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -514,6 +514,8 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
        private boolean mConfigured;
        private boolean mAudioAccessoryConnected;
        private boolean mAudioAccessorySupported;
        private boolean mConnectedToDataDisabledPort;
        private int mPowerBrickConnectionStatus;

        private UsbAccessory mCurrentAccessory;
        private int mUsbNotificationId;
@@ -952,12 +954,19 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                                && status.isRoleCombinationSupported(POWER_ROLE_SOURCE,
                                DATA_ROLE_DEVICE)
                                && status.isRoleCombinationSupported(POWER_ROLE_SINK, DATA_ROLE_DEVICE);

                        boolean usbDataDisabled =
                                status.getUsbDataStatus() != UsbPortStatus.DATA_STATUS_ENABLED;
                        mConnectedToDataDisabledPort = status.isConnected() && usbDataDisabled;
                        mPowerBrickConnectionStatus = status.getPowerBrickConnectionStatus();
                    } else {
                        mHostConnected = false;
                        mSourcePower = false;
                        mSinkPower = false;
                        mAudioAccessoryConnected = false;
                        mSupportsAllCombinations = false;
                        mConnectedToDataDisabledPort = false;
                        mPowerBrickConnectionStatus = UsbPortStatus.POWER_BRICK_STATUS_UNKNOWN;
                    }

                    if (mHostConnected) {
@@ -1265,6 +1274,12 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
            } else if (mHostConnected && mSinkPower && (mUsbCharging || mUsbAccessoryConnected)) {
                titleRes = com.android.internal.R.string.usb_charging_notification_title;
                id = SystemMessage.NOTE_USB_CHARGING;
            } else if (mSinkPower && mConnectedToDataDisabledPort
                    && mPowerBrickConnectionStatus != UsbPortStatus.POWER_BRICK_STATUS_CONNECTED) {
                // Show charging notification when USB Data is disabled on the port, and not
                // connected to a wall charger.
                titleRes = com.android.internal.R.string.usb_charging_notification_title;
                id = SystemMessage.NOTE_USB_CHARGING;
            }
            if (id != mUsbNotificationId || force) {
                // clear notification if title needs changing