Remove getShadeViewController calls

Bug: 288868098
Test: updated and ran affected test
Change-Id: Ief8dc9782d07cfc52832dc24b3e3b5249d68a79a
This commit is contained in:
Justin Weir
2023-07-18 17:01:49 -04:00
parent 06db41a823
commit 5d0589110a
6 changed files with 36 additions and 21 deletions

View File

@@ -1326,7 +1326,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
}
});
mScreenOffAnimationController.initialize(this, mLightRevealScrim);
mScreenOffAnimationController.initialize(this, mShadeSurface, mLightRevealScrim);
updateLightRevealScrimVisibility();
mShadeSurface.initDependencies(

View File

@@ -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<ScreenOffAnimation> =
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

View File

@@ -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()

View File

@@ -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<KeyguardInteractor>,
) : CallbackController<FoldAodAnimationStatus>, 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

View File

@@ -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.

View File

@@ -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())