Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +6 −1 Original line number Original line Diff line number Diff line Loading @@ -475,8 +475,13 @@ public class BubbleController implements ConfigurationChangeListener { @VisibleForTesting @VisibleForTesting public void onStatusBarStateChanged(boolean isShade) { public void onStatusBarStateChanged(boolean isShade) { boolean didChange = mIsStatusBarShade != isShade; if (DEBUG_BUBBLE_CONTROLLER) { Log.d(TAG, "onStatusBarStateChanged isShade=" + isShade + " didChange=" + didChange); } mIsStatusBarShade = isShade; mIsStatusBarShade = isShade; if (!mIsStatusBarShade) { if (!mIsStatusBarShade && didChange) { // Only collapse stack on change collapseStack(); collapseStack(); } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java +17 −5 Original line number Original line Diff line number Diff line Loading @@ -301,7 +301,8 @@ public class NotificationTestHelper { public ExpandableNotificationRow createBubble() public ExpandableNotificationRow createBubble() throws Exception { throws Exception { Notification n = createNotification(false /* isGroupSummary */, Notification n = createNotification(false /* isGroupSummary */, null /* groupKey */, makeBubbleMetadata(null)); null /* groupKey */, makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */)); n.flags |= FLAG_BUBBLE; n.flags |= FLAG_BUBBLE; ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, mDefaultInflationFlags, IMPORTANCE_HIGH); mDefaultInflationFlags, IMPORTANCE_HIGH); Loading Loading @@ -334,7 +335,8 @@ public class NotificationTestHelper { public ExpandableNotificationRow createBubbleInGroup() public ExpandableNotificationRow createBubbleInGroup() throws Exception { throws Exception { Notification n = createNotification(false /* isGroupSummary */, Notification n = createNotification(false /* isGroupSummary */, GROUP_KEY /* groupKey */, makeBubbleMetadata(null)); GROUP_KEY /* groupKey */, makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */)); n.flags |= FLAG_BUBBLE; n.flags |= FLAG_BUBBLE; ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, mDefaultInflationFlags, IMPORTANCE_HIGH); mDefaultInflationFlags, IMPORTANCE_HIGH); Loading @@ -350,7 +352,7 @@ public class NotificationTestHelper { * @param deleteIntent the intent to assign to {@link BubbleMetadata#deleteIntent} * @param deleteIntent the intent to assign to {@link BubbleMetadata#deleteIntent} */ */ public NotificationEntry createBubble(@Nullable PendingIntent deleteIntent) { public NotificationEntry createBubble(@Nullable PendingIntent deleteIntent) { return createBubble(makeBubbleMetadata(deleteIntent), USER_HANDLE); return createBubble(makeBubbleMetadata(deleteIntent, false /* autoExpand */), USER_HANDLE); } } /** /** Loading @@ -359,7 +361,16 @@ public class NotificationTestHelper { * @param handle the user to associate with this bubble. * @param handle the user to associate with this bubble. */ */ public NotificationEntry createBubble(UserHandle handle) { public NotificationEntry createBubble(UserHandle handle) { return createBubble(makeBubbleMetadata(null), handle); return createBubble(makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */), handle); } /** * Returns an {@link NotificationEntry} that should be shown as a auto-expanded bubble. */ public NotificationEntry createAutoExpandedBubble() { return createBubble(makeBubbleMetadata(null /* deleteIntent */, true /* autoExpand */), USER_HANDLE); } } /** /** Loading Loading @@ -567,7 +578,7 @@ public class NotificationTestHelper { assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS)); assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS)); } } private BubbleMetadata makeBubbleMetadata(PendingIntent deleteIntent) { private BubbleMetadata makeBubbleMetadata(PendingIntent deleteIntent, boolean autoExpand) { Intent target = new Intent(mContext, BubblesTestActivity.class); Intent target = new Intent(mContext, BubblesTestActivity.class); PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, PendingIntent.FLAG_MUTABLE); PendingIntent.FLAG_MUTABLE); Loading @@ -576,6 +587,7 @@ public class NotificationTestHelper { Icon.createWithResource(mContext, R.drawable.android)) Icon.createWithResource(mContext, R.drawable.android)) .setDeleteIntent(deleteIntent) .setDeleteIntent(deleteIntent) .setDesiredHeight(314) .setDesiredHeight(314) .setAutoExpandBubble(autoExpand) .build(); .build(); } } Loading packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +31 −1 Original line number Original line Diff line number Diff line Loading @@ -1423,13 +1423,43 @@ public class BubblesTest extends SysuiTestCase { assertStackCollapsed(); assertStackCollapsed(); // Post status bar state change update with the same value // Post status bar state change update with the same value mBubbleController.onStatusBarStateChanged(false); mBubbleController.onStatusBarStateChanged(false); // Stack should remain collapsedb // Stack should remain collapsed assertStackCollapsed(); assertStackCollapsed(); // Post status bar state change which should trigger bubble to expand // Post status bar state change which should trigger bubble to expand mBubbleController.onStatusBarStateChanged(true); mBubbleController.onStatusBarStateChanged(true); assertStackExpanded(); assertStackExpanded(); } } /** * Test to verify behavior for the following scenario: * <ol> * <li>device is locked with keyguard on, status bar shade state updates to * <code>false</code></li> * <li>notification entry is marked to be a bubble and it is set to auto-expand</li> * <li>device unlock starts, status bar shade state receives another update to * <code>false</code></li> * <li>device is unlocked and status bar shade state is set to <code>true</code></li> * <li>bubble should be expanded</li> * </ol> */ @Test public void testOnStatusBarStateChanged_newAutoExpandedBubbleRemainsExpanded() { // Set device as locked mBubbleController.onStatusBarStateChanged(false); // Create a auto-expanded bubble NotificationEntry entry = mNotificationTestHelper.createAutoExpandedBubble(); mEntryListener.onEntryAdded(entry); // When unlocking, we may receive duplicate updates with shade=false, ensure they don't // clear the expanded state mBubbleController.onStatusBarStateChanged(false); mBubbleController.onStatusBarStateChanged(true); // After unlocking, stack should be expanded assertStackExpanded(); } @Test @Test public void testSetShouldAutoExpand_notifiesFlagChanged() { public void testSetShouldAutoExpand_notifiesFlagChanged() { mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +6 −1 Original line number Original line Diff line number Diff line Loading @@ -475,8 +475,13 @@ public class BubbleController implements ConfigurationChangeListener { @VisibleForTesting @VisibleForTesting public void onStatusBarStateChanged(boolean isShade) { public void onStatusBarStateChanged(boolean isShade) { boolean didChange = mIsStatusBarShade != isShade; if (DEBUG_BUBBLE_CONTROLLER) { Log.d(TAG, "onStatusBarStateChanged isShade=" + isShade + " didChange=" + didChange); } mIsStatusBarShade = isShade; mIsStatusBarShade = isShade; if (!mIsStatusBarShade) { if (!mIsStatusBarShade && didChange) { // Only collapse stack on change collapseStack(); collapseStack(); } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationTestHelper.java +17 −5 Original line number Original line Diff line number Diff line Loading @@ -301,7 +301,8 @@ public class NotificationTestHelper { public ExpandableNotificationRow createBubble() public ExpandableNotificationRow createBubble() throws Exception { throws Exception { Notification n = createNotification(false /* isGroupSummary */, Notification n = createNotification(false /* isGroupSummary */, null /* groupKey */, makeBubbleMetadata(null)); null /* groupKey */, makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */)); n.flags |= FLAG_BUBBLE; n.flags |= FLAG_BUBBLE; ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, mDefaultInflationFlags, IMPORTANCE_HIGH); mDefaultInflationFlags, IMPORTANCE_HIGH); Loading Loading @@ -334,7 +335,8 @@ public class NotificationTestHelper { public ExpandableNotificationRow createBubbleInGroup() public ExpandableNotificationRow createBubbleInGroup() throws Exception { throws Exception { Notification n = createNotification(false /* isGroupSummary */, Notification n = createNotification(false /* isGroupSummary */, GROUP_KEY /* groupKey */, makeBubbleMetadata(null)); GROUP_KEY /* groupKey */, makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */)); n.flags |= FLAG_BUBBLE; n.flags |= FLAG_BUBBLE; ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE, mDefaultInflationFlags, IMPORTANCE_HIGH); mDefaultInflationFlags, IMPORTANCE_HIGH); Loading @@ -350,7 +352,7 @@ public class NotificationTestHelper { * @param deleteIntent the intent to assign to {@link BubbleMetadata#deleteIntent} * @param deleteIntent the intent to assign to {@link BubbleMetadata#deleteIntent} */ */ public NotificationEntry createBubble(@Nullable PendingIntent deleteIntent) { public NotificationEntry createBubble(@Nullable PendingIntent deleteIntent) { return createBubble(makeBubbleMetadata(deleteIntent), USER_HANDLE); return createBubble(makeBubbleMetadata(deleteIntent, false /* autoExpand */), USER_HANDLE); } } /** /** Loading @@ -359,7 +361,16 @@ public class NotificationTestHelper { * @param handle the user to associate with this bubble. * @param handle the user to associate with this bubble. */ */ public NotificationEntry createBubble(UserHandle handle) { public NotificationEntry createBubble(UserHandle handle) { return createBubble(makeBubbleMetadata(null), handle); return createBubble(makeBubbleMetadata(null /* deleteIntent */, false /* autoExpand */), handle); } /** * Returns an {@link NotificationEntry} that should be shown as a auto-expanded bubble. */ public NotificationEntry createAutoExpandedBubble() { return createBubble(makeBubbleMetadata(null /* deleteIntent */, true /* autoExpand */), USER_HANDLE); } } /** /** Loading Loading @@ -567,7 +578,7 @@ public class NotificationTestHelper { assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS)); assertTrue(countDownLatch.await(500, TimeUnit.MILLISECONDS)); } } private BubbleMetadata makeBubbleMetadata(PendingIntent deleteIntent) { private BubbleMetadata makeBubbleMetadata(PendingIntent deleteIntent, boolean autoExpand) { Intent target = new Intent(mContext, BubblesTestActivity.class); Intent target = new Intent(mContext, BubblesTestActivity.class); PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, PendingIntent.FLAG_MUTABLE); PendingIntent.FLAG_MUTABLE); Loading @@ -576,6 +587,7 @@ public class NotificationTestHelper { Icon.createWithResource(mContext, R.drawable.android)) Icon.createWithResource(mContext, R.drawable.android)) .setDeleteIntent(deleteIntent) .setDeleteIntent(deleteIntent) .setDesiredHeight(314) .setDesiredHeight(314) .setAutoExpandBubble(autoExpand) .build(); .build(); } } Loading
packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +31 −1 Original line number Original line Diff line number Diff line Loading @@ -1423,13 +1423,43 @@ public class BubblesTest extends SysuiTestCase { assertStackCollapsed(); assertStackCollapsed(); // Post status bar state change update with the same value // Post status bar state change update with the same value mBubbleController.onStatusBarStateChanged(false); mBubbleController.onStatusBarStateChanged(false); // Stack should remain collapsedb // Stack should remain collapsed assertStackCollapsed(); assertStackCollapsed(); // Post status bar state change which should trigger bubble to expand // Post status bar state change which should trigger bubble to expand mBubbleController.onStatusBarStateChanged(true); mBubbleController.onStatusBarStateChanged(true); assertStackExpanded(); assertStackExpanded(); } } /** * Test to verify behavior for the following scenario: * <ol> * <li>device is locked with keyguard on, status bar shade state updates to * <code>false</code></li> * <li>notification entry is marked to be a bubble and it is set to auto-expand</li> * <li>device unlock starts, status bar shade state receives another update to * <code>false</code></li> * <li>device is unlocked and status bar shade state is set to <code>true</code></li> * <li>bubble should be expanded</li> * </ol> */ @Test public void testOnStatusBarStateChanged_newAutoExpandedBubbleRemainsExpanded() { // Set device as locked mBubbleController.onStatusBarStateChanged(false); // Create a auto-expanded bubble NotificationEntry entry = mNotificationTestHelper.createAutoExpandedBubble(); mEntryListener.onEntryAdded(entry); // When unlocking, we may receive duplicate updates with shade=false, ensure they don't // clear the expanded state mBubbleController.onStatusBarStateChanged(false); mBubbleController.onStatusBarStateChanged(true); // After unlocking, stack should be expanded assertStackExpanded(); } @Test @Test public void testSetShouldAutoExpand_notifiesFlagChanged() { public void testSetShouldAutoExpand_notifiesFlagChanged() { mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry); Loading