summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michael Mikhail <michaelmikhil@google.com> 2023-03-13 17:55:09 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-03-13 17:55:09 +0000
commit1a3da87826497ac3a31df12c8e855578da5a4a6a (patch)
tree51583a189652369f4f8ac3ae50e0b03d7a10d22e
parent0eda9e925afbc1876039c2e8fe0e8fff6ea192a5 (diff)
parent60eb33e4f04ca0331afb04872b4d4ed634c97f6b (diff)
Merge "Check for block location change when configuration changes" into tm-qpr-dev am: 4f4d7d3a08 am: 60eb33e4f0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21961697 Change-Id: Ia0b0ff24d2c5c9d904b6072d7a629156a2ca2940 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt51
2 files changed, 54 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
index 7fc7bdb872c9..e10d74db6333 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt
@@ -639,7 +639,9 @@ constructor(
) =
traceSection("MediaHierarchyManager#updateDesiredLocation") {
val desiredLocation = calculateLocation()
- if (desiredLocation != this.desiredLocation || forceStateUpdate) {
+ if (
+ desiredLocation != this.desiredLocation || forceStateUpdate && !blockLocationChanges
+ ) {
if (this.desiredLocation >= 0 && desiredLocation != this.desiredLocation) {
// Only update previous location when it actually changes
previousLocation = this.desiredLocation
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
index a5795184b493..feb429d2f0d4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt
@@ -180,6 +180,57 @@ class MediaHierarchyManagerTest : SysuiTestCase() {
}
@Test
+ fun testBlockedWhenConfigurationChangesAndScreenOff() {
+ // Let's set it onto QS:
+ mediaHierarchyManager.qsExpansion = 1.0f
+ verify(mediaCarouselController)
+ .onDesiredLocationChanged(
+ ArgumentMatchers.anyInt(),
+ any(MediaHostState::class.java),
+ anyBoolean(),
+ anyLong(),
+ anyLong()
+ )
+ val observer = wakefullnessObserver.value
+ assertNotNull("lifecycle observer wasn't registered", observer)
+ observer.onStartedGoingToSleep()
+ clearInvocations(mediaCarouselController)
+ configurationController.notifyConfigurationChanged()
+ verify(mediaCarouselController, times(0))
+ .onDesiredLocationChanged(
+ ArgumentMatchers.anyInt(),
+ any(MediaHostState::class.java),
+ anyBoolean(),
+ anyLong(),
+ anyLong()
+ )
+ }
+
+ @Test
+ fun testAllowedWhenConfigurationChanges() {
+ // Let's set it onto QS:
+ mediaHierarchyManager.qsExpansion = 1.0f
+ verify(mediaCarouselController)
+ .onDesiredLocationChanged(
+ ArgumentMatchers.anyInt(),
+ any(MediaHostState::class.java),
+ anyBoolean(),
+ anyLong(),
+ anyLong()
+ )
+ clearInvocations(mediaCarouselController)
+ configurationController.notifyConfigurationChanged()
+ verify(mediaCarouselController)
+ .onDesiredLocationChanged(
+ ArgumentMatchers.anyInt(),
+ any(MediaHostState::class.java),
+ anyBoolean(),
+ anyLong(),
+ anyLong()
+ )
+ }
+
+ @Test
fun testAllowedWhenNotTurningOff() {
// Let's set it onto QS:
mediaHierarchyManager.qsExpansion = 1.0f