diff options
author | 2022-08-17 05:58:32 +0000 | |
---|---|---|
committer | 2022-08-17 05:58:32 +0000 | |
commit | e648d3cb91f9a0156c729ca18ec27e71f59f9ce2 (patch) | |
tree | 96b900f55660523012fe1ccc5ddb13f7d66ed143 | |
parent | c4cfeaf45f2cea6fcf97d029345e80c1f90124cf (diff) | |
parent | 7b9a26138feda94191d5d49b0af2abbdd7d2e009 (diff) |
Merge "usb: Don't show the notification when no USB device is connected"
-rw-r--r-- | services/usb/java/com/android/server/usb/UsbDeviceManager.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java index 6ea416b54811..d5809957ba29 100644 --- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java +++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java @@ -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); |