summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-08-21 15:59:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-08-21 15:59:24 +0000
commitf4918271134e72da0e55436776480740b283997a (patch)
treec1a9e71ea3298aa7e62d6c9937a45909276e692b
parentcf7450804b63af9d4908540983f15e20f9621663 (diff)
parentd0c099257ee3a75df4664febe015f08a15e0ccff (diff)
Merge changes I938c93bd,Ia3640874 into main
* changes: [flexiglass] Only show full notifications on lockscreen [flexiglass] StatusBarState is KEYGUARD on Scenes.Lockscreen
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt17
-rw-r--r--packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java18
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java14
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt2
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt2
8 files changed, 63 insertions, 8 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt
index 355669bd8a59..f72a2e861be5 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt
@@ -43,6 +43,7 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.scene.data.repository.Idle
import com.android.systemui.scene.data.repository.setTransition
+import com.android.systemui.scene.domain.interactor.sceneBackInteractor
import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
@@ -112,6 +113,7 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest
{ kosmos.sceneInteractor },
{ kosmos.sceneContainerOcclusionInteractor },
{ kosmos.keyguardClockInteractor },
+ { kosmos.sceneBackInteractor },
) {
override fun createDarkAnimator(): ObjectAnimator {
return mockDarkAnimator
@@ -320,12 +322,23 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization) : SysuiTest
assertThat(deviceUnlockStatus!!.isUnlocked).isTrue()
- kosmos.sceneInteractor.changeScene(toScene = Scenes.Gone, loggingReason = "reason")
+ kosmos.sceneInteractor.changeScene(
+ toScene = Scenes.Lockscreen,
+ loggingReason = "reason"
+ )
runCurrent()
- assertThat(currentScene).isEqualTo(Scenes.Gone)
+ assertThat(currentScene).isEqualTo(Scenes.Lockscreen)
// Call start to begin hydrating based on the scene framework:
underTest.start()
+ runCurrent()
+
+ assertThat(statusBarState).isEqualTo(StatusBarState.KEYGUARD)
+
+ kosmos.sceneInteractor.changeScene(toScene = Scenes.Gone, loggingReason = "reason")
+ runCurrent()
+ assertThat(currentScene).isEqualTo(Scenes.Gone)
+ assertThat(statusBarState).isEqualTo(StatusBarState.SHADE)
kosmos.sceneInteractor.changeScene(toScene = Scenes.Shade, loggingReason = "reason")
runCurrent()
diff --git a/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt b/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt
index d3e529c9035b..323bb3ddd63a 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/data/model/SceneStack.kt
@@ -55,6 +55,9 @@ fun SceneStack.asIterable(): Iterable<SceneKey> = Iterable {
}
}
+/** Does this stack contain the given [sceneKey]? O(N) */
+fun SceneStack.contains(sceneKey: SceneKey): Boolean = asIterable().any { it == sceneKey }
+
/**
* Returns a new [SceneStack] containing the given [scenes], ordered such that the first argument is
* the head returned from [peek], then the second, and so forth.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
index 0957e5a5df35..3422c67d50bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java
@@ -54,6 +54,9 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac
import com.android.systemui.keyguard.shared.model.KeyguardState;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.res.R;
+import com.android.systemui.scene.data.model.SceneStack;
+import com.android.systemui.scene.data.model.SceneStackKt;
+import com.android.systemui.scene.domain.interactor.SceneBackInteractor;
import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor;
import com.android.systemui.scene.domain.interactor.SceneInteractor;
import com.android.systemui.scene.shared.flag.SceneContainerFlag;
@@ -118,6 +121,7 @@ public class StatusBarStateControllerImpl implements
private final Lazy<SceneInteractor> mSceneInteractorLazy;
private final Lazy<SceneContainerOcclusionInteractor> mSceneContainerOcclusionInteractorLazy;
private final Lazy<KeyguardClockInteractor> mKeyguardClockInteractorLazy;
+ private final Lazy<SceneBackInteractor> mSceneBackInteractorLazy;
private int mState;
private int mLastState;
private int mUpcomingState;
@@ -186,7 +190,8 @@ public class StatusBarStateControllerImpl implements
Lazy<DeviceUnlockedInteractor> deviceUnlockedInteractorLazy,
Lazy<SceneInteractor> sceneInteractorLazy,
Lazy<SceneContainerOcclusionInteractor> sceneContainerOcclusionInteractor,
- Lazy<KeyguardClockInteractor> keyguardClockInteractorLazy) {
+ Lazy<KeyguardClockInteractor> keyguardClockInteractorLazy,
+ Lazy<SceneBackInteractor> sceneBackInteractorLazy) {
mUiEventLogger = uiEventLogger;
mInteractionJankMonitorLazy = interactionJankMonitorLazy;
mJavaAdapter = javaAdapter;
@@ -196,6 +201,7 @@ public class StatusBarStateControllerImpl implements
mSceneInteractorLazy = sceneInteractorLazy;
mSceneContainerOcclusionInteractorLazy = sceneContainerOcclusionInteractor;
mKeyguardClockInteractorLazy = keyguardClockInteractorLazy;
+ mSceneBackInteractorLazy = sceneBackInteractorLazy;
for (int i = 0; i < HISTORY_SIZE; i++) {
mHistoricalRecords[i] = new HistoricalState();
}
@@ -221,6 +227,7 @@ public class StatusBarStateControllerImpl implements
combineFlows(
mDeviceUnlockedInteractorLazy.get().getDeviceUnlockStatus(),
mSceneInteractorLazy.get().getCurrentScene(),
+ mSceneBackInteractorLazy.get().getBackStack(),
mSceneContainerOcclusionInteractorLazy.get().getInvisibleDueToOcclusion(),
this::calculateStateFromSceneFramework),
this::onStatusBarStateChanged);
@@ -677,10 +684,15 @@ public class StatusBarStateControllerImpl implements
private int calculateStateFromSceneFramework(
DeviceUnlockStatus deviceUnlockStatus,
SceneKey currentScene,
+ SceneStack backStack,
boolean isOccluded) {
SceneContainerFlag.isUnexpectedlyInLegacyMode();
-
- if (deviceUnlockStatus.isUnlocked() || isOccluded) {
+ if (currentScene.equals(Scenes.Lockscreen)) {
+ return StatusBarState.KEYGUARD;
+ } else if (currentScene.equals(Scenes.Shade)
+ && SceneStackKt.contains(backStack, Scenes.Lockscreen)) {
+ return StatusBarState.SHADE_LOCKED;
+ } else if (deviceUnlockStatus.isUnlocked() || isOccluded) {
return StatusBarState.SHADE;
} else {
return Preconditions.checkNotNull(sStatusBarStateByLockedSceneKey.get(currentScene));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 0e4be8ecc920..8f187f0274f0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -1487,7 +1487,14 @@ public class NotificationStackScrollLayout
private float updateStackEndHeight() {
if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f;
- float height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop());
+ final float height;
+ if (mMaxDisplayedNotifications != -1) {
+ // The stack intrinsic height already contains the correct value when there is a limit
+ // in the max number of notifications (e.g. as in keyguard).
+ height = mIntrinsicContentHeight;
+ } else {
+ height = Math.max(0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop());
+ }
mAmbientState.setStackEndHeight(height);
return height;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
index 8125ef55f4af..523d15c7548f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
@@ -468,7 +468,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
() -> mKosmos.getDeviceUnlockedInteractor(),
() -> mKosmos.getSceneInteractor(),
() -> mKosmos.getSceneContainerOcclusionInteractor(),
- () -> mKosmos.getKeyguardClockInteractor());
+ () -> mKosmos.getKeyguardClockInteractor(),
+ () -> mKosmos.getSceneBackInteractor());
KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext);
keyguardStatusView.setId(R.id.keyguard_status_view);
@@ -625,7 +626,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
() -> mKosmos.getDeviceUnlockedInteractor(),
() -> mKosmos.getSceneInteractor(),
() -> mKosmos.getSceneContainerOcclusionInteractor(),
- () -> mKosmos.getKeyguardClockInteractor()),
+ () -> mKosmos.getKeyguardClockInteractor(),
+ () -> mKosmos.getSceneBackInteractor()),
mKeyguardBypassController,
mDozeParameters,
mScreenOffAnimationController,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
index 22b98874c7ef..1717f4c069f4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java
@@ -354,6 +354,20 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
}
@Test
+ @EnableSceneContainer
+ public void updateStackEndHeightAndStackHeight_maxNotificationsSet_withSceneContainer() {
+ float stackHeight = 300f;
+ when(mStackSizeCalculator.computeHeight(eq(mStackScroller), anyInt(), anyFloat()))
+ .thenReturn(stackHeight);
+ mStackScroller.setMaxDisplayedNotifications(3); // any non-zero amount
+
+ clearInvocations(mAmbientState);
+ mStackScroller.updateStackEndHeightAndStackHeight(1f);
+
+ verify(mAmbientState).setStackHeight(eq(300f));
+ }
+
+ @Test
public void updateStackEndHeightAndStackHeight_onlyUpdatesStackHeightDuringSwipeUp() {
final float expansionFraction = 0.5f;
mAmbientState.setStatusBarState(StatusBarState.KEYGUARD);
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
index e6bd24b6b99a..9fe66eb77feb 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
@@ -50,6 +50,7 @@ import com.android.systemui.model.sceneContainerPlugin
import com.android.systemui.plugins.statusbar.statusBarStateController
import com.android.systemui.power.data.repository.fakePowerRepository
import com.android.systemui.power.domain.interactor.powerInteractor
+import com.android.systemui.scene.domain.interactor.sceneBackInteractor
import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.domain.startable.scrimStartable
@@ -115,6 +116,7 @@ class KosmosJavaAdapter() {
val interactionJankMonitor by lazy { kosmos.interactionJankMonitor }
val fakeSceneContainerConfig by lazy { kosmos.sceneContainerConfig }
val sceneInteractor by lazy { kosmos.sceneInteractor }
+ val sceneBackInteractor by lazy { kosmos.sceneBackInteractor }
val falsingCollector by lazy { kosmos.falsingCollector }
val powerInteractor by lazy { kosmos.powerInteractor }
val deviceEntryInteractor by lazy { kosmos.deviceEntryInteractor }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt
index f9f8d232611e..2deeb253e925 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/plugins/statusbar/StatusBarStateControllerKosmos.kt
@@ -22,6 +22,7 @@ import com.android.systemui.jank.interactionJankMonitor
import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.scene.domain.interactor.sceneBackInteractor
import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
@@ -41,5 +42,6 @@ var Kosmos.statusBarStateController: SysuiStatusBarStateController by
{ sceneInteractor },
{ sceneContainerOcclusionInteractor },
{ keyguardClockInteractor },
+ { sceneBackInteractor },
)
}