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

Commit 6f794498 authored by Mady Mellor's avatar Mady Mellor
Browse files

Notify launcher when bubble overflow data has loaded

For the optional overflow, shell needs to notify launcher that
there's stuff in the overflow so it should show. We load the overflow
data from xml and we don't let launcher know when it's loaded.

Instead launcher gets the event whenever it gets the next bubble event
causing the overflow to appear with a delay.

This cl dispatches a change event specifically in the overflow
case, so the overflow shows up when its ready.

Bug: 334175587
Test: atest BubbleDataTest
Test: manual - have stuff in bubble overflow, reboot device, get
               a bubble in bubble bar, observe that overflow is added
               smoothly
Flag: EXEMPT - bugfix / some behind com.android.wm.shell.enable_bubble_bar
Change-Id: I8abc549b99090eee951ff0fc47731a742cb8030d
parent 5a480c2d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1970,7 +1970,13 @@ public class BubbleController implements ConfigurationChangeListener,
                    return;
                }
                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,
                        mExpandedViewManager,
                        mBubbleTaskViewFactory,
+10 −2
Original line number Diff line number Diff line
@@ -850,7 +850,7 @@ public class BubbleData {
        ProtoLog.d(WM_SHELL_BUBBLES, "doRemove=%s reason=%s", bubbleToRemove.getKey(),
                dismissReasonToString(reason));
        bubbleToRemove.stopInflation();
        overflowBubble(reason, bubbleToRemove);
        doOverflow(reason, bubbleToRemove);

        if (mBubbles.size() == 1) {
            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
                || reason == Bubbles.DISMISS_USER_GESTURE
                || 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.
     */
+19 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

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.assertWithMessage;

@@ -37,6 +39,7 @@ import android.content.LocusId;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.UserHandle;
import android.platform.test.annotations.EnableFlags;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.testing.AndroidTestingRunner;
@@ -457,6 +460,19 @@ public class BubbleDataTest extends ShellTestCase {
    // 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.
     */
@@ -1095,9 +1111,9 @@ public class BubbleDataTest extends ShellTestCase {
    @Test
    public void test_addToOverflow_doesntAllowDupes() {
        assertEquals(0, mBubbleData.getOverflowBubbles().size());
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.overflowBubble(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.doOverflow(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.doOverflow(Bubbles.DISMISS_AGED, mBubbleA1);
        mBubbleData.doOverflow(Bubbles.DISMISS_AGED, mBubbleA1);
        assertEquals(1, mBubbleData.getOverflowBubbles().size());
    }