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

Commit 05e2d321 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Notify launcher when bubble overflow data has loaded" into main

parents 233d6092 6f794498
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -1971,7 +1971,13 @@ public class BubbleController implements ConfigurationChangeListener,
                    return;
                    return;
                }
                }
                bubble.inflate(
                bubble.inflate(
                        (b) -> mBubbleData.overflowBubble(Bubbles.DISMISS_RELOAD_FROM_DISK, bubble),
                        (b) -> {
                            if (Flags.enableOptionalBubbleOverflow()) {
                                mBubbleData.addOverflowBubbleFromDisk(bubble);
                            } else {
                                mBubbleData.doOverflow(Bubbles.DISMISS_RELOAD_FROM_DISK, bubble);
                            }
                        },
                        mContext,
                        mContext,
                        mExpandedViewManager,
                        mExpandedViewManager,
                        mBubbleTaskViewFactory,
                        mBubbleTaskViewFactory,
+10 −2
Original line number Original line Diff line number Diff line
@@ -850,7 +850,7 @@ public class BubbleData {
        ProtoLog.d(WM_SHELL_BUBBLES, "doRemove=%s reason=%s", bubbleToRemove.getKey(),
        ProtoLog.d(WM_SHELL_BUBBLES, "doRemove=%s reason=%s", bubbleToRemove.getKey(),
                dismissReasonToString(reason));
                dismissReasonToString(reason));
        bubbleToRemove.stopInflation();
        bubbleToRemove.stopInflation();
        overflowBubble(reason, bubbleToRemove);
        doOverflow(reason, bubbleToRemove);


        if (mBubbles.size() == 1) {
        if (mBubbles.size() == 1) {
            setExpandedInternal(false);
            setExpandedInternal(false);
@@ -947,7 +947,7 @@ public class BubbleData {
        }
        }
    }
    }


    void overflowBubble(@DismissReason int reason, Bubble bubble) {
    void doOverflow(@DismissReason int reason, Bubble bubble) {
        boolean isOverflowReason = reason == Bubbles.DISMISS_AGED
        boolean isOverflowReason = reason == Bubbles.DISMISS_AGED
                || reason == Bubbles.DISMISS_USER_GESTURE
                || reason == Bubbles.DISMISS_USER_GESTURE
                || reason == Bubbles.DISMISS_USER_GESTURE_FROM_LAUNCHER
                || reason == Bubbles.DISMISS_USER_GESTURE_FROM_LAUNCHER
@@ -1040,6 +1040,14 @@ public class BubbleData {
        }
        }
    }
    }


    /**
     * Adds a bubble loaded from the saved bubbles xml file to the overflow.
     */
    public void addOverflowBubbleFromDisk(Bubble bubble) {
        doOverflow(Bubbles.DISMISS_RELOAD_FROM_DISK, bubble);
        dispatchPendingChanges();
    }

    /**
    /**
     * Removes all bubbles from the overflow, called when the user changes.
     * Removes all bubbles from the overflow, called when the user changes.
     */
     */
+19 −3
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.wm.shell.bubbles;
package com.android.wm.shell.bubbles;


import static com.android.wm.shell.Flags.FLAG_ENABLE_OPTIONAL_BUBBLE_OVERFLOW;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assertWithMessage;


@@ -37,6 +39,7 @@ import android.content.LocusId;
import android.graphics.drawable.Icon;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserHandle;
import android.platform.test.annotations.EnableFlags;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.service.notification.StatusBarNotification;
import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
@@ -457,6 +460,19 @@ public class BubbleDataTest extends ShellTestCase {
    // Overflow
    // Overflow
    //
    //


    @EnableFlags(FLAG_ENABLE_OPTIONAL_BUBBLE_OVERFLOW)
    @Test
    public void testAddOverflowBubbleFromDisk_notifiesUpdate() {
        mBubbleData.setListener(mListener);

        mBubbleData.addOverflowBubbleFromDisk(mBubbleA1);
        verifyUpdateReceived();

        BubbleData.Update update = mUpdateCaptor.getValue();
        assertThat(update.showOverflowChanged).isTrue();
        assertThat(update.overflowBubbles).hasSize(1);
    }

    /**
    /**
     * Verifies that when the bubble stack reaches its maximum, the oldest bubble is overflowed.
     * Verifies that when the bubble stack reaches its maximum, the oldest bubble is overflowed.
     */
     */
@@ -1095,9 +1111,9 @@ public class BubbleDataTest extends ShellTestCase {
    @Test
    @Test
    public void test_addToOverflow_doesntAllowDupes() {
    public void test_addToOverflow_doesntAllowDupes() {
        assertEquals(0, mBubbleData.getOverflowBubbles().size());
        assertEquals(0, mBubbleData.getOverflowBubbles().size());
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.doOverflow(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.doOverflow(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.doOverflow(Bubbles.DISMISS_AGED, mBubbleA1);
        assertEquals(1, mBubbleData.getOverflowBubbles().size());
        assertEquals(1, mBubbleData.getOverflowBubbles().size());
    }
    }