Merge "[Media TTT] Displayed View Keeps Screen On" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d1cf8adeda
@@ -65,8 +65,7 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
|
|||||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||||
type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR
|
type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR
|
||||||
flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
|
flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
|
||||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
||||||
format = PixelFormat.TRANSLUCENT
|
format = PixelFormat.TRANSLUCENT
|
||||||
setTrustedOverlay()
|
setTrustedOverlay()
|
||||||
}
|
}
|
||||||
@@ -120,20 +119,27 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
|
|||||||
// At this point, we're guaranteed to no longer be displaying a view.
|
// At this point, we're guaranteed to no longer be displaying a view.
|
||||||
// So, set up all our callbacks and inflate the view.
|
// So, set up all our callbacks and inflate the view.
|
||||||
configurationController.addCallback(displayScaleListener)
|
configurationController.addCallback(displayScaleListener)
|
||||||
// Wake the screen if necessary so the user will see the view. (Per b/239426653, we want
|
|
||||||
// the view to show over the dream state, so we should only wake up if the screen is
|
wakeLock = if (!powerManager.isScreenOn) {
|
||||||
// completely off.)
|
// If the screen is off, fully wake it so the user can see the view.
|
||||||
if (!powerManager.isScreenOn) {
|
wakeLockBuilder
|
||||||
wakeLock = wakeLockBuilder
|
|
||||||
.setTag(newInfo.windowTitle)
|
.setTag(newInfo.windowTitle)
|
||||||
.setLevelsAndFlags(
|
.setLevelsAndFlags(
|
||||||
PowerManager.FULL_WAKE_LOCK or
|
PowerManager.FULL_WAKE_LOCK or
|
||||||
PowerManager.ACQUIRE_CAUSES_WAKEUP
|
PowerManager.ACQUIRE_CAUSES_WAKEUP
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
} else {
|
||||||
|
// Per b/239426653, we want the view to show over the dream state.
|
||||||
|
// If the screen is on, using screen bright level will leave screen on the dream
|
||||||
|
// state but ensure the screen will not go off before wake lock is released.
|
||||||
|
wakeLockBuilder
|
||||||
|
.setTag(newInfo.windowTitle)
|
||||||
|
.setLevelsAndFlags(PowerManager.SCREEN_BRIGHT_WAKE_LOCK)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
wakeLock?.acquire(newInfo.wakeReason)
|
wakeLock?.acquire(newInfo.wakeReason)
|
||||||
wakeReasonAcquired = newInfo.wakeReason
|
wakeReasonAcquired = newInfo.wakeReason
|
||||||
}
|
|
||||||
logger.logViewAddition(newInfo.windowTitle)
|
logger.logViewAddition(newInfo.windowTitle)
|
||||||
inflateAndUpdateView(newInfo)
|
inflateAndUpdateView(newInfo)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,27 +123,37 @@ class TemporaryViewDisplayControllerTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun displayView_screenOff_wakeLockAcquired() {
|
fun displayView_wakeLockAcquired() {
|
||||||
underTest.displayView(getState())
|
underTest.displayView(getState())
|
||||||
|
|
||||||
assertThat(fakeWakeLock.isHeld).isTrue()
|
assertThat(fakeWakeLock.isHeld).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun displayView_screenAlreadyOn_wakeLockNotAcquired() {
|
fun displayView_screenAlreadyOn_wakeLockAcquired() {
|
||||||
whenever(powerManager.isScreenOn).thenReturn(true)
|
whenever(powerManager.isScreenOn).thenReturn(true)
|
||||||
|
|
||||||
underTest.displayView(getState())
|
underTest.displayView(getState())
|
||||||
|
|
||||||
|
assertThat(fakeWakeLock.isHeld).isTrue()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun displayView_wakeLockCanBeReleasedAfterTimeOut() {
|
||||||
|
underTest.displayView(getState())
|
||||||
|
assertThat(fakeWakeLock.isHeld).isTrue()
|
||||||
|
|
||||||
|
fakeClock.advanceTime(TIMEOUT_MS + 1)
|
||||||
|
|
||||||
assertThat(fakeWakeLock.isHeld).isFalse()
|
assertThat(fakeWakeLock.isHeld).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun displayView_screenOff_wakeLockCanBeReleasedAfterTimeOut() {
|
fun displayView_removeView_wakeLockCanBeReleased() {
|
||||||
underTest.displayView(getState())
|
underTest.displayView(getState())
|
||||||
assertThat(fakeWakeLock.isHeld).isTrue()
|
assertThat(fakeWakeLock.isHeld).isTrue()
|
||||||
|
|
||||||
fakeClock.advanceTime(TIMEOUT_MS + 1)
|
underTest.removeView("test reason")
|
||||||
|
|
||||||
assertThat(fakeWakeLock.isHeld).isFalse()
|
assertThat(fakeWakeLock.isHeld).isFalse()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user