Merge "When a shortcut is deleted remove it from xml as well" into sc-v2-dev

This commit is contained in:
Mady Mellor
2021-11-03 16:20:09 +00:00
committed by Android (Google) Code Review
4 changed files with 63 additions and 1 deletions

View File

@@ -1137,7 +1137,8 @@ public class BubbleController {
if (reason == DISMISS_USER_CHANGED || reason == DISMISS_NO_BUBBLE_UP) { if (reason == DISMISS_USER_CHANGED || reason == DISMISS_NO_BUBBLE_UP) {
continue; continue;
} }
if (reason == DISMISS_NOTIF_CANCEL) { if (reason == DISMISS_NOTIF_CANCEL
|| reason == DISMISS_SHORTCUT_REMOVED) {
bubblesToBeRemovedFromRepository.add(bubble); bubblesToBeRemovedFromRepository.add(bubble);
} }
if (!mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) { if (!mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) {

View File

@@ -254,6 +254,22 @@ public class NotificationTestHelper {
return row; return row;
} }
/**
* Returns an {@link ExpandableNotificationRow} that should be shown as a bubble.
*/
public ExpandableNotificationRow createShortcutBubble(String shortcutId)
throws Exception {
Notification n = createNotification(false /* isGroupSummary */,
null /* groupKey */, makeShortcutBubbleMetadata(shortcutId));
n.flags |= FLAG_BUBBLE;
ExpandableNotificationRow row = generateRow(n, PKG, UID, USER_HANDLE,
0 /* extraInflationFlags */, IMPORTANCE_HIGH);
modifyRanking(row.getEntry())
.setCanBubble(true)
.build();
return row;
}
/** /**
* Returns an {@link ExpandableNotificationRow} that should be shown as a bubble and is part * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble and is part
* of a group of notifications. * of a group of notifications.
@@ -506,6 +522,12 @@ public class NotificationTestHelper {
.build(); .build();
} }
private BubbleMetadata makeShortcutBubbleMetadata(String shortcutId) {
return new BubbleMetadata.Builder(shortcutId)
.setDesiredHeight(314)
.build();
}
private static class MockSmartReplyInflater implements SmartReplyStateInflater { private static class MockSmartReplyInflater implements SmartReplyStateInflater {
@Override @Override
public InflatedSmartReplyState inflateSmartReplyState(NotificationEntry entry) { public InflatedSmartReplyState inflateSmartReplyState(NotificationEntry entry) {

View File

@@ -185,6 +185,8 @@ public class BubblesTest extends SysuiTestCase {
private ArgumentCaptor<NotificationEntryListener> mEntryListenerCaptor; private ArgumentCaptor<NotificationEntryListener> mEntryListenerCaptor;
@Captor @Captor
private ArgumentCaptor<NotificationRemoveInterceptor> mRemoveInterceptorCaptor; private ArgumentCaptor<NotificationRemoveInterceptor> mRemoveInterceptorCaptor;
@Captor
private ArgumentCaptor<List<Bubble>> mBubbleListCaptor;
private BubblesManager mBubblesManager; private BubblesManager mBubblesManager;
// TODO(178618782): Move tests on the controller directly to the shell // TODO(178618782): Move tests on the controller directly to the shell
@@ -1165,6 +1167,22 @@ public class BubblesTest extends SysuiTestCase {
verify(mDataRepository, times(1)).loadBubbles(anyInt(), any()); verify(mDataRepository, times(1)).loadBubbles(anyInt(), any());
} }
/**
* Verifies that shortcut deletions triggers that bubble being removed from XML.
*/
@Test
public void testDeleteShortcutsDeletesXml() throws Exception {
ExpandableNotificationRow row = mNotificationTestHelper.createShortcutBubble("shortcutId");
BubbleEntry shortcutBubbleEntry = BubblesManager.notifToBubbleEntry(row.getEntry());
mBubbleController.updateBubble(shortcutBubbleEntry);
mBubbleData.dismissBubbleWithKey(shortcutBubbleEntry.getKey(),
Bubbles.DISMISS_SHORTCUT_REMOVED);
verify(mDataRepository, atLeastOnce()).removeBubbles(anyInt(), mBubbleListCaptor.capture());
assertThat(mBubbleListCaptor.getValue().get(0).getKey()).isEqualTo(
shortcutBubbleEntry.getKey());
}
/** /**
* Verifies that the package manager for the user is used when loading info for the bubble. * Verifies that the package manager for the user is used when loading info for the bubble.

View File

@@ -93,6 +93,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.ZenModeController; import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.WindowManagerShellWrapper; import com.android.wm.shell.WindowManagerShellWrapper;
import com.android.wm.shell.bubbles.Bubble;
import com.android.wm.shell.bubbles.BubbleData; import com.android.wm.shell.bubbles.BubbleData;
import com.android.wm.shell.bubbles.BubbleDataRepository; import com.android.wm.shell.bubbles.BubbleDataRepository;
import com.android.wm.shell.bubbles.BubbleEntry; import com.android.wm.shell.bubbles.BubbleEntry;
@@ -167,6 +168,9 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
@Captor @Captor
private ArgumentCaptor<NotifCollectionListener> mNotifListenerCaptor; private ArgumentCaptor<NotifCollectionListener> mNotifListenerCaptor;
@Captor
private ArgumentCaptor<List<Bubble>> mBubbleListCaptor;
private BubblesManager mBubblesManager; private BubblesManager mBubblesManager;
private TestableBubbleController mBubbleController; private TestableBubbleController mBubbleController;
private NotificationShadeWindowControllerImpl mNotificationShadeWindowController; private NotificationShadeWindowControllerImpl mNotificationShadeWindowController;
@@ -1013,6 +1017,23 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
verify(mDataRepository, times(1)).loadBubbles(anyInt(), any()); verify(mDataRepository, times(1)).loadBubbles(anyInt(), any());
} }
/**
* Verifies that shortcut deletions triggers that bubble being removed from XML.
*/
@Test
public void testDeleteShortcutsDeletesXml() throws Exception {
ExpandableNotificationRow row = mNotificationTestHelper.createShortcutBubble("shortcutId");
BubbleEntry shortcutBubbleEntry = BubblesManager.notifToBubbleEntry(row.getEntry());
mBubbleController.updateBubble(shortcutBubbleEntry);
mBubbleData.dismissBubbleWithKey(shortcutBubbleEntry.getKey(),
Bubbles.DISMISS_SHORTCUT_REMOVED);
verify(mDataRepository, atLeastOnce()).removeBubbles(anyInt(), mBubbleListCaptor.capture());
assertThat(mBubbleListCaptor.getValue().get(0).getKey()).isEqualTo(
shortcutBubbleEntry.getKey());
}
@Test @Test
public void testShowManageMenuChangesSysuiState() { public void testShowManageMenuChangesSysuiState() {
mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry);