diff options
33 files changed, 459 insertions, 269 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerBaseTest.java index 324534fb766c..7986051de3e0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerBaseTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsKeyguardViewLegacyControllerBaseTest.java @@ -105,7 +105,7 @@ public class UdfpsKeyguardViewLegacyControllerBaseTest extends SysuiTestCase { when(mKeyguardViewMediator.isAnimatingScreenOff()).thenReturn(false); when(mView.getUnpausedAlpha()).thenReturn(255); when(mShadeExpansionStateManager.addExpansionListener(any())).thenReturn( - new ShadeExpansionChangeEvent(0, false, false, 0)); + new ShadeExpansionChangeEvent(0, false, false)); mController = createUdfpsKeyguardViewController(); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java index 5827671e22b8..6a86801cba90 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java @@ -376,7 +376,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { // Ensure correct expansion passed in. ShadeExpansionChangeEvent event = new ShadeExpansionChangeEvent( - expansion, /* expanded= */ false, /* tracking= */ true, dragDownAmount); + expansion, /* expanded= */ false, /* tracking= */ true); verify(mScrimController).expand(event); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimControllerTest.java index 97052a84a60f..7cdd4781631f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimControllerTest.java @@ -59,7 +59,7 @@ public class BouncerlessScrimControllerTest extends SysuiTestCase { final BouncerlessScrimController scrimController = new BouncerlessScrimController(mExecutor, mPowerManager); scrimController.addCallback(mCallback); - scrimController.expand(new ShadeExpansionChangeEvent(.5f, true, false, 0.0f)); + scrimController.expand(new ShadeExpansionChangeEvent(.5f, true, false)); mExecutor.runAllReady(); verify(mPowerManager).wakeUp(anyLong(), eq(PowerManager.WAKE_REASON_GESTURE), any()); verify(mCallback).onWakeup(); @@ -71,7 +71,7 @@ public class BouncerlessScrimControllerTest extends SysuiTestCase { new BouncerlessScrimController(mExecutor, mPowerManager); scrimController.addCallback(mCallback); final ShadeExpansionChangeEvent expansionEvent = - new ShadeExpansionChangeEvent(0.5f, false, false, 0.0f); + new ShadeExpansionChangeEvent(0.5f, false, false); scrimController.expand(expansionEvent); mExecutor.runAllReady(); verify(mCallback).onExpansion(eq(expansionEvent)); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImplTest.kt index 16b68ccf097b..ad40f8eab4f6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImplTest.kt @@ -52,6 +52,7 @@ class PanelExpansionInteractorImplTest : SysuiTestCase() { private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository private val deviceUnlockedInteractor = kosmos.deviceUnlockedInteractor private val sceneInteractor = kosmos.sceneInteractor + private val shadeAnimationInteractor = kosmos.shadeAnimationInteractor private val transitionState = MutableStateFlow<ObservableTransitionState>( ObservableTransitionState.Idle(Scenes.Lockscreen) @@ -112,6 +113,40 @@ class PanelExpansionInteractorImplTest : SysuiTestCase() { changeScene(Scenes.Communal) { assertThat(panelExpansion).isEqualTo(1f) } assertThat(panelExpansion).isEqualTo(1f) } + + @Test + @EnableSceneContainer + fun shouldHideStatusBarIconsWhenExpanded_goneScene() = + testScope.runTest { + underTest = kosmos.panelExpansionInteractorImpl + shadeAnimationInteractor.setIsLaunchingActivity(false) + changeScene(Scenes.Gone) + + assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isFalse() + } + + @Test + @EnableSceneContainer + fun shouldHideStatusBarIconsWhenExpanded_lockscreenScene() = + testScope.runTest { + underTest = kosmos.panelExpansionInteractorImpl + shadeAnimationInteractor.setIsLaunchingActivity(false) + changeScene(Scenes.Lockscreen) + + assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isTrue() + } + + @Test + @EnableSceneContainer + fun shouldHideStatusBarIconsWhenExpanded_activityLaunch() = + testScope.runTest { + underTest = kosmos.panelExpansionInteractorImpl + changeScene(Scenes.Gone) + shadeAnimationInteractor.setIsLaunchingActivity(true) + + assertThat(underTest.shouldHideStatusBarIconsWhenExpanded()).isFalse() + } + private fun TestScope.setUnlocked(isUnlocked: Boolean) { val isDeviceUnlocked by collectLastValue(deviceUnlockedInteractor.isDeviceUnlocked) deviceEntryRepository.setUnlocked(isUnlocked) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt index 31dacdd61151..52caa787bb2f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt @@ -18,15 +18,32 @@ package com.android.systemui.shade.domain.startable import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest +import com.android.compose.animation.scene.ObservableTransitionState +import com.android.compose.animation.scene.SceneKey import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue +import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository +import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor +import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.testScope import com.android.systemui.res.R +import com.android.systemui.scene.domain.interactor.sceneInteractor +import com.android.systemui.scene.shared.model.Scenes +import com.android.systemui.scene.shared.model.fakeSceneDataSource +import com.android.systemui.shade.ShadeExpansionChangeEvent +import com.android.systemui.shade.ShadeExpansionListener import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.testKosmos +import com.android.systemui.util.mockito.any +import com.android.systemui.util.mockito.mock +import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith @@ -34,11 +51,15 @@ import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class ShadeStartableTest : SysuiTestCase() { - private val kosmos = testKosmos() private val testScope = kosmos.testScope private val shadeInteractor = kosmos.shadeInteractor + private val sceneInteractor = kosmos.sceneInteractor + private val shadeExpansionStateManager = kosmos.shadeExpansionStateManager + private val deviceEntryRepository = kosmos.fakeDeviceEntryRepository + private val deviceUnlockedInteractor = kosmos.deviceUnlockedInteractor private val fakeConfigurationRepository = kosmos.fakeConfigurationRepository + private val fakeSceneDataSource = kosmos.fakeSceneDataSource private val underTest = kosmos.shadeStartable @@ -59,4 +80,89 @@ class ShadeStartableTest : SysuiTestCase() { fakeConfigurationRepository.onAnyConfigurationChange() assertThat(shadeMode).isEqualTo(ShadeMode.Single) } + + @Test + @EnableSceneContainer + fun hydrateShadeExpansionStateManager() = + testScope.runTest { + val expansionListener = mock<ShadeExpansionListener>() + var latestChangeEvent: ShadeExpansionChangeEvent? = null + whenever(expansionListener.onPanelExpansionChanged(any())).thenAnswer { + latestChangeEvent = it.arguments[0] as ShadeExpansionChangeEvent + Unit + } + shadeExpansionStateManager.addExpansionListener(expansionListener) + + underTest.start() + + setUnlocked(true) + val transitionState = + MutableStateFlow<ObservableTransitionState>( + ObservableTransitionState.Idle(Scenes.Gone) + ) + sceneInteractor.setTransitionState(transitionState) + + changeScene(Scenes.Gone, transitionState) + val currentScene by collectLastValue(sceneInteractor.currentScene) + assertThat(currentScene).isEqualTo(Scenes.Gone) + + assertThat(latestChangeEvent) + .isEqualTo( + ShadeExpansionChangeEvent( + fraction = 0f, + expanded = false, + tracking = false, + ) + ) + + changeScene(Scenes.Shade, transitionState) { progress -> + assertThat(latestChangeEvent?.fraction).isEqualTo(progress) + } + } + + private fun TestScope.setUnlocked(isUnlocked: Boolean) { + val isDeviceUnlocked by collectLastValue(deviceUnlockedInteractor.isDeviceUnlocked) + deviceEntryRepository.setUnlocked(isUnlocked) + runCurrent() + + assertThat(isDeviceUnlocked).isEqualTo(isUnlocked) + } + + private fun TestScope.changeScene( + toScene: SceneKey, + transitionState: MutableStateFlow<ObservableTransitionState>, + assertDuringProgress: ((progress: Float) -> Unit) = {}, + ) { + val currentScene by collectLastValue(sceneInteractor.currentScene) + val progressFlow = MutableStateFlow(0f) + transitionState.value = + ObservableTransitionState.Transition( + fromScene = checkNotNull(currentScene), + toScene = toScene, + progress = progressFlow, + isInitiatedByUserInput = true, + isUserInputOngoing = flowOf(true), + ) + runCurrent() + assertDuringProgress(progressFlow.value) + + progressFlow.value = 0.2f + runCurrent() + assertDuringProgress(progressFlow.value) + + progressFlow.value = 0.6f + runCurrent() + assertDuringProgress(progressFlow.value) + + progressFlow.value = 1f + runCurrent() + assertDuringProgress(progressFlow.value) + + transitionState.value = ObservableTransitionState.Idle(toScene) + fakeSceneDataSource.changeScene(toScene) + runCurrent() + assertDuringProgress(progressFlow.value) + + assertThat(currentScene).isEqualTo(toScene) + } } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java index 7f3b5eba96c6..926f7f1aee48 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java @@ -172,19 +172,18 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY()) / mTouchSession.getBounds().height(); setPanelExpansion(mBouncerInitiallyShowing - ? screenTravelPercentage : 1 - screenTravelPercentage, dragDownAmount); + ? screenTravelPercentage : 1 - screenTravelPercentage); return true; } }; - private void setPanelExpansion(float expansion, float dragDownAmount) { + private void setPanelExpansion(float expansion) { mCurrentExpansion = expansion; ShadeExpansionChangeEvent event = new ShadeExpansionChangeEvent( /* fraction= */ mCurrentExpansion, /* expanded= */ mExpanded, - /* tracking= */ true, - /* dragDownPxAmount= */ dragDownAmount); + /* tracking= */ true); mCurrentScrimController.expand(event); } @@ -333,7 +332,7 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { animation -> { float expansionFraction = (float) animation.getAnimatedValue(); float dragDownAmount = expansionFraction * expansionHeight; - setPanelExpansion(expansionFraction, dragDownAmount); + setPanelExpansion(expansionFraction); }); if (!mBouncerInitiallyShowing && targetExpansion == KeyguardBouncerConstants.EXPANSION_VISIBLE) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java index c501d88b77ce..6bf5535b0761 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelView.java @@ -27,6 +27,8 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.FrameLayout; +import com.android.systemui.scene.shared.flag.SceneContainerFlag; + /** The shade view. */ public final class NotificationPanelView extends FrameLayout { static final boolean DEBUG = false; @@ -41,14 +43,20 @@ public final class NotificationPanelView extends FrameLayout { public NotificationPanelView(Context context, AttributeSet attrs) { super(context, attrs); - setWillNotDraw(!DEBUG); - mAlphaPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); + if (!SceneContainerFlag.isEnabled()) { + setWillNotDraw(!DEBUG); + mAlphaPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); - setBackgroundColor(Color.TRANSPARENT); + setBackgroundColor(Color.TRANSPARENT); + } } @Override public void onRtlPropertiesChanged(int layoutDirection) { + if (SceneContainerFlag.isEnabled()) { + super.onRtlPropertiesChanged(layoutDirection); + return; + } if (mRtlChangeListener != null) { mRtlChangeListener.onRtlPropertielsChanged(layoutDirection); } @@ -56,14 +64,19 @@ public final class NotificationPanelView extends FrameLayout { @Override public boolean shouldDelayChildPressedState() { + if (SceneContainerFlag.isEnabled()) { + return super.shouldDelayChildPressedState(); + } return true; } @Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); - if (mCurrentPanelAlpha != 255) { - canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mAlphaPaint); + if (!SceneContainerFlag.isEnabled()) { + if (mCurrentPanelAlpha != 255) { + canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mAlphaPaint); + } } } @@ -83,6 +96,9 @@ public final class NotificationPanelView extends FrameLayout { @Override public boolean hasOverlappingRendering() { + if (SceneContainerFlag.isEnabled()) { + return super.hasOverlappingRendering(); + } return !mDozing; } @@ -102,6 +118,9 @@ public final class NotificationPanelView extends FrameLayout { @Override public boolean onInterceptTouchEvent(MotionEvent event) { + if (SceneContainerFlag.isEnabled()) { + return super.onInterceptTouchEvent(event); + } return mTouchHandler.onInterceptTouchEvent(event); } @@ -113,7 +132,9 @@ public final class NotificationPanelView extends FrameLayout { @Override public void dispatchConfigurationChanged(Configuration newConfig) { super.dispatchConfigurationChanged(newConfig); - mOnConfigurationChangedListener.onConfigurationChanged(newConfig); + if (!SceneContainerFlag.isEnabled()) { + mOnConfigurationChangedListener.onConfigurationChanged(newConfig); + } } /** Callback for right-to-left setting changes. */ diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index e4f5aeb5028c..0ddea307b33a 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -982,6 +982,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump }); mAlternateBouncerInteractor = alternateBouncerInteractor; dumpManager.registerDumpable(this); + SceneContainerFlag.assertInLegacyMode(); } private void unlockAnimationFinished() { @@ -3555,9 +3556,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } @Override - public ViewPropertyAnimator fadeOut(long startDelayMs, long durationMs, Runnable endAction) { + public void fadeOut(long startDelayMs, long durationMs, Runnable endAction) { mView.animate().cancel(); - return mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration( + mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration( durationMs).setInterpolator(Interpolators.ALPHA_OUT).withLayer().withEndAction( endAction); } @@ -4121,9 +4122,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @Override public void updateExpansionAndVisibility() { - mShadeExpansionStateManager.onPanelExpansionChanged( - mExpandedFraction, isExpanded(), isTracking(), mExpansionDragDownAmountPx); - + if (!SceneContainerFlag.isEnabled()) { + mShadeExpansionStateManager.onPanelExpansionChanged( + mExpandedFraction, isExpanded(), isTracking()); + } updateVisibility(); } @@ -4159,7 +4161,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } /** Sends an external (e.g. Status Bar) intercept touch event to the Shade touch handler. */ - boolean handleExternalInterceptTouch(MotionEvent event) { + @Override + public boolean handleExternalInterceptTouch(MotionEvent event) { try { mUseExternalTouch = true; return mTouchHandler.onInterceptTouchEvent(event); diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java index 59da8f1d5841..324dfdf32a3f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java @@ -52,6 +52,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac import com.android.systemui.keyguard.shared.model.TransitionState; import com.android.systemui.keyguard.shared.model.TransitionStep; import com.android.systemui.res.R; +import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor; import com.android.systemui.shared.animation.DisableSubpixelTextTransitionListener; import com.android.systemui.statusbar.DragDownHelper; import com.android.systemui.statusbar.LockscreenShadeTransitionController; @@ -132,7 +133,8 @@ public class NotificationShadeWindowViewController implements Dumpable { private DragDownHelper mDragDownHelper; private boolean mExpandingBelowNotch; private final DockManager mDockManager; - private final NotificationPanelViewController mNotificationPanelViewController; + private final ShadeViewController mShadeViewController; + private final PanelExpansionInteractor mPanelExpansionInteractor; private final ShadeExpansionStateManager mShadeExpansionStateManager; private boolean mIsTrackingBarGesture = false; @@ -154,7 +156,8 @@ public class NotificationShadeWindowViewController implements Dumpable { DockManager dockManager, NotificationShadeDepthController depthController, NotificationShadeWindowView notificationShadeWindowView, - NotificationPanelViewController notificationPanelViewController, + ShadeViewController shadeViewController, + PanelExpansionInteractor panelExpansionInteractor, ShadeExpansionStateManager shadeExpansionStateManager, NotificationStackScrollLayoutController notificationStackScrollLayoutController, StatusBarKeyguardViewManager statusBarKeyguardViewManager, @@ -187,7 +190,8 @@ public class NotificationShadeWindowViewController implements Dumpable { mStatusBarStateController = statusBarStateController; mView = notificationShadeWindowView; mDockManager = dockManager; - mNotificationPanelViewController = notificationPanelViewController; + mShadeViewController = shadeViewController; + mPanelExpansionInteractor = panelExpansionInteractor; mShadeExpansionStateManager = shadeExpansionStateManager; mDepthController = depthController; mNotificationStackScrollLayoutController = notificationStackScrollLayoutController; @@ -374,7 +378,7 @@ public class NotificationShadeWindowViewController implements Dumpable { } if (!mIsTrackingBarGesture && isDown - && mNotificationPanelViewController.isFullyCollapsed()) { + && mPanelExpansionInteractor.isFullyCollapsed()) { float x = ev.getRawX(); float y = ev.getRawY(); if (mStatusBarViewController.touchIsWithinView(x, y)) { @@ -447,7 +451,7 @@ public class NotificationShadeWindowViewController implements Dumpable { } else { bouncerShowing = mService.isBouncerShowing(); } - if (mNotificationPanelViewController.isFullyExpanded() + if (mPanelExpansionInteractor.isFullyExpanded() && !bouncerShowing && !mStatusBarStateController.isDozing()) { if (mDragDownHelper.isDragDownEnabled()) { @@ -503,7 +507,7 @@ public class NotificationShadeWindowViewController implements Dumpable { cancellation.setAction(MotionEvent.ACTION_CANCEL); mStackScrollLayout.onInterceptTouchEvent(cancellation); if (!MigrateClocksToBlueprint.isEnabled()) { - mNotificationPanelViewController.handleExternalInterceptTouch(cancellation); + mShadeViewController.handleExternalInterceptTouch(cancellation); } cancellation.recycle(); } @@ -522,7 +526,7 @@ public class NotificationShadeWindowViewController implements Dumpable { // we still want to finish our drag down gesture when locking the screen handled |= mDragDownHelper.onTouchEvent(ev) || handled; } - if (!handled && mNotificationPanelViewController.handleExternalTouch(ev)) { + if (!handled && mShadeViewController.handleExternalTouch(ev)) { return true; } } else { @@ -611,7 +615,7 @@ public class NotificationShadeWindowViewController implements Dumpable { // Since NotificationStackScrollLayout is now a sibling of notification_panel, we need // to also ask NotificationPanelViewController directly, in order to process swipe up // events originating from notifications - if (mNotificationPanelViewController.handleExternalInterceptTouch(ev)) { + if (mShadeViewController.handleExternalInterceptTouch(ev)) { mShadeLogger.d("NSWVC: NPVC intercepted"); return true; } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionChangeEvent.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionChangeEvent.kt index 71dfafa09d52..d9c1f0a91d0c 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionChangeEvent.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionChangeEvent.kt @@ -23,7 +23,5 @@ data class ShadeExpansionChangeEvent( /** Whether the panel should be considered expanded */ val expanded: Boolean, /** Whether the user is actively dragging the panel. */ - val tracking: Boolean, - /** The amount of pixels that the user has dragged during the expansion. */ - val dragDownPxAmount: Float + val tracking: Boolean ) diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt index df5ff5a8b1f5..359ddd86f115 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt @@ -18,13 +18,13 @@ package com.android.systemui.shade import android.annotation.IntDef import android.os.Trace -import android.os.Trace.TRACE_TAG_APP as TRACE_TAG import android.util.Log import androidx.annotation.FloatRange import com.android.systemui.dagger.SysUISingleton import com.android.systemui.util.Compile import java.util.concurrent.CopyOnWriteArrayList import javax.inject.Inject +import android.os.Trace.TRACE_TAG_APP as TRACE_TAG /** * A class responsible for managing the notification panel's current state. @@ -42,7 +42,6 @@ class ShadeExpansionStateManager @Inject constructor() { @FloatRange(from = 0.0, to = 1.0) private var fraction: Float = 0f private var expanded: Boolean = false private var tracking: Boolean = false - private var dragDownPxAmount: Float = 0f /** * Adds a listener that will be notified when the panel expansion fraction has changed and @@ -53,7 +52,7 @@ class ShadeExpansionStateManager @Inject constructor() { @Deprecated("Use ShadeInteractor instead") fun addExpansionListener(listener: ShadeExpansionListener): ShadeExpansionChangeEvent { expansionListeners.add(listener) - return ShadeExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount) + return ShadeExpansionChangeEvent(fraction, expanded, tracking) } /** Adds a listener that will be notified when the panel state has changed. */ @@ -76,8 +75,7 @@ class ShadeExpansionStateManager @Inject constructor() { fun onPanelExpansionChanged( @FloatRange(from = 0.0, to = 1.0) fraction: Float, expanded: Boolean, - tracking: Boolean, - dragDownPxAmount: Float + tracking: Boolean ) { require(!fraction.isNaN()) { "fraction cannot be NaN" } val oldState = state @@ -85,7 +83,6 @@ class ShadeExpansionStateManager @Inject constructor() { this.fraction = fraction this.expanded = expanded this.tracking = tracking - this.dragDownPxAmount = dragDownPxAmount var fullyClosed = true var fullyOpened = false @@ -111,7 +108,6 @@ class ShadeExpansionStateManager @Inject constructor() { "f=$fraction " + "expanded=$expanded " + "tracking=$tracking " + - "dragDownPxAmount=$dragDownPxAmount " + "${if (fullyOpened) " fullyOpened" else ""} " + if (fullyClosed) " fullyClosed" else "" ) @@ -124,8 +120,7 @@ class ShadeExpansionStateManager @Inject constructor() { } } - val expansionChangeEvent = - ShadeExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount) + val expansionChangeEvent = ShadeExpansionChangeEvent(fraction, expanded, tracking) expansionListeners.forEach { it.onPanelExpansionChanged(expansionChangeEvent) } } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt index 2d3833c55199..648d4b55370e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt @@ -162,9 +162,7 @@ abstract class ShadeModule { @Binds @SysUISingleton - abstract fun bindsShadeViewController( - notificationPanelViewController: NotificationPanelViewController - ): ShadeViewController + abstract fun bindsShadeViewController(shadeSurface: ShadeSurface): ShadeViewController @Binds @SysUISingleton diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt index d02c2154279b..7346a28dc7a7 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt @@ -15,7 +15,6 @@ */ package com.android.systemui.shade -import android.view.ViewPropertyAnimator import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractor import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor @@ -48,7 +47,7 @@ interface ShadeSurface : fun cancelAnimation() /** Animates the view from its current alpha to zero then runs the runnable. */ - fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable): ViewPropertyAnimator + fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable) /** Set whether the bouncer is showing. */ fun setBouncerShowing(bouncerShowing: Boolean) diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt new file mode 100644 index 000000000000..adb29287e40e --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.shade + +import com.android.systemui.statusbar.GestureRecorder +import com.android.systemui.statusbar.phone.CentralSurfaces +import com.android.systemui.statusbar.policy.HeadsUpManager +import javax.inject.Inject + +class ShadeSurfaceImpl @Inject constructor() : ShadeSurface, ShadeViewControllerEmptyImpl() { + override fun initDependencies( + centralSurfaces: CentralSurfaces, + recorder: GestureRecorder, + hideExpandedRunnable: Runnable, + headsUpManager: HeadsUpManager + ) {} + + override fun cancelPendingCollapse() { + // Do nothing + } + + override fun cancelAnimation() { + // Do nothing + } + + override fun fadeOut(startDelayMs: Long, durationMs: Long, endAction: Runnable) { + // Do nothing + } + + override fun setBouncerShowing(bouncerShowing: Boolean) { + // Do nothing + } + + override fun setTouchAndAnimationDisabled(disabled: Boolean) { + // TODO(b/322197941): determine if still needed + } + + override fun setWillPlayDelayedDozeAmountAnimation(willPlay: Boolean) { + // TODO(b/322494538): determine if still needed + } + + override fun setDozing(dozing: Boolean, animate: Boolean) { + // Do nothing + } + + override fun setImportantForAccessibility(mode: Int) { + // Do nothing + } + + override fun resetTranslation() { + // Do nothing + } + + override fun resetAlpha() { + // Do nothing + } + + override fun onScreenTurningOn() { + // Do nothing + } + + override fun onThemeChanged() { + // Do nothing + } + + override fun updateExpansionAndVisibility() { + // Do nothing + } + + override fun updateResources() { + // Do nothing + } +} diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt index 5b2377f7f610..4e1edd33ecf4 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt @@ -33,14 +33,12 @@ interface ShadeViewController { /** Returns whether the shade's top level view is enabled. */ @Deprecated("No longer supported. Do not add new calls to this.") val isViewEnabled: Boolean - /** Returns whether status bar icons should be hidden when the shade is expanded. */ - fun shouldHideStatusBarIconsWhenExpanded(): Boolean - /** If the latency tracker is enabled, begins tracking expand latency. */ @Deprecated("No longer supported. Do not add new calls to this.") fun startExpandLatencyTracking() /** Sets the alpha value of the shade to a value between 0 and 255. */ + @Deprecated("No longer supported. Do not add new calls to this.") fun setAlpha(alpha: Int, animate: Boolean) /** @@ -48,6 +46,7 @@ interface ShadeViewController { * * @see .setAlpha */ + @Deprecated("No longer supported. Do not add new calls to this.") fun setAlphaChangeAnimationEndAction(r: Runnable) /** Sets Qs ScrimEnabled and updates QS state. */ @@ -61,7 +60,7 @@ interface ShadeViewController { @Deprecated("Does nothing when scene container is enabled.") fun updateSystemUiStateFlags() /** Ensures that the touchable region is updated. */ - fun updateTouchableRegion() + @Deprecated("No longer supported. Do not add new calls to this.") fun updateTouchableRegion() /** * Sends an external (e.g. Status Bar) touch event to the Shade touch handler. @@ -72,6 +71,8 @@ interface ShadeViewController { */ fun handleExternalTouch(event: MotionEvent): Boolean + fun handleExternalInterceptTouch(event: MotionEvent): Boolean + /** * Triggered when an input focus transfer gesture has started. * diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt index e037c701a165..0c41efd513ad 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt @@ -28,7 +28,7 @@ import javax.inject.Inject import kotlinx.coroutines.flow.flowOf /** Empty implementation of ShadeViewController for variants with no shade. */ -class ShadeViewControllerEmptyImpl @Inject constructor() : +open class ShadeViewControllerEmptyImpl @Inject constructor() : ShadeViewController, ShadeBackActionInteractor, ShadeLockscreenInteractor, @@ -81,6 +81,10 @@ class ShadeViewControllerEmptyImpl @Inject constructor() : override fun handleExternalTouch(event: MotionEvent): Boolean { return false } + override fun handleExternalInterceptTouch(event: MotionEvent): Boolean { + return false + } + override fun startInputFocusTransfer() {} override fun cancelInputFocusTransfer() {} override fun finishInputFocusTransfer(velocity: Float) {} diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractor.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractor.kt index 661130317854..dfdf2ad564db 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractor.kt @@ -72,4 +72,8 @@ interface PanelExpansionInteractor { /** Returns the StatusBarState. Note: System UI was formerly known simply as Status Bar. */ @Deprecated("Use SceneInteractor or ShadeInteractor instead") val barState: Int + + /** Returns whether status bar icons should be hidden when the shade is expanded. */ + @Deprecated("No longer supported. Do not add new calls to this.") + fun shouldHideStatusBarIconsWhenExpanded(): Boolean } diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImpl.kt index 561d0bc8e6ef..58bcd2e0d7eb 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/PanelExpansionInteractorImpl.kt @@ -69,27 +69,21 @@ constructor( state.fromScene == Scenes.Gone -> if (state.toScene.isExpandable()) { // Moving from Gone to a scene that can animate-expand has a - // panel - // expansion - // that tracks with the transition. + // panel expansion that tracks with the transition. state.progress } else { // Moving from Gone to a scene that doesn't animate-expand - // immediately makes - // the panel fully expanded. + // immediately makes the panel fully expanded. flowOf(1f) } state.toScene == Scenes.Gone -> if (state.fromScene.isExpandable()) { // Moving to Gone from a scene that can animate-expand has a - // panel - // expansion - // that tracks with the transition. + // panel expansion that tracks with the transition. state.progress.map { 1 - it } } else { // Moving to Gone from a scene that doesn't animate-expand - // immediately makes - // the panel fully collapsed. + // immediately makes the panel fully collapsed. flowOf(0f) } else -> flowOf(1f) @@ -126,6 +120,15 @@ constructor( override val barState get() = statusBarStateController.state + @Deprecated("No longer supported. Do not add new calls to this.") + override fun shouldHideStatusBarIconsWhenExpanded(): Boolean { + if (shadeAnimationInteractor.isLaunchingActivity.value) { + return false + } + // TODO(b/325936094) if a HUN is showing, return false + return sceneInteractor.currentScene.value == Scenes.Lockscreen + } + private fun SceneKey.isExpandable(): Boolean { return this == Scenes.Shade || this == Scenes.QuickSettings } diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt index d8216dcfdec6..f3802da9bc9b 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt @@ -23,13 +23,20 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.log.LogBuffer import com.android.systemui.log.dagger.ShadeTouchLog +import com.android.systemui.scene.domain.interactor.SceneInteractor +import com.android.systemui.scene.shared.flag.SceneContainerFlag +import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.shade.TouchLogger.Companion.logTouchesTo import com.android.systemui.shade.data.repository.ShadeRepository +import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.shade.shared.model.ShadeMode import com.android.systemui.shade.transition.ScrimShadeTransitionController import com.android.systemui.statusbar.policy.SplitShadeStateController import javax.inject.Inject +import javax.inject.Provider import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.launch @@ -43,23 +50,44 @@ constructor( @ShadeTouchLog private val touchLog: LogBuffer, private val configurationRepository: ConfigurationRepository, private val shadeRepository: ShadeRepository, - private val controller: SplitShadeStateController, + private val splitShadeStateController: SplitShadeStateController, private val scrimShadeTransitionController: ScrimShadeTransitionController, + private val sceneInteractorProvider: Provider<SceneInteractor>, + private val panelExpansionInteractorProvider: Provider<PanelExpansionInteractor>, + private val shadeExpansionStateManager: ShadeExpansionStateManager, ) : CoreStartable { override fun start() { hydrateShadeMode() + hydrateShadeExpansionStateManager() logTouchesTo(touchLog) scrimShadeTransitionController.init() } + private fun hydrateShadeExpansionStateManager() { + if (SceneContainerFlag.isEnabled) { + combine( + panelExpansionInteractorProvider.get().legacyPanelExpansion, + sceneInteractorProvider.get().isTransitionUserInputOngoing, + ) { panelExpansion, tracking -> + shadeExpansionStateManager.onPanelExpansionChanged( + fraction = panelExpansion, + expanded = panelExpansion > 0f, + tracking = tracking, + ) + }.launchIn(applicationScope) + } + } + private fun hydrateShadeMode() { applicationScope.launch { configurationRepository.onAnyConfigurationChange // Force initial collection. .onStart { emit(Unit) } .map { applicationContext.resources } - .map { resources -> controller.shouldUseSplitNotificationShade(resources) } + .map { resources -> + splitShadeStateController.shouldUseSplitNotificationShade(resources) + } .collect { isSplitShade -> shadeRepository.setShadeMode( if (isSplitShade) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/transition/ScrimShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/shade/transition/ScrimShadeTransitionController.kt index 151e28903fba..e38e53d67f61 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/transition/ScrimShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/transition/ScrimShadeTransitionController.kt @@ -17,28 +17,20 @@ package com.android.systemui.shade.transition import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dump.DumpManager -import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.PanelState import com.android.systemui.shade.ShadeExpansionChangeEvent import com.android.systemui.shade.ShadeExpansionStateManager -import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.statusbar.phone.ScrimController -import dagger.Lazy import java.io.PrintWriter import javax.inject.Inject -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch /** Controls the scrim properties during the shade expansion transition on non-lockscreen. */ @SysUISingleton class ScrimShadeTransitionController @Inject constructor( - @Application private val applicationScope: CoroutineScope, private val shadeExpansionStateManager: ShadeExpansionStateManager, - private val panelExpansionInteractor: Lazy<PanelExpansionInteractor>, private val dumpManager: DumpManager, private val scrimController: ScrimController, ) { @@ -47,32 +39,17 @@ constructor( private var currentPanelState: Int? = null fun init() { - if (SceneContainerFlag.isEnabled) { - applicationScope.launch { - panelExpansionInteractor.get().legacyPanelExpansion.collect { panelExpansion -> - onPanelExpansionChanged( - ShadeExpansionChangeEvent( - fraction = panelExpansion, - expanded = panelExpansion > 0f, - tracking = true, - dragDownPxAmount = 0f, - ) - ) - } - } - } else { - val currentState = - shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged) - onPanelExpansionChanged(currentState) - shadeExpansionStateManager.addStateListener(this::onPanelStateChanged) - } + val currentState = + shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged) + onPanelExpansionChanged(currentState) + shadeExpansionStateManager.addStateListener(this::onPanelStateChanged) dumpManager.registerDumpable( ScrimShadeTransitionController::class.java.simpleName, this::dump ) } - fun onPanelStateChanged(@PanelState state: Int) { + private fun onPanelStateChanged(@PanelState state: Int) { currentPanelState = state onStateChanged() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java index f960fcafafc6..e5b64970c5b0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/CentralSurfacesDependenciesModule.java @@ -35,9 +35,11 @@ import com.android.systemui.dump.DumpHandler; import com.android.systemui.dump.DumpManager; import com.android.systemui.media.controls.domain.pipeline.MediaDataManager; import com.android.systemui.power.domain.interactor.PowerInteractor; +import com.android.systemui.scene.shared.flag.SceneContainerFlags; import com.android.systemui.settings.DisplayTracker; import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.ShadeSurface; +import com.android.systemui.shade.ShadeSurfaceImpl; import com.android.systemui.shade.carrier.ShadeCarrierGroupController; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationClickNotifier; @@ -59,6 +61,8 @@ import com.android.systemui.statusbar.phone.StatusBarIconList; import com.android.systemui.statusbar.phone.StatusBarRemoteInputCallback; import com.android.systemui.statusbar.policy.KeyguardStateController; +import javax.inject.Provider; + import dagger.Binds; import dagger.Lazy; import dagger.Module; @@ -178,9 +182,20 @@ public interface CentralSurfacesDependenciesModule { * The {@link com.android.systemui.shade.ShadeViewController} interface is bound in * {@link com.android.systemui.shade.ShadeModule} so others can access it. */ - @Binds + @Provides @SysUISingleton - ShadeSurface provideShadeSurface(NotificationPanelViewController impl); + static ShadeSurface provideShadeSurface( + SceneContainerFlags sceneContainerFlags, + Provider<ShadeSurfaceImpl> sceneContainerOn, + Provider<NotificationPanelViewController> sceneContainerOff) { + if (sceneContainerFlags.isEnabled()) { + return sceneContainerOn.get(); + } else { + return sceneContainerOff.get(); + } + + } + /** */ @Binds 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 b6f653fabdc4..2798dbfc62e4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -164,6 +164,7 @@ import com.android.systemui.qs.QSFragmentLegacy; import com.android.systemui.qs.QSPanelController; import com.android.systemui.res.R; import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor; +import com.android.systemui.scene.shared.flag.SceneContainerFlag; import com.android.systemui.scene.shared.flag.SceneContainerFlags; import com.android.systemui.scrim.ScrimView; import com.android.systemui.settings.UserTracker; @@ -1256,11 +1257,13 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mScreenOffAnimationController.initialize(this, mShadeSurface, mLightRevealScrim); updateLightRevealScrimVisibility(); - mShadeSurface.initDependencies( - this, - mGestureRec, - mShadeController::makeExpandedInvisible, - mHeadsUpManager); + if (!SceneContainerFlag.isEnabled()) { + mShadeSurface.initDependencies( + this, + mGestureRec, + mShadeController::makeExpandedInvisible, + mHeadsUpManager); + } // Set up the quick settings tile panel final View container = getNotificationShadeWindowView().findViewById(R.id.qs_frame); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java index 617e1076fca3..c52132f66813 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java @@ -46,7 +46,7 @@ import com.android.systemui.dump.DumpManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.res.R; import com.android.systemui.shade.ShadeExpansionStateManager; -import com.android.systemui.shade.ShadeViewController; +import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.OperatorNameView; import com.android.systemui.statusbar.OperatorNameViewController; @@ -79,6 +79,8 @@ import com.android.systemui.util.CarrierConfigTracker.CarrierConfigChangedListen import com.android.systemui.util.CarrierConfigTracker.DefaultDataSubscriptionChangedListener; import com.android.systemui.util.settings.SecureSettings; +import kotlin.Unit; + import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; @@ -89,8 +91,6 @@ import java.util.concurrent.Executor; import javax.inject.Inject; -import kotlin.Unit; - import kotlinx.coroutines.DisposableHandle; /** @@ -115,7 +115,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue private PhoneStatusBarView mStatusBar; private final StatusBarStateController mStatusBarStateController; private final KeyguardStateController mKeyguardStateController; - private final ShadeViewController mShadeViewController; + private final PanelExpansionInteractor mPanelExpansionInteractor; private MultiSourceMinAlphaController mEndSideAlphaController; private LinearLayout mEndSideContent; private View mClockView; @@ -227,7 +227,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue CollapsedStatusBarViewBinder collapsedStatusBarViewBinder, StatusBarHideIconsForBouncerManager statusBarHideIconsForBouncerManager, KeyguardStateController keyguardStateController, - ShadeViewController shadeViewController, + PanelExpansionInteractor panelExpansionInteractor, StatusBarStateController statusBarStateController, NotificationIconContainerStatusBarViewBinder nicViewBinder, CommandQueue commandQueue, @@ -252,7 +252,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue mStatusBarHideIconsForBouncerManager = statusBarHideIconsForBouncerManager; mDarkIconManagerFactory = darkIconManagerFactory; mKeyguardStateController = keyguardStateController; - mShadeViewController = shadeViewController; + mPanelExpansionInteractor = panelExpansionInteractor; mStatusBarStateController = statusBarStateController; mNicViewBinder = nicViewBinder; mCommandQueue = commandQueue; @@ -603,7 +603,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue private boolean shouldHideStatusBar() { if (!mShadeExpansionStateManager.isClosed() - && mShadeViewController.shouldHideStatusBarIconsWhenExpanded()) { + && mPanelExpansionInteractor.shouldHideStatusBarIconsWhenExpanded()) { return true; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 29a92d969ca4..650c45bf83ea 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -1061,7 +1061,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo @Test public void testPanelClosedWhenClosingQsInSplitShade() { mShadeExpansionStateManager.onPanelExpansionChanged(/* fraction= */ 1, - /* expanded= */ true, /* tracking= */ false, /* dragDownPxAmount= */ 0); + /* expanded= */ true, /* tracking= */ false); enableSplitShade(/* enabled= */ true); mNotificationPanelViewController.setExpandedFraction(1f); diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt index b6996131ea09..7a3b561e2f8f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt @@ -46,6 +46,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.res.R import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler +import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.statusbar.DragDownHelper import com.android.systemui.statusbar.LockscreenShadeTransitionController import com.android.systemui.statusbar.NotificationInsetsController @@ -68,6 +69,7 @@ import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth.assertThat +import java.util.Optional import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.emptyFlow @@ -85,7 +87,6 @@ import org.mockito.Mockito.never import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations -import java.util.Optional import org.mockito.Mockito.`when` as whenever @OptIn(ExperimentalCoroutinesApi::class) @@ -100,7 +101,8 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { @Mock private lateinit var dozeServiceHost: DozeServiceHost @Mock private lateinit var dozeScrimController: DozeScrimController @Mock private lateinit var dockManager: DockManager - @Mock private lateinit var notificationPanelViewController: NotificationPanelViewController + @Mock private lateinit var shadeViewController: ShadeViewController + @Mock private lateinit var panelExpansionInteractor: PanelExpansionInteractor @Mock private lateinit var notificationShadeDepthController: NotificationShadeDepthController @Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController @Mock private lateinit var keyguardUnlockAnimationController: KeyguardUnlockAnimationController @@ -177,7 +179,8 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { dockManager, notificationShadeDepthController, view, - notificationPanelViewController, + shadeViewController, + panelExpansionInteractor, ShadeExpansionStateManager(), stackScrollLayoutController, statusBarKeyguardViewManager, @@ -263,7 +266,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { testScope.runTest { underTest.setStatusBarViewController(phoneStatusBarViewController) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(true) - whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true) + whenever(panelExpansionInteractor.isFullyCollapsed).thenReturn(true) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) .thenReturn(true) whenever(phoneStatusBarViewController.sendTouchToView(DOWN_EVENT)).thenReturn(true) @@ -282,7 +285,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) .thenReturn(true) // Item we're testing - whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(false) + whenever(panelExpansionInteractor.isFullyCollapsed).thenReturn(false) val returnVal = interactionEventHandler.handleDispatchTouchEvent(DOWN_EVENT) @@ -295,7 +298,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { testScope.runTest { underTest.setStatusBarViewController(phoneStatusBarViewController) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(true) - whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true) + whenever(panelExpansionInteractor.isFullyCollapsed).thenReturn(true) // Item we're testing whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) .thenReturn(false) @@ -310,7 +313,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { fun handleDispatchTouchEvent_sbWindowNotShowing_noSendTouchToSbAndReturnsTrue() = testScope.runTest { underTest.setStatusBarViewController(phoneStatusBarViewController) - whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true) + whenever(panelExpansionInteractor.isFullyCollapsed).thenReturn(true) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) .thenReturn(true) // Item we're testing @@ -327,7 +330,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { testScope.runTest { underTest.setStatusBarViewController(phoneStatusBarViewController) whenever(statusBarWindowStateController.windowIsShowing()).thenReturn(true) - whenever(notificationPanelViewController.isFullyCollapsed).thenReturn(true) + whenever(panelExpansionInteractor.isFullyCollapsed).thenReturn(true) whenever(phoneStatusBarViewController.touchIsWithinView(anyFloat(), anyFloat())) .thenReturn(true) @@ -486,7 +489,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { // AND bouncer is not showing whenever(centralSurfaces.isBouncerShowing()).thenReturn(false) // AND panel view controller wants it - whenever(notificationPanelViewController.handleExternalInterceptTouch(DOWN_EVENT)) + whenever(shadeViewController.handleExternalInterceptTouch(DOWN_EVENT)) .thenReturn(true) mSetFlagsRule.enableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt index 2ecca2e5c4ca..0f54e0718233 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt @@ -38,6 +38,7 @@ import com.android.systemui.keyguard.KeyguardUnlockAnimationController import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.res.R import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler +import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.statusbar.DragDownHelper import com.android.systemui.statusbar.LockscreenShadeTransitionController import com.android.systemui.statusbar.NotificationInsetsController @@ -89,7 +90,8 @@ class NotificationShadeWindowViewTest : SysuiTestCase() { @Mock private lateinit var dozeServiceHost: DozeServiceHost @Mock private lateinit var dozeScrimController: DozeScrimController @Mock private lateinit var dockManager: DockManager - @Mock private lateinit var notificationPanelViewController: NotificationPanelViewController + @Mock private lateinit var shadeViewController: ShadeViewController + @Mock private lateinit var panelExpansionInteractor: PanelExpansionInteractor @Mock private lateinit var notificationStackScrollLayout: NotificationStackScrollLayout @Mock private lateinit var notificationShadeDepthController: NotificationShadeDepthController @Mock private lateinit var notificationShadeWindowController: NotificationShadeWindowController @@ -166,7 +168,8 @@ class NotificationShadeWindowViewTest : SysuiTestCase() { dockManager, notificationShadeDepthController, underTest, - notificationPanelViewController, + shadeViewController, + panelExpansionInteractor, ShadeExpansionStateManager(), notificationStackScrollLayoutController, statusBarKeyguardViewManager, diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeExpansionStateManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeExpansionStateManagerTest.kt index 15c04eb2e2bc..89ae42fd9f83 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeExpansionStateManagerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeExpansionStateManagerTest.kt @@ -42,17 +42,11 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { val tracking = true val dragDownAmount = 1234f - shadeExpansionStateManager.onPanelExpansionChanged( - fraction, - expanded, - tracking, - dragDownAmount - ) + shadeExpansionStateManager.onPanelExpansionChanged(fraction, expanded, tracking) assertThat(listener.fraction).isEqualTo(fraction) assertThat(listener.expanded).isEqualTo(expanded) assertThat(listener.tracking).isEqualTo(tracking) - assertThat(listener.dragDownAmountPx).isEqualTo(dragDownAmount) } @Test @@ -61,12 +55,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { val expanded = true val tracking = true val dragDownAmount = 1234f - shadeExpansionStateManager.onPanelExpansionChanged( - fraction, - expanded, - tracking, - dragDownAmount - ) + shadeExpansionStateManager.onPanelExpansionChanged(fraction, expanded, tracking) val listener = TestShadeExpansionListener() val currentState = shadeExpansionStateManager.addExpansionListener(listener) @@ -75,7 +64,6 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { assertThat(listener.fraction).isEqualTo(fraction) assertThat(listener.expanded).isEqualTo(expanded) assertThat(listener.tracking).isEqualTo(tracking) - assertThat(listener.dragDownAmountPx).isEqualTo(dragDownAmount) } @Test @@ -100,8 +88,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 0.5f, expanded = true, - tracking = false, - dragDownPxAmount = 0f + tracking = false ) assertThat(listener.state).isEqualTo(STATE_OPENING) @@ -115,8 +102,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 0.5f, expanded = true, - tracking = true, - dragDownPxAmount = 0f + tracking = true ) assertThat(listener.state).isEqualTo(STATE_OPENING) @@ -132,8 +118,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 0.5f, expanded = false, - tracking = false, - dragDownPxAmount = 0f + tracking = false ) assertThat(listener.state).isEqualTo(STATE_CLOSED) @@ -149,8 +134,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 0.5f, expanded = false, - tracking = true, - dragDownPxAmount = 0f + tracking = true ) assertThat(listener.state).isEqualTo(STATE_OPEN) @@ -166,8 +150,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 1f, expanded = true, - tracking = false, - dragDownPxAmount = 0f + tracking = false ) assertThat(listener.previousState).isEqualTo(STATE_OPENING) @@ -182,8 +165,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 1f, expanded = true, - tracking = true, - dragDownPxAmount = 0f + tracking = true ) assertThat(listener.state).isEqualTo(STATE_OPENING) @@ -199,8 +181,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 1f, expanded = false, - tracking = false, - dragDownPxAmount = 0f + tracking = false ) assertThat(listener.state).isEqualTo(STATE_CLOSED) @@ -216,8 +197,7 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { shadeExpansionStateManager.onPanelExpansionChanged( fraction = 1f, expanded = false, - tracking = true, - dragDownPxAmount = 0f + tracking = true ) assertThat(listener.state).isEqualTo(STATE_OPEN) @@ -229,13 +209,11 @@ class ShadeExpansionStateManagerTest : SysuiTestCase() { var fraction: Float = 0f var expanded: Boolean = false var tracking: Boolean = false - var dragDownAmountPx: Float = 0f override fun onPanelExpansionChanged(event: ShadeExpansionChangeEvent) { this.fraction = event.fraction this.expanded = event.expanded this.tracking = event.tracking - this.dragDownAmountPx = event.dragDownPxAmount } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ScrimShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ScrimShadeTransitionControllerTest.kt index dea905aad132..f2abb909e004 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ScrimShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/transition/ScrimShadeTransitionControllerTest.kt @@ -3,23 +3,18 @@ package com.android.systemui.shade.transition import android.platform.test.annotations.DisableFlags import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest -import com.android.compose.animation.scene.ObservableTransitionState -import com.android.compose.animation.scene.SceneKey import com.android.systemui.Flags import com.android.systemui.SysuiTestCase -import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.data.repository.FakeDeviceEntryRepository import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor import com.android.systemui.dump.DumpManager -import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.kosmos.testScope import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor import com.android.systemui.scene.shared.model.FakeSceneDataSource -import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource import com.android.systemui.shade.ShadeExpansionChangeEvent import com.android.systemui.shade.ShadeExpansionStateManager @@ -27,15 +22,8 @@ import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.shade.domain.interactor.panelExpansionInteractor import com.android.systemui.statusbar.phone.ScrimController import com.android.systemui.testKosmos -import com.android.systemui.util.mockito.any -import com.android.systemui.util.mockito.whenever -import com.google.common.truth.Truth import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.TestScope -import kotlinx.coroutines.test.runCurrent -import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -74,9 +62,7 @@ class ScrimShadeTransitionControllerTest : SysuiTestCase() { sceneInteractor = kosmos.sceneInteractor fakeSceneDataSource = kosmos.fakeSceneDataSource underTest = ScrimShadeTransitionController( - applicationScope, shadeExpansionStateManager, - { panelExpansionInteractor }, dumpManager, scrimController, ) @@ -99,96 +85,20 @@ class ScrimShadeTransitionControllerTest : SysuiTestCase() { verify(scrimController).setRawPanelExpansionFraction(DEFAULT_EXPANSION_EVENT.fraction) } - @Test - @EnableSceneContainer - fun sceneChanges_forwardsToScrimTransitionController() = - testScope.runTest { - var rawExpansion: Float? = null - whenever(scrimController.setRawPanelExpansionFraction(any())).then { - (it.arguments[0] as Float?).also { rawExp -> rawExpansion = rawExp } - } - setUnlocked(true) - val transitionState = - MutableStateFlow<ObservableTransitionState>( - ObservableTransitionState.Idle(Scenes.Gone) - ) - sceneInteractor.setTransitionState(transitionState) - - changeScene(Scenes.Gone, transitionState) - val currentScene by collectLastValue(sceneInteractor.currentScene) - Truth.assertThat(currentScene).isEqualTo(Scenes.Gone) - - Truth.assertThat(rawExpansion) - .isEqualTo(0f) - - changeScene(Scenes.Shade, transitionState) { progress -> - Truth.assertThat(rawExpansion) - .isEqualTo(progress) - } - } - private fun startLegacyPanelExpansion() { shadeExpansionStateManager.onPanelExpansionChanged( DEFAULT_EXPANSION_EVENT.fraction, DEFAULT_EXPANSION_EVENT.expanded, DEFAULT_EXPANSION_EVENT.tracking, - DEFAULT_EXPANSION_EVENT.dragDownPxAmount, ) } - private fun TestScope.setUnlocked(isUnlocked: Boolean) { - val isDeviceUnlocked by collectLastValue(deviceUnlockedInteractor.isDeviceUnlocked) - deviceEntryRepository.setUnlocked(isUnlocked) - runCurrent() - - Truth.assertThat(isDeviceUnlocked).isEqualTo(isUnlocked) - } - - private fun TestScope.changeScene( - toScene: SceneKey, - transitionState: MutableStateFlow<ObservableTransitionState>, - assertDuringProgress: ((progress: Float) -> Unit) = {}, - ) { - val currentScene by collectLastValue(sceneInteractor.currentScene) - val progressFlow = MutableStateFlow(0f) - transitionState.value = - ObservableTransitionState.Transition( - fromScene = checkNotNull(currentScene), - toScene = toScene, - progress = progressFlow, - isInitiatedByUserInput = true, - isUserInputOngoing = flowOf(true), - ) - runCurrent() - assertDuringProgress(progressFlow.value) - - progressFlow.value = 0.2f - runCurrent() - assertDuringProgress(progressFlow.value) - - progressFlow.value = 0.6f - runCurrent() - assertDuringProgress(progressFlow.value) - - progressFlow.value = 1f - runCurrent() - assertDuringProgress(progressFlow.value) - - transitionState.value = ObservableTransitionState.Idle(toScene) - fakeSceneDataSource.changeScene(toScene) - runCurrent() - assertDuringProgress(progressFlow.value) - - Truth.assertThat(currentScene).isEqualTo(toScene) - } - companion object { val DEFAULT_EXPANSION_EVENT = ShadeExpansionChangeEvent( fraction = 0.5f, expanded = true, - tracking = true, - dragDownPxAmount = 10f + tracking = true ) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt index 68bc72b09f94..fc0c85e30d5a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationShadeDepthControllerTest.kt @@ -23,18 +23,18 @@ import android.view.Choreographer import android.view.View import android.view.ViewRootImpl import androidx.test.filters.SmallTest -import com.android.systemui.res.R import com.android.systemui.SysuiTestCase import com.android.systemui.animation.ShadeInterpolation import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.statusbar.StatusBarStateController +import com.android.systemui.res.R import com.android.systemui.shade.ShadeExpansionChangeEvent import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.ScrimController import com.android.systemui.statusbar.policy.FakeConfigurationController -import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController import com.android.systemui.statusbar.policy.KeyguardStateController +import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController import com.android.systemui.util.WallpaperController import com.android.systemui.util.mockito.eq import com.google.common.truth.Truth.assertThat @@ -142,7 +142,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun onPanelExpansionChanged_apliesBlur_ifShade() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) verify(shadeAnimation).animateTo(eq(maxBlur)) } @@ -150,7 +150,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun onPanelExpansionChanged_animatesBlurIn_ifShade() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 0.01f, expanded = false, tracking = false, dragDownPxAmount = 0f)) + fraction = 0.01f, expanded = false, tracking = false)) verify(shadeAnimation).animateTo(eq(maxBlur)) } @@ -160,7 +160,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { clearInvocations(shadeAnimation) notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 0f, expanded = false, tracking = false, dragDownPxAmount = 0f)) + fraction = 0f, expanded = false, tracking = false)) verify(shadeAnimation).animateTo(eq(0)) } @@ -168,7 +168,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun onPanelExpansionChanged_animatesBlurOut_ifFlick() { val event = ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f) + fraction = 1f, expanded = true, tracking = false) onPanelExpansionChanged_apliesBlur_ifShade() clearInvocations(shadeAnimation) notificationShadeDepthController.onPanelExpansionChanged(event) @@ -189,7 +189,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { clearInvocations(shadeAnimation) notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 0.6f, expanded = true, tracking = true, dragDownPxAmount = 0f)) + fraction = 0.6f, expanded = true, tracking = true)) verify(shadeAnimation).animateTo(eq(maxBlur)) } @@ -197,7 +197,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun onPanelExpansionChanged_respectsMinPanelPullDownFraction() { val event = ShadeExpansionChangeEvent( - fraction = 0.5f, expanded = true, tracking = true, dragDownPxAmount = 0f) + fraction = 0.5f, expanded = true, tracking = true) notificationShadeDepthController.panelPullDownMinFraction = 0.5f notificationShadeDepthController.onPanelExpansionChanged(event) assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0f) @@ -225,7 +225,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.qsPanelExpansion = 1f notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false)) } @@ -236,7 +236,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.qsPanelExpansion = 0.25f notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(wallpaperController) .setNotificationShadeZoom(eq(ShadeInterpolation.getNotificationScrimAlpha(0.25f))) @@ -248,7 +248,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(wallpaperController).setNotificationShadeZoom(0f) @@ -260,7 +260,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(wallpaperController).setNotificationShadeZoom(floatThat { it > 0 }) @@ -273,7 +273,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { val expanded = true val tracking = false val dragDownPxAmount = 0f - val event = ShadeExpansionChangeEvent(rawFraction, expanded, tracking, dragDownPxAmount) + val event = ShadeExpansionChangeEvent(rawFraction, expanded, tracking) val inOrder = Mockito.inOrder(wallpaperController) notificationShadeDepthController.onPanelExpansionChanged(event) @@ -338,7 +338,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun updateBlurCallback_setsBlur_whenExpanded() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) notificationShadeDepthController.updateBlurCallback.doFrame(0) verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false)) @@ -348,7 +348,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun updateBlurCallback_ignoreShadeBlurUntilHidden_overridesZoom() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) notificationShadeDepthController.blursDisabledForAppLaunch = true notificationShadeDepthController.updateBlurCallback.doFrame(0) @@ -367,7 +367,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun ignoreBlurForUnlock_ignores() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) notificationShadeDepthController.blursDisabledForAppLaunch = false @@ -384,7 +384,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { fun ignoreBlurForUnlock_doesNotIgnore() { notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) notificationShadeDepthController.blursDisabledForAppLaunch = false @@ -416,7 +416,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() { // And shade is blurred notificationShadeDepthController.onPanelExpansionChanged( ShadeExpansionChangeEvent( - fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)) + fraction = 1f, expanded = true, tracking = false)) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) notificationShadeDepthController.updateBlurCallback.doFrame(0) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java index 054680df1582..ba5ab3273dc6 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java @@ -597,8 +597,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { private static ShadeExpansionChangeEvent expansionEvent( float fraction, boolean expanded, boolean tracking) { - return new ShadeExpansionChangeEvent( - fraction, expanded, tracking, /* dragDownPxAmount= */ 0f); + return new ShadeExpansionChangeEvent(fraction, expanded, tracking); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java index 3da5ab9f9d3d..9c3d9c669adc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java @@ -52,7 +52,7 @@ import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.res.R; import com.android.systemui.shade.ShadeExpansionStateManager; -import com.android.systemui.shade.ShadeViewController; +import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.OperatorNameViewController; import com.android.systemui.statusbar.disableflags.DisableFlagsLogger; @@ -115,7 +115,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { @Mock private HeadsUpAppearanceController mHeadsUpAppearanceController; @Mock - private ShadeViewController mShadeViewController; + private PanelExpansionInteractor mPanelExpansionInteractor; @Mock private StatusBarIconController.DarkIconManager.Factory mIconManagerFactory; @Mock @@ -304,7 +304,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { // WHEN the shade is open and configured to hide the status bar icons mShadeExpansionStateManager.updateState(STATE_OPEN); - when(mShadeViewController.shouldHideStatusBarIconsWhenExpanded()).thenReturn(true); + when(mPanelExpansionInteractor.shouldHideStatusBarIconsWhenExpanded()).thenReturn(true); fragment.disable(DEFAULT_DISPLAY, 0, 0, false); @@ -320,7 +320,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { // WHEN the shade is open but *not* configured to hide the status bar icons mShadeExpansionStateManager.updateState(STATE_OPEN); - when(mShadeViewController.shouldHideStatusBarIconsWhenExpanded()).thenReturn(false); + when(mPanelExpansionInteractor.shouldHideStatusBarIconsWhenExpanded()).thenReturn(false); fragment.disable(DEFAULT_DISPLAY, 0, 0, false); @@ -337,7 +337,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { // WHEN the shade is open and configured to hide the status bar icons mShadeExpansionStateManager.updateState(STATE_OPEN); - when(mShadeViewController.shouldHideStatusBarIconsWhenExpanded()).thenReturn(true); + when(mPanelExpansionInteractor.shouldHideStatusBarIconsWhenExpanded()).thenReturn(true); fragment.disable(DEFAULT_DISPLAY, 0, 0, false); @@ -696,7 +696,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { mCollapsedStatusBarViewBinder, mStatusBarHideIconsForBouncerManager, mKeyguardStateController, - mShadeViewController, + mPanelExpansionInteractor, mStatusBarStateController, mock(NotificationIconContainerStatusBarViewBinder.class), mCommandQueue, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt index 513c6ab3586d..4a2eaf0f7bf6 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/ShadeControllerKosmos.kt @@ -27,6 +27,7 @@ import com.android.systemui.kosmos.testDispatcher import com.android.systemui.log.LogBuffer import com.android.systemui.plugins.statusbar.statusBarStateController import com.android.systemui.scene.domain.interactor.sceneInteractor +import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.NotificationShadeWindowController @@ -78,4 +79,11 @@ val Kosmos.shadeControllerImpl by { mock<NotificationGutsManager>() }, ) } -var Kosmos.shadeController: ShadeController by Kosmos.Fixture { shadeControllerImpl } +var Kosmos.shadeController: ShadeController by + Kosmos.Fixture { + if (SceneContainerFlag.isEnabled) { + shadeControllerSceneImpl + } else { + shadeControllerImpl + } + } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/startable/ShadeStartableKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/startable/ShadeStartableKosmos.kt index 7dfa68605ef3..b85858d915b5 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/startable/ShadeStartableKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/startable/ShadeStartableKosmos.kt @@ -22,11 +22,17 @@ import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.kosmos.applicationCoroutineScope import com.android.systemui.log.LogBuffer +import com.android.systemui.scene.domain.interactor.sceneInteractor +import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.shade.data.repository.shadeRepository +import com.android.systemui.shade.domain.interactor.panelExpansionInteractor import com.android.systemui.shade.transition.ScrimShadeTransitionController import com.android.systemui.statusbar.policy.splitShadeStateController import com.android.systemui.util.mockito.mock +@Deprecated("ShadeExpansionStateManager is deprecated. Remove your dependency on it instead.") +val Kosmos.shadeExpansionStateManager by Fixture { ShadeExpansionStateManager() } + val Kosmos.shadeStartable by Fixture { ShadeStartable( applicationScope = applicationCoroutineScope, @@ -34,7 +40,10 @@ val Kosmos.shadeStartable by Fixture { touchLog = mock<LogBuffer>(), configurationRepository = configurationRepository, shadeRepository = shadeRepository, - controller = splitShadeStateController, + splitShadeStateController = splitShadeStateController, scrimShadeTransitionController = mock<ScrimShadeTransitionController>(), + sceneInteractorProvider = { sceneInteractor }, + panelExpansionInteractorProvider = { panelExpansionInteractor }, + shadeExpansionStateManager = shadeExpansionStateManager, ) } |