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

Commit eb55c4e5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "usb: Don't show the notification when no USB device is connected" am:...

Merge "usb: Don't show the notification when no USB device is connected" am: e648d3cb am: 40f45bdd am: 3161749b am: 12699672

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2181961



Change-Id: I01fafac7e27f4f87c0734b49dcfb6ba78f9e12c0
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents f278de2b 12699672
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -508,6 +508,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
        // current USB state
        private boolean mHostConnected;
        private boolean mUsbAccessoryConnected;
        private boolean mInHostModeWithNoAccessoryConnected;
        private boolean mSourcePower;
        private boolean mSinkPower;
        private boolean mConfigured;
@@ -959,6 +960,17 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                        mSupportsAllCombinations = false;
                    }

                    if (mHostConnected) {
                        if (!mUsbAccessoryConnected) {
                            mInHostModeWithNoAccessoryConnected = true;
                        } else {
                            mInHostModeWithNoAccessoryConnected = false;
                        }
                    } else {
                        // if not in host mode, reset value to false
                        mInHostModeWithNoAccessoryConnected = false;
                    }

                    mAudioAccessorySupported = port.isModeSupported(MODE_AUDIO_ACCESSORY);

                    args.recycle();
@@ -983,6 +995,12 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
                        Slog.i(TAG, "HOST_STATE connected:" + mUsbAccessoryConnected);
                    }

                    if (!devices.hasNext()) {
                        mInHostModeWithNoAccessoryConnected = true;
                    } else {
                        mInHostModeWithNoAccessoryConnected = false;
                    }

                    mHideUsbNotification = false;
                    while (devices.hasNext()) {
                        Map.Entry pair = (Map.Entry) devices.next();
@@ -1192,7 +1210,8 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser

            // Dont show the notification when connected to a USB peripheral
            // and the link does not support PR_SWAP and DR_SWAP
            if (mHideUsbNotification && !mSupportsAllCombinations) {
            if ((mHideUsbNotification || mInHostModeWithNoAccessoryConnected)
                    && !mSupportsAllCombinations) {
                if (mUsbNotificationId != 0) {
                    mNotificationManager.cancelAsUser(null, mUsbNotificationId,
                            UserHandle.ALL);