summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java15
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java2
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java127
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java100
7 files changed, 223 insertions, 44 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
index d590ab112aae..300319a2f78f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
@@ -120,8 +120,6 @@ public class BubbleStackView extends FrameLayout
private static final int EXPANDED_VIEW_ALPHA_ANIMATION_DURATION = 150;
- private static final int MANAGE_MENU_SCRIM_ANIM_DURATION = 150;
-
private static final float SCRIM_ALPHA = 0.6f;
/**
@@ -894,6 +892,7 @@ public class BubbleStackView extends FrameLayout
updatePointerPosition(false /* forIme */);
mExpandedAnimationController.expandFromStack(() -> {
afterExpandedViewAnimation();
+ showManageMenu(mShowingManage);
} /* after */);
final float translationY = mPositioner.getExpandedViewY(mExpandedBubble,
getBubbleIndex(mExpandedBubble));
@@ -1253,9 +1252,6 @@ public class BubbleStackView extends FrameLayout
mRelativeStackPositionBeforeRotation = new RelativeStackPosition(
mPositioner.getRestingPosition(),
mStackAnimationController.getAllowableStackPositionRegion());
- mManageMenu.setVisibility(View.INVISIBLE);
- mShowingManage = false;
-
addOnLayoutChangeListener(mOrientationChangedListener);
hideFlyoutImmediate();
}
@@ -2555,16 +2551,19 @@ public class BubbleStackView extends FrameLayout
invalidate();
}
- private void showManageMenu(boolean show) {
+ /** Hide or show the manage menu for the currently expanded bubble. */
+ @VisibleForTesting
+ public void showManageMenu(boolean show) {
mShowingManage = show;
// This should not happen, since the manage menu is only visible when there's an expanded
// bubble. If we end up in this state, just hide the menu immediately.
if (mExpandedBubble == null || mExpandedBubble.getExpandedView() == null) {
mManageMenu.setVisibility(View.INVISIBLE);
+ mManageMenuScrim.setVisibility(INVISIBLE);
+ mBubbleController.getSysuiProxy().onManageMenuExpandChanged(false /* show */);
return;
}
-
if (show) {
mManageMenuScrim.setVisibility(VISIBLE);
mManageMenuScrim.setTranslationZ(mManageMenu.getElevation() - 1f);
@@ -2576,8 +2575,8 @@ public class BubbleStackView extends FrameLayout
}
};
+ mBubbleController.getSysuiProxy().onManageMenuExpandChanged(show);
mManageMenuScrim.animate()
- .setDuration(MANAGE_MENU_SCRIM_ANIM_DURATION)
.setInterpolator(show ? ALPHA_IN : ALPHA_OUT)
.alpha(show ? SCRIM_ALPHA : 0f)
.withEndAction(endAction)
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java
index 9b7eb2f1cfb3..c82249b8a369 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java
@@ -284,6 +284,8 @@ public interface Bubbles {
void onStackExpandChanged(boolean shouldExpand);
+ void onManageMenuExpandChanged(boolean menuExpanded);
+
void onUnbubbleConversation(String key);
}
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java
index 196e6f335b14..d447b485f33b 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java
@@ -118,6 +118,8 @@ public class QuickStepContract {
public static final int SYSUI_STATE_DEVICE_DOZING = 1 << 21;
// The home feature is disabled (either by SUW/SysUI/device policy)
public static final int SYSUI_STATE_BACK_DISABLED = 1 << 22;
+ // The bubble stack is expanded AND the mange menu for bubbles is expanded on top of it.
+ public static final int SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED = 1 << 23;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SYSUI_STATE_SCREEN_PINNING,
@@ -142,7 +144,8 @@ public class QuickStepContract {
SYSUI_STATE_MAGNIFICATION_OVERLAP,
SYSUI_STATE_IME_SWITCHER_SHOWING,
SYSUI_STATE_DEVICE_DOZING,
- SYSUI_STATE_BACK_DISABLED
+ SYSUI_STATE_BACK_DISABLED,
+ SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED
})
public @interface SystemUiStateFlags {}
@@ -174,6 +177,8 @@ public class QuickStepContract {
str.add((flags & SYSUI_STATE_IME_SWITCHER_SHOWING) != 0 ? "ime_switcher_showing" : "");
str.add((flags & SYSUI_STATE_DEVICE_DOZING) != 0 ? "device_dozing" : "");
str.add((flags & SYSUI_STATE_BACK_DISABLED) != 0 ? "back_disabled" : "");
+ str.add((flags & SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0
+ ? "bubbles_mange_menu_expanded" : "");
return str.toString();
}
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java
index d3581a9fd177..291c64dd6daf 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/BubblesManager.java
@@ -377,10 +377,24 @@ public class BubblesManager implements Dumpable {
sysuiMainExecutor.execute(() -> {
sysUiState.setFlag(QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED, shouldExpand)
.commitUpdate(mContext.getDisplayId());
+ if (!shouldExpand) {
+ sysUiState.setFlag(
+ QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED,
+ false).commitUpdate(mContext.getDisplayId());
+ }
});
}
@Override
+ public void onManageMenuExpandChanged(boolean menuExpanded) {
+ sysuiMainExecutor.execute(() -> {
+ sysUiState.setFlag(QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED,
+ menuExpanded).commitUpdate(mContext.getDisplayId());
+ });
+ }
+
+
+ @Override
public void onUnbubbleConversation(String key) {
sysuiMainExecutor.execute(() -> {
final NotificationEntry entry =
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java
index c776ab9bda1d..74611cce6f87 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java
@@ -20,6 +20,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_GLOBAL_ACTIONS_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ONE_HANDED_ACTIVE;
@@ -101,6 +102,7 @@ public final class WMShell extends SystemUI
| SYSUI_STATE_BOUNCER_SHOWING
| SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
| SYSUI_STATE_BUBBLES_EXPANDED
+ | SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
// Shell interfaces
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
index 9f755f7be2c7..1159e0912926 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
@@ -179,6 +179,7 @@ public class BubblesTest extends SysuiTestCase {
private SysUiState mSysUiState;
private boolean mSysUiStateBubblesExpanded;
+ private boolean mSysUiStateBubblesManageMenuExpanded;
@Captor
private ArgumentCaptor<NotificationEntryListener> mEntryListenerCaptor;
@@ -295,9 +296,13 @@ public class BubblesTest extends SysuiTestCase {
when(mZenModeController.getConfig()).thenReturn(mZenModeConfig);
mSysUiState = new SysUiState();
- mSysUiState.addCallback(sysUiFlags ->
- mSysUiStateBubblesExpanded =
- (sysUiFlags & QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED) != 0);
+ mSysUiState.addCallback(sysUiFlags -> {
+ mSysUiStateBubblesManageMenuExpanded =
+ (sysUiFlags
+ & QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
+ mSysUiStateBubblesExpanded =
+ (sysUiFlags & QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED) != 0;
+ });
// TODO: Fix
mPositioner = new TestableBubblePositioner(mContext, mWindowManager);
@@ -372,8 +377,7 @@ public class BubblesTest extends SysuiTestCase {
public void testAddBubble() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
-
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -381,7 +385,7 @@ public class BubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.hasBubbles());
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -396,7 +400,7 @@ public class BubblesTest extends SysuiTestCase {
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
verify(mNotificationEntryManager, times(2)).updateNotifications(anyString());
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -459,7 +463,7 @@ public class BubblesTest extends SysuiTestCase {
verify(mNotificationEntryManager, never()).performRemoveNotification(
eq(mRow.getSbn()), any(), anyInt());
assertFalse(mBubbleController.hasBubbles());
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
assertTrue(mRow.isBubble());
}
@@ -478,7 +482,7 @@ public class BubblesTest extends SysuiTestCase {
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
assertNull(mBubbleData.getBubbleInStackWithKey(mRow2.getKey()));
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -498,8 +502,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
-
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Make sure the notif is suppressed
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -508,8 +511,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleController.collapseStack();
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertStackCollapsed();
-
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -532,8 +534,7 @@ public class BubblesTest extends SysuiTestCase {
assertStackExpanded();
verify(mBubbleExpandListener, atLeastOnce()).onBubbleExpandChanged(
true, mRow2.getKey());
-
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Last added is the one that is expanded
assertEquals(mRow2.getKey(), mBubbleData.getSelectedBubble().getKey());
@@ -557,8 +558,7 @@ public class BubblesTest extends SysuiTestCase {
// Collapse
mBubbleController.collapseStack();
assertStackCollapsed();
-
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -578,8 +578,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
-
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -604,8 +603,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
-
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -634,7 +632,7 @@ public class BubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getKey());
@@ -666,7 +664,7 @@ public class BubblesTest extends SysuiTestCase {
assertEquals(mBubbleData.getSelectedBubble().getKey(), BubbleOverflow.KEY);
verify(mBubbleExpandListener).onBubbleExpandChanged(true, BubbleOverflow.KEY);
assertTrue(mBubbleController.hasBubbles());
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -679,7 +677,7 @@ public class BubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
@@ -694,7 +692,7 @@ public class BubblesTest extends SysuiTestCase {
// We should be collapsed
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertFalse(mBubbleController.hasBubbles());
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -711,8 +709,7 @@ public class BubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener, never()).onBubbleExpandChanged(false /* expanded */,
mRow.getKey());
assertStackCollapsed();
-
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -728,8 +725,7 @@ public class BubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener).onBubbleExpandChanged(true /* expanded */,
mRow.getKey());
assertStackExpanded();
-
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -746,8 +742,7 @@ public class BubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
-
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -769,8 +764,7 @@ public class BubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
-
- assertFalse(mSysUiStateBubblesExpanded);
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -784,7 +778,7 @@ public class BubblesTest extends SysuiTestCase {
mBubbleController.expandStackAndSelectBubble(mBubbleEntry);
- assertTrue(mSysUiStateBubblesExpanded);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -1206,6 +1200,63 @@ public class BubblesTest extends SysuiTestCase {
assertNotNull(info);
}
+ @Test
+ public void testShowManageMenuChangesSysuiState() {
+ mBubbleController.updateBubble(mBubbleEntry);
+ assertTrue(mBubbleController.hasBubbles());
+
+ // Expand the stack
+ BubbleStackView stackView = mBubbleController.getStackView();
+ mBubbleData.setExpanded(true);
+ assertStackExpanded();
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+
+ // Show the menu
+ stackView.showManageMenu(true);
+ assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
+ }
+
+ @Test
+ public void testHideManageMenuChangesSysuiState() {
+ mBubbleController.updateBubble(mBubbleEntry);
+ assertTrue(mBubbleController.hasBubbles());
+
+ // Expand the stack
+ BubbleStackView stackView = mBubbleController.getStackView();
+ mBubbleData.setExpanded(true);
+ assertStackExpanded();
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+
+ // Show the menu
+ stackView.showManageMenu(true);
+ assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
+
+ // Hide the menu
+ stackView.showManageMenu(false);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+ }
+
+ @Test
+ public void testCollapseBubbleManageMenuChangesSysuiState() {
+ mBubbleController.updateBubble(mBubbleEntry);
+ assertTrue(mBubbleController.hasBubbles());
+
+ // Expand the stack
+ BubbleStackView stackView = mBubbleController.getStackView();
+ mBubbleData.setExpanded(true);
+ assertStackExpanded();
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+
+ // Show the menu
+ stackView.showManageMenu(true);
+ assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
+
+ // Collapse the stack
+ mBubbleData.setExpanded(false);
+
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
+ }
+
/** Creates a bubble using the userId and package. */
private Bubble createBubble(int userId, String pkg) {
final UserHandle userHandle = new UserHandle(userId);
@@ -1303,4 +1354,12 @@ public class BubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.getImplCachedState().isBubbleNotificationSuppressedFromShade(
entry.getKey(), entry.getGroupKey()));
}
+
+ /**
+ * Asserts that the system ui states associated to bubbles are in the correct state.
+ */
+ private void assertSysuiStates(boolean stackExpanded, boolean manageMenuExpanded) {
+ assertThat(mSysUiStateBubblesExpanded).isEqualTo(stackExpanded);
+ assertThat(mSysUiStateBubblesManageMenuExpanded).isEqualTo(manageMenuExpanded);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java
index a3bbb26c6b23..05c4822f288e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/NewNotifPipelineBubblesTest.java
@@ -68,6 +68,7 @@ import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.model.SysUiState;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
@@ -160,7 +161,9 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
@Mock
private AuthController mAuthController;
- private SysUiState mSysUiState = new SysUiState();
+ private SysUiState mSysUiState;
+ private boolean mSysUiStateBubblesExpanded;
+ private boolean mSysUiStateBubblesManageMenuExpanded;
@Captor
private ArgumentCaptor<NotifCollectionListener> mNotifListenerCaptor;
@@ -257,6 +260,15 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mZenModeConfig.suppressedVisualEffects = 0;
when(mZenModeController.getConfig()).thenReturn(mZenModeConfig);
+ mSysUiState = new SysUiState();
+ mSysUiState.addCallback(sysUiFlags -> {
+ mSysUiStateBubblesManageMenuExpanded =
+ (sysUiFlags
+ & QuickStepContract.SYSUI_STATE_BUBBLES_MANAGE_MENU_EXPANDED) != 0;
+ mSysUiStateBubblesExpanded =
+ (sysUiFlags & QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED) != 0;
+ });
+
mPositioner = new TestableBubblePositioner(mContext, mWindowManager);
mPositioner.setMaxBubbles(5);
mBubbleData = new BubbleData(mContext, mBubbleLogger, mPositioner, syncExecutor);
@@ -325,6 +337,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
public void testAddBubble() {
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -332,6 +345,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.hasBubbles());
mBubbleController.updateBubble(mBubbleEntry);
assertTrue(mBubbleController.hasBubbles());
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -345,6 +359,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mRow.getKey(), Bubbles.DISMISS_USER_GESTURE);
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
verify(mNotifCallback, times(2)).invalidateNotifications(anyString());
+
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -407,6 +423,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mNotifCallback, times(3)).invalidateNotifications(anyString());
assertNull(mBubbleData.getBubbleInStackWithKey(mRow.getKey()));
assertNull(mBubbleData.getBubbleInStackWithKey(mRow2.getKey()));
+
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -425,6 +443,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Make sure the notif is suppressed
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -433,6 +452,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleController.collapseStack();
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertStackCollapsed();
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -455,6 +475,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertStackExpanded();
verify(mBubbleExpandListener, atLeastOnce()).onBubbleExpandChanged(
true, mRow2.getKey());
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Last added is the one that is expanded
assertEquals(mRow2.getKey(), mBubbleData.getSelectedBubble().getKey());
@@ -479,6 +500,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// Collapse
mBubbleController.collapseStack();
assertStackCollapsed();
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -498,6 +520,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -522,6 +545,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
mBubbleData.setExpanded(true);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
// Notif is suppressed after expansion
assertBubbleNotificationSuppressedFromShade(mBubbleEntry);
@@ -550,6 +574,8 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow2.getKey());
@@ -580,6 +606,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertEquals(mBubbleData.getSelectedBubble().getKey(), BubbleOverflow.KEY);
verify(mBubbleExpandListener).onBubbleExpandChanged(true, BubbleOverflow.KEY);
assertTrue(mBubbleController.hasBubbles());
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -592,6 +619,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
BubbleStackView stackView = mBubbleController.getStackView();
mBubbleData.setExpanded(true);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
assertStackExpanded();
verify(mBubbleExpandListener).onBubbleExpandChanged(true, mRow.getKey());
@@ -606,6 +634,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// We should be collapsed
verify(mBubbleExpandListener).onBubbleExpandChanged(false, mRow.getKey());
assertFalse(mBubbleController.hasBubbles());
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@@ -623,6 +652,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener, never()).onBubbleExpandChanged(false /* expanded */,
mRow.getKey());
assertStackCollapsed();
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -638,6 +668,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mBubbleExpandListener).onBubbleExpandChanged(true /* expanded */,
mRow.getKey());
assertStackExpanded();
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -654,6 +685,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -675,6 +707,7 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
// Dot + flyout is hidden because notif is suppressed
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showDot());
assertFalse(mBubbleData.getBubbleInStackWithKey(mRow.getKey()).showFlyout());
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
}
@Test
@@ -980,6 +1013,63 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mDataRepository, times(1)).loadBubbles(anyInt(), any());
}
+ @Test
+ public void testShowManageMenuChangesSysuiState() {
+ mBubbleController.updateBubble(mBubbleEntry);
+ assertTrue(mBubbleController.hasBubbles());
+
+ // Expand the stack
+ BubbleStackView stackView = mBubbleController.getStackView();
+ mBubbleData.setExpanded(true);
+ assertStackExpanded();
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+
+ // Show the menu
+ stackView.showManageMenu(true);
+ assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
+ }
+
+ @Test
+ public void testHideManageMenuChangesSysuiState() {
+ mBubbleController.updateBubble(mBubbleEntry);
+ assertTrue(mBubbleController.hasBubbles());
+
+ // Expand the stack
+ BubbleStackView stackView = mBubbleController.getStackView();
+ mBubbleData.setExpanded(true);
+ assertStackExpanded();
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+
+ // Show the menu
+ stackView.showManageMenu(true);
+ assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
+
+ // Hide the menu
+ stackView.showManageMenu(false);
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+ }
+
+ @Test
+ public void testCollapseBubbleManageMenuChangesSysuiState() {
+ mBubbleController.updateBubble(mBubbleEntry);
+ assertTrue(mBubbleController.hasBubbles());
+
+ // Expand the stack
+ BubbleStackView stackView = mBubbleController.getStackView();
+ mBubbleData.setExpanded(true);
+ assertStackExpanded();
+ assertSysuiStates(true /* stackExpanded */, false /* mangeMenuExpanded */);
+
+ // Show the menu
+ stackView.showManageMenu(true);
+ assertSysuiStates(true /* stackExpanded */, true /* mangeMenuExpanded */);
+
+ // Collapse the stack
+ mBubbleData.setExpanded(false);
+
+ assertSysuiStates(false /* stackExpanded */, false /* mangeMenuExpanded */);
+ }
+
/**
* Sets the bubble metadata flags for this entry. These flags are normally set by
* NotificationManagerService when the notification is sent, however, these tests do not
@@ -1034,4 +1124,12 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
assertFalse(mBubbleController.getImplCachedState().isBubbleNotificationSuppressedFromShade(
entry.getKey(), entry.getGroupKey()));
}
+
+ /**
+ * Asserts that the system ui states associated to bubbles are in the correct state.
+ */
+ private void assertSysuiStates(boolean stackExpanded, boolean manageMenuExpanded) {
+ assertThat(mSysUiStateBubblesExpanded).isEqualTo(stackExpanded);
+ assertThat(mSysUiStateBubblesManageMenuExpanded).isEqualTo(manageMenuExpanded);
+ }
}