diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index c3c9a61df2ea0..79148fd67ceb3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1326,7 +1326,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } }); - mScreenOffAnimationController.initialize(this, mLightRevealScrim); + mScreenOffAnimationController.initialize(this, mShadeSurface, mLightRevealScrim); updateLightRevealScrimVisibility(); mShadeSurface.initDependencies( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt index c8174669cc653..89c3a02f94019 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone import android.view.View import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.WakefulnessLifecycle +import com.android.systemui.shade.ShadeViewController import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.unfold.FoldAodAnimationController import com.android.systemui.unfold.SysUIUnfoldComponent @@ -37,8 +38,12 @@ class ScreenOffAnimationController @Inject constructor( private val animations: List = listOfNotNull(foldToAodAnimation, unlockedScreenOffAnimation) - fun initialize(centralSurfaces: CentralSurfaces, lightRevealScrim: LightRevealScrim) { - animations.forEach { it.initialize(centralSurfaces, lightRevealScrim) } + fun initialize( + centralSurfaces: CentralSurfaces, + shadeViewController: ShadeViewController, + lightRevealScrim: LightRevealScrim, + ) { + animations.forEach { it.initialize(centralSurfaces, shadeViewController, lightRevealScrim) } wakefulnessLifecycle.addObserver(this) } @@ -197,7 +202,11 @@ class ScreenOffAnimationController @Inject constructor( } interface ScreenOffAnimation { - fun initialize(centralSurfaces: CentralSurfaces, lightRevealScrim: LightRevealScrim) {} + fun initialize( + centralSurfaces: CentralSurfaces, + shadeViewController: ShadeViewController, + lightRevealScrim: LightRevealScrim, + ) {} /** * Called when started going to sleep, should return true if the animation will be played diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index 96a4d900c1602..7e9172da18174 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -20,6 +20,7 @@ import com.android.app.animation.Interpolators import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.KeyguardViewMediator import com.android.systemui.keyguard.WakefulnessLifecycle +import com.android.systemui.shade.ShadeViewController import com.android.systemui.statusbar.CircleReveal import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.NotificationShadeWindowController @@ -66,7 +67,8 @@ class UnlockedScreenOffAnimationController @Inject constructor( private val powerManager: PowerManager, private val handler: Handler = Handler() ) : WakefulnessLifecycle.Observer, ScreenOffAnimation { - private lateinit var mCentralSurfaces: CentralSurfaces + private lateinit var centralSurfaces: CentralSurfaces + private lateinit var shadeViewController: ShadeViewController /** * Whether or not [initialize] has been called to provide us with the StatusBar, * NotificationPanelViewController, and LightRevealSrim so that we can run the unlocked screen @@ -126,7 +128,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( lightRevealAnimator.start() } - val animatorDurationScaleObserver = object : ContentObserver(null) { + private val animatorDurationScaleObserver = object : ContentObserver(null) { override fun onChange(selfChange: Boolean) { updateAnimatorDurationScale() } @@ -134,11 +136,13 @@ class UnlockedScreenOffAnimationController @Inject constructor( override fun initialize( centralSurfaces: CentralSurfaces, + shadeViewController: ShadeViewController, lightRevealScrim: LightRevealScrim ) { this.initialized = true this.lightRevealScrim = lightRevealScrim - this.mCentralSurfaces = centralSurfaces + this.centralSurfaces = centralSurfaces + this.shadeViewController = shadeViewController updateAnimatorDurationScale() globalSettings.registerContentObserver( @@ -198,7 +202,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( // Tell the CentralSurfaces to become keyguard for real - we waited on that // since it is slow and would have caused the animation to jank. - mCentralSurfaces.updateIsKeyguard() + centralSurfaces.updateIsKeyguard() // Run the callback given to us by the KeyguardVisibilityHelper. after.run() @@ -251,7 +255,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( // even if we're going from SHADE to SHADE or KEYGUARD to KEYGUARD, since we might have // changed parts of the UI (such as showing AOD in the shade) without actually changing // the StatusBarState. This ensures that the UI definitely reflects the desired state. - mCentralSurfaces.updateIsKeyguard(true /* forceStateChange */) + centralSurfaces.updateIsKeyguard(true /* forceStateChange */) } } @@ -280,7 +284,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( // Show AOD. That'll cause the KeyguardVisibilityHelper to call // #animateInKeyguard. - mCentralSurfaces.shadeViewController.showAodUi() + shadeViewController.showAodUi() } }, (ANIMATE_IN_KEYGUARD_DELAY * animatorDurationScale).toLong()) @@ -328,8 +332,8 @@ class UnlockedScreenOffAnimationController @Inject constructor( // We currently draw both the light reveal scrim, and the AOD UI, in the shade. If it's // already expanded and showing notifications/QS, the animation looks really messy. For now, // disable it if the notification panel is expanded. - if ((!this::mCentralSurfaces.isInitialized || - mCentralSurfaces.shadeViewController.isPanelExpanded) && + if ((!this::centralSurfaces.isInitialized || + shadeViewController.isPanelExpanded) && // Status bar might be expanded because we have started // playing the animation already !isAnimationPlaying() diff --git a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt index cbe402017c415..098d51e94fc72 100644 --- a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt @@ -31,6 +31,7 @@ import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.shade.ShadeFoldAnimator +import com.android.systemui.shade.ShadeViewController import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.ScreenOffAnimation @@ -62,7 +63,7 @@ constructor( private val keyguardInteractor: Lazy, ) : CallbackController, ScreenOffAnimation, WakefulnessLifecycle.Observer { - private lateinit var centralSurfaces: CentralSurfaces + private lateinit var shadeViewController: ShadeViewController private var isFolded = false private var isFoldHandled = true @@ -87,8 +88,12 @@ constructor( ) } - override fun initialize(centralSurfaces: CentralSurfaces, lightRevealScrim: LightRevealScrim) { - this.centralSurfaces = centralSurfaces + override fun initialize( + centralSurfaces: CentralSurfaces, + shadeViewController: ShadeViewController, + lightRevealScrim: LightRevealScrim, + ) { + this.shadeViewController = shadeViewController deviceStateManager.registerCallback(mainExecutor, FoldListener()) wakefulnessLifecycle.addObserver(this) @@ -128,7 +133,7 @@ constructor( } private fun getShadeFoldAnimator(): ShadeFoldAnimator = - centralSurfaces.shadeViewController.shadeFoldAnimator + shadeViewController.shadeFoldAnimator private fun setAnimationState(playing: Boolean) { shouldPlayAnimation = playing diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt index 2e9a6909e402b..e76f26d8128e7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt @@ -97,9 +97,7 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() { powerManager, handler = handler ) - controller.initialize(centralSurfaces, lightRevealScrim) - `when`(centralSurfaces.shadeViewController).thenReturn( - shadeViewController) + controller.initialize(centralSurfaces, shadeViewController, lightRevealScrim) // Screen off does not run if the panel is expanded, so we should say it's collapsed to test // screen off. diff --git a/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt index 813597a8b5769..7f990a446aafb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt @@ -101,7 +101,6 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { whenever(viewGroup.viewTreeObserver).thenReturn(viewTreeObserver) whenever(wakefulnessLifecycle.lastSleepReason) .thenReturn(PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD) - whenever(centralSurfaces.shadeViewController).thenReturn(shadeViewController) whenever(shadeFoldAnimator.startFoldToAodAnimation(any(), any(), any())).then { val onActionStarted = it.arguments[0] as Runnable onActionStarted.run() @@ -124,7 +123,7 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { latencyTracker, { keyguardInteractor }, ) - .apply { initialize(centralSurfaces, lightRevealScrim) } + .apply { initialize(centralSurfaces, shadeViewController, lightRevealScrim) } verify(deviceStateManager).registerCallback(any(), foldStateListenerCaptor.capture())