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

Commit 708a9f96 authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge changes Ib6f2f9a4,I0480fd83 into main

* changes:
  Log when bubble is moved to overflow
  Log bubble removed events from bubble bar
parents 307f7ca3 330bb37f
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -759,7 +759,9 @@ public class BubbleData {
                if (b != null) {
                    b.stopInflation();
                }
                mLogger.logOverflowRemove(b, reason);
                if (!mPositioner.isShowingInBubbleBar()) {
                    mLogger.logStackOverflowRemove(b, reason);
                }
                mOverflowBubbles.remove(b);
                mStateChange.bubbleRemoved(b, reason);
                mStateChange.removedOverflowBubble = b;
@@ -802,6 +804,27 @@ public class BubbleData {
            setNewSelectedIndex(indexToRemove);
        }
        maybeSendDeleteIntent(reason, bubbleToRemove);

        if (mPositioner.isShowingInBubbleBar()) {
            logBubbleBarBubbleRemoved(bubbleToRemove, reason);
        }
    }

    private void logBubbleBarBubbleRemoved(Bubble bubble, @DismissReason int reason) {
        switch (reason) {
            case Bubbles.DISMISS_NOTIF_CANCEL:
                mLogger.log(bubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_REMOVED_CANCELED);
                break;
            case Bubbles.DISMISS_TASK_FINISHED:
                mLogger.log(bubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_ACTIVITY_FINISH);
                break;
            case Bubbles.DISMISS_BLOCKED:
            case Bubbles.DISMISS_NO_LONGER_BUBBLE:
                mLogger.log(bubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_REMOVED_BLOCKED);
                break;
            default:
                // skip logging other events
        }
    }

    private void setNewSelectedIndex(int indexOfSelected) {
@@ -862,7 +885,7 @@ public class BubbleData {
            return;
        }
        ProtoLog.d(WM_SHELL_BUBBLES, "overflowBubble=%s", bubble.getKey());
        mLogger.logOverflowAdd(bubble, reason);
        mLogger.logOverflowAdd(bubble, mPositioner.isShowingInBubbleBar(), reason);
        if (mOverflowBubbles.isEmpty()) {
            mStateChange.showOverflowChanged = true;
        }
+16 −8
Original line number Diff line number Diff line
@@ -182,10 +182,12 @@ public class BubbleLogger {
    }

    /**
     * Log when a bubble is removed from overflow in stack view
     *
     * @param b Bubble removed from overflow
     * @param r Reason that bubble was removed
     */
    public void logOverflowRemove(Bubble b, @Bubbles.DismissReason int r) {
    public void logStackOverflowRemove(Bubble b, @Bubbles.DismissReason int r) {
        if (r == Bubbles.DISMISS_NOTIF_CANCEL) {
            log(b, BubbleLogger.Event.BUBBLE_OVERFLOW_REMOVE_CANCEL);
        } else if (r == Bubbles.DISMISS_GROUP_CANCELLED) {
@@ -201,7 +203,12 @@ public class BubbleLogger {
     * @param b Bubble added to overflow
     * @param r Reason that bubble was added to overflow
     */
    public void logOverflowAdd(Bubble b, @Bubbles.DismissReason int r) {
    public void logOverflowAdd(Bubble b, boolean bubbleBar, @Bubbles.DismissReason int r) {
        if (bubbleBar) {
            if (r == Bubbles.DISMISS_AGED) {
                log(b, Event.BUBBLE_BAR_OVERFLOW_ADD_AGED);
            }
        } else {
            if (r == Bubbles.DISMISS_AGED) {
                log(b, Event.BUBBLE_OVERFLOW_ADD_AGED);
            } else if (r == Bubbles.DISMISS_USER_GESTURE) {
@@ -210,6 +217,7 @@ public class BubbleLogger {
                log(b, Event.BUBBLE_OVERFLOW_RECOVER);
            }
        }
    }

    void logStackUiChanged(String packageName, int action, int bubbleCount, float normalX,
            float normalY) {
+7 −0
Original line number Diff line number Diff line
@@ -830,6 +830,13 @@ public class BubblePositioner {
        mShowingInBubbleBar = showingInBubbleBar;
    }

    /**
     * Whether bubbles ar showing in the bubble bar from launcher.
     */
    boolean isShowingInBubbleBar() {
        return mShowingInBubbleBar;
    }

    public void setBubbleBarLocation(BubbleBarLocation location) {
        mBubbleBarLocation = location;
    }
+82 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.view.WindowManager;

import androidx.test.filters.SmallTest;

import com.android.internal.logging.testing.UiEventLoggerFake;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.bubbles.BubbleData.TimeSource;
import com.android.wm.shell.common.ShellExecutor;
@@ -102,6 +103,7 @@ public class BubbleDataTest extends ShellTestCase {

    private BubbleData mBubbleData;
    private TestableBubblePositioner mPositioner;
    private UiEventLoggerFake mUiEventLogger;

    @Mock
    private TimeSource mTimeSource;
@@ -112,8 +114,6 @@ public class BubbleDataTest extends ShellTestCase {
    @Mock
    private PendingIntent mDeleteIntent;
    @Mock
    private BubbleLogger mBubbleLogger;
    @Mock
    private BubbleEducationController mEducationController;
    @Mock
    private ShellExecutor mMainExecutor;
@@ -196,10 +196,12 @@ public class BubbleDataTest extends ShellTestCase {
                mock(Icon.class),
                mMainExecutor, mBgExecutor);

        mUiEventLogger = new UiEventLoggerFake();

        mPositioner = new TestableBubblePositioner(mContext,
                mContext.getSystemService(WindowManager.class));
        mBubbleData = new BubbleData(getContext(), mBubbleLogger, mPositioner, mEducationController,
                mMainExecutor, mBgExecutor);
        mBubbleData = new BubbleData(getContext(), new BubbleLogger(mUiEventLogger), mPositioner,
                mEducationController, mMainExecutor, mBgExecutor);

        // Used by BubbleData to set lastAccessedTime
        when(mTimeSource.currentTimeMillis()).thenReturn(1000L);
@@ -296,6 +298,82 @@ public class BubbleDataTest extends ShellTestCase {
        assertThat(bubbleBarUpdate.removedBubbles).isEmpty();
    }

    @Test
    public void testRemoveBubbleFromBubbleBar_notifCancelled_logEvent() {
        mPositioner.setShowingInBubbleBar(true);

        sendUpdatedEntryAtTime(mEntryA1, 1000);
        mBubbleData.setListener(mListener);

        mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_NOTIF_CANCEL);
        assertThat(mUiEventLogger.numLogs()).isEqualTo(1);
        assertThat(mUiEventLogger.eventId(0)).isEqualTo(
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_REMOVED_CANCELED.getId());
    }

    @Test
    public void testRemoveBubbleFromBubbleBar_taskFinished_logEvent() {
        mPositioner.setShowingInBubbleBar(true);

        sendUpdatedEntryAtTime(mEntryA1, 1000);
        mBubbleData.setListener(mListener);

        mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_TASK_FINISHED);
        assertThat(mUiEventLogger.numLogs()).isEqualTo(1);
        assertThat(mUiEventLogger.eventId(0)).isEqualTo(
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_ACTIVITY_FINISH.getId());
    }

    @Test
    public void testRemoveBubbleFromBubbleBar_notifBlocked_logEvent() {
        mPositioner.setShowingInBubbleBar(true);

        sendUpdatedEntryAtTime(mEntryA1, 1000);
        mBubbleData.setListener(mListener);

        mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_BLOCKED);
        assertThat(mUiEventLogger.numLogs()).isEqualTo(1);
        assertThat(mUiEventLogger.eventId(0)).isEqualTo(
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_REMOVED_BLOCKED.getId());
    }

    @Test
    public void testRemoveBubbleFromBubbleBar_noLongerBubble_logEvent() {
        mPositioner.setShowingInBubbleBar(true);

        sendUpdatedEntryAtTime(mEntryA1, 1000);
        mBubbleData.setListener(mListener);

        mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_NO_LONGER_BUBBLE);
        assertThat(mUiEventLogger.numLogs()).isEqualTo(1);
        assertThat(mUiEventLogger.eventId(0)).isEqualTo(
                BubbleLogger.Event.BUBBLE_BAR_BUBBLE_REMOVED_BLOCKED.getId());
    }

    @Test
    public void testRemoveBubbleFromBubbleBar_addToOverflow_logEvent() {
        mPositioner.setShowingInBubbleBar(true);

        sendUpdatedEntryAtTime(mEntryA1, 1000);
        mBubbleData.setListener(mListener);

        mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_AGED);
        assertThat(mUiEventLogger.numLogs()).isEqualTo(1);
        assertThat(mUiEventLogger.eventId(0)).isEqualTo(
                BubbleLogger.Event.BUBBLE_BAR_OVERFLOW_ADD_AGED.getId());
    }

    @Test
    public void testRemoveBubble_notifCancelled_noLog() {
        mPositioner.setShowingInBubbleBar(false);

        sendUpdatedEntryAtTime(mEntryA1, 1000);
        mBubbleData.setListener(mListener);

        mBubbleData.dismissBubbleWithKey(mEntryA1.getKey(), Bubbles.DISMISS_BLOCKED);
        assertThat(mUiEventLogger.numLogs()).isEqualTo(0);
    }

    @Test
    public void ifSuppress_hideFlyout() {
        // Setup