Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0031bbe7 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16168977

Change-Id: I472b0b0f1aa893eaf2799ed11c650414a1233fc5
parents 092705de 980e3e78
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1137,7 +1137,8 @@ public class BubbleController {
                if (reason == DISMISS_USER_CHANGED || reason == DISMISS_NO_BUBBLE_UP) {
                    continue;
                }
                if (reason == DISMISS_NOTIF_CANCEL) {
                if (reason == DISMISS_NOTIF_CANCEL
                        || reason == DISMISS_SHORTCUT_REMOVED) {
                    bubblesToBeRemovedFromRepository.add(bubble);
                }
                if (!mBubbleData.hasBubbleInStackWithKey(bubble.getKey())) {
+22 −0
Original line number Diff line number Diff line
@@ -254,6 +254,22 @@ public class NotificationTestHelper {
        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
     * of a group of notifications.
@@ -506,6 +522,12 @@ public class NotificationTestHelper {
                .build();
    }

    private BubbleMetadata makeShortcutBubbleMetadata(String shortcutId) {
        return new BubbleMetadata.Builder(shortcutId)
                .setDesiredHeight(314)
                .build();
    }

    private static class MockSmartReplyInflater implements SmartReplyStateInflater {
        @Override
        public InflatedSmartReplyState inflateSmartReplyState(NotificationEntry entry) {
+18 −0
Original line number Diff line number Diff line
@@ -185,6 +185,8 @@ public class BubblesTest extends SysuiTestCase {
    private ArgumentCaptor<NotificationEntryListener> mEntryListenerCaptor;
    @Captor
    private ArgumentCaptor<NotificationRemoveInterceptor> mRemoveInterceptorCaptor;
    @Captor
    private ArgumentCaptor<List<Bubble>> mBubbleListCaptor;

    private BubblesManager mBubblesManager;
    // 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());
    }

    /**
     * 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.
+21 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.wm.shell.ShellTaskOrganizer;
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.BubbleDataRepository;
import com.android.wm.shell.bubbles.BubbleEntry;
@@ -167,6 +168,9 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {

    @Captor
    private ArgumentCaptor<NotifCollectionListener> mNotifListenerCaptor;
    @Captor
    private ArgumentCaptor<List<Bubble>> mBubbleListCaptor;

    private BubblesManager mBubblesManager;
    private TestableBubbleController mBubbleController;
    private NotificationShadeWindowControllerImpl mNotificationShadeWindowController;
@@ -1013,6 +1017,23 @@ public class NewNotifPipelineBubblesTest extends SysuiTestCase {
        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
    public void testShowManageMenuChangesSysuiState() {
        mBubbleController.updateBubble(mBubbleEntry);