From c2bcdf389028504175b1325596026135549fe9a4 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Fri, 24 Mar 2023 12:33:56 +0000 Subject: [PATCH] Fixing Y translation of media when no media is visible in previousLocation Fixes: 271247142 Test: have media playing -> go to lockscreen in split shade -> remove media player -> swipe down to shade and see clock not jumping Change-Id: I7e7e682a5c70adc9e3a6d08ccbc0b8f78d43a775 --- .../systemui/media/controls/ui/MediaHierarchyManager.kt | 7 +++++-- .../media/controls/ui/MediaHierarchyManagerTest.kt | 9 +++++++++ 2 files changed, 14 insertions(+), 2 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 e10d74db63339..54237ce7cf251 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 @@ -317,13 +317,16 @@ constructor( /** * Returns the amount of translationY of the media container, during the current guided - * transformation, if running. If there is no guided transformation running, it will return 0. + * transformation, if running. If there is no guided transformation running, it will return -1. */ fun getGuidedTransformationTranslationY(): Int { if (!isCurrentlyInGuidedTransformation()) { return -1 } - val startHost = getHost(previousLocation) ?: return 0 + val startHost = getHost(previousLocation) + if (startHost == null || !startHost.visible) { + return 0 + } return targetBounds.top - startHost.currentBounds.top } 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 feb429d2f0d4e..eb78ded008b27 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 @@ -388,6 +388,15 @@ class MediaHierarchyManagerTest : SysuiTestCase() { .isEqualTo(expectedTranslation) } + @Test + fun getGuidedTransformationTranslationY_previousHostInvisible_returnsZero() { + goToLockscreen() + enterGuidedTransformation() + whenever(lockHost.visible).thenReturn(false) + + assertThat(mediaHierarchyManager.getGuidedTransformationTranslationY()).isEqualTo(0) + } + @Test fun isCurrentlyInGuidedTransformation_hostsVisible_returnsTrue() { goToLockscreen()