diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommon.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommon.kt index 79e1fb9a60f63..a86421158eb2b 100644 --- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommon.kt +++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommon.kt @@ -112,12 +112,16 @@ abstract class MediaTttChipControllerCommon( // The chip is new, so set up all our callbacks and inflate the view configurationController.addCallback(displayScaleListener) tapGestureDetector.addOnGestureDetectedCallback(TAG, this::onScreenTapped) - // Wake the screen so the user will see the chip - powerManager.wakeUp( - SystemClock.uptimeMillis(), - PowerManager.WAKE_REASON_APPLICATION, - "com.android.systemui:media_tap_to_transfer_activated" - ) + // Wake the screen if necessary so the user will see the chip. (Per b/239426653, we want + // the chip to show over the dream state, so we should only wake up if the screen is + // completely off.) + if (!powerManager.isScreenOn) { + powerManager.wakeUp( + SystemClock.uptimeMillis(), + PowerManager.WAKE_REASON_APPLICATION, + "com.android.systemui:media_tap_to_transfer_activated" + ) + } inflateAndUpdateChip(newChipInfo) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommonTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommonTest.kt index 55397868125bb..7337764b9ec25 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommonTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/common/MediaTttChipControllerCommonTest.kt @@ -115,14 +115,31 @@ class MediaTttChipControllerCommonTest : SysuiTestCase() { } @Test - fun displayChip_chipAddedAndGestureDetectionStartedAndScreenOn() { + fun displayChip_chipAddedAndGestureDetectionStarted() { controllerCommon.displayChip(getState()) verify(windowManager).addView(any(), any()) verify(tapGestureDetector).addOnGestureDetectedCallback(any(), any()) + } + + @Test + fun displayChip_screenOff_screenWakes() { + whenever(powerManager.isScreenOn).thenReturn(false) + + controllerCommon.displayChip(getState()) + verify(powerManager).wakeUp(any(), any(), any()) } + @Test + fun displayChip_screenAlreadyOn_screenNotWoken() { + whenever(powerManager.isScreenOn).thenReturn(true) + + controllerCommon.displayChip(getState()) + + verify(powerManager, never()).wakeUp(any(), any(), any()) + } + @Test fun displayChip_twice_chipAndGestureDetectionNotAddedTwice() { controllerCommon.displayChip(getState())