From 5511a4d8ce1967f29220b66e5707e2c8b18e6f60 Mon Sep 17 00:00:00 2001 From: Beth Thibodeau Date: Wed, 30 Jun 2021 20:06:26 -0400 Subject: [PATCH] Fix transition after restarting inactive media The previousLocation was updated when it shouldn't have been, which resulted in the animation always thinking it was going from QS to QS in the first transition after restarting media. To fix this: 1. Only update the previous location when it has changed (how it worked before the forceStateUpdate parameter was added) 2. When forceStateUpdate is true, check where the next animation ought to be and update if necessary Test: swipe away small player, restart from QS, swipe back to QQS Fixes: 192384088 Change-Id: Ib44e9bd9087549d60f09f90c09ad1f2e0da82069 --- .../android/systemui/media/MediaHierarchyManager.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt index 186f961ff1b67..fb601e3107028 100644 --- a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt @@ -537,8 +537,19 @@ class MediaHierarchyManager @Inject constructor( ) { val desiredLocation = calculateLocation() if (desiredLocation != this.desiredLocation || forceStateUpdate) { - if (this.desiredLocation >= 0) { + if (this.desiredLocation >= 0 && desiredLocation != this.desiredLocation) { + // Only update previous location when it actually changes previousLocation = this.desiredLocation + } else if (forceStateUpdate) { + val onLockscreen = (!bypassController.bypassEnabled && + (statusbarState == StatusBarState.KEYGUARD || + statusbarState == StatusBarState.FULLSCREEN_USER_SWITCHER)) + if (desiredLocation == LOCATION_QS && previousLocation == LOCATION_LOCKSCREEN && + !onLockscreen) { + // If media active state changed and the device is now unlocked, update the + // previous location so we animate between the correct hosts + previousLocation = LOCATION_QQS + } } val isNewView = this.desiredLocation == -1 this.desiredLocation = desiredLocation