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

Commit 588d1031 authored by Caitlin Cassidy's avatar Caitlin Cassidy
Browse files

[Media TTT] Don't wake the screen if the screen is already in dream

state.

Fixes: 239426653
Test: manual: verified chip displays on top of dream instead of fully
waking the device
Test: MediaTttChipControllerCommonTest

Change-Id: Ieef1681cfcd2cf46ed5b6faaa1f692c768ae4427
parent 655f9880
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -112,12 +112,16 @@ abstract class MediaTttChipControllerCommon<T : ChipInfoCommon>(
            // 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
            // 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)
        }
+18 −1
Original line number Diff line number Diff line
@@ -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())