[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
This commit is contained in:
@@ -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
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user