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

Commit 7cc1b8d5 authored by Ats Jenk's avatar Ats Jenk
Browse files

Log when bubble bar bubbles are added or updated

Log UIEvents when bubbles are added or updated in bubble bar.

Bug: 349845968
Test: atest BubblesTest
Flag: com.android.wm.shell.enable_bubble_bar
Change-Id: I2ed6f7763ec82fb63b7961a2c1f0a01590456566
parent beff035f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1979,11 +1979,15 @@ public class BubbleController implements ConfigurationChangeListener,

        @Override
        public void addBubble(Bubble addedBubble) {
            // Only log metrics event
            mLogger.log(addedBubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_POSTED);
            // Nothing to do for adds, these are handled by launcher / in the bubble bar.
        }

        @Override
        public void updateBubble(Bubble updatedBubble) {
            // Only log metrics event
            mLogger.log(updatedBubble, BubbleLogger.Event.BUBBLE_BAR_BUBBLE_UPDATED);
            // Nothing to do for updates, these are handled by launcher / in the bubble bar.
        }

+0 −2
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.wm.shell.bubbles;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.internal.util.FrameworkStatsLog;
@@ -33,7 +32,6 @@ public class BubbleLogger {
    /**
     * Bubble UI event.
     */
    @VisibleForTesting
    public enum Event implements UiEventLogger.UiEventEnum {

        // region bubble events
+32 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
@@ -2470,6 +2471,37 @@ public class BubblesTest extends SysuiTestCase {
        verify(stackView, never()).showOverflow(anyBoolean());
    }

    @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
    @Test
    public void testEventLogging_bubbleBar_addBubble() {
        mBubbleProperties.mIsBubbleBarEnabled = true;
        mPositioner.setIsLargeScreen(true);
        FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
        mBubbleController.registerBubbleStateListener(bubbleStateListener);

        mEntryListener.onEntryAdded(mRow);

        verify(mBubbleLogger).log(argThat(b -> b.getKey().equals(mRow.getKey())),
                eq(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_POSTED));
    }

    @EnableFlags(FLAG_ENABLE_BUBBLE_BAR)
    @Test
    public void testEventLogging_bubbleBar_updateBubble() {
        mBubbleProperties.mIsBubbleBarEnabled = true;
        mPositioner.setIsLargeScreen(true);
        FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
        mBubbleController.registerBubbleStateListener(bubbleStateListener);

        mEntryListener.onEntryAdded(mRow);
        // Mark the notification as updated
        NotificationEntryHelper.modifyRanking(mRow).setTextChanged(true).build();
        mEntryListener.onEntryUpdated(mRow, /* fromSystem= */ true);

        verify(mBubbleLogger).log(argThat(b -> b.getKey().equals(mRow.getKey())),
                eq(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_UPDATED));
    }

    /** Creates a bubble using the userId and package. */
    private Bubble createBubble(int userId, String pkg) {
        final UserHandle userHandle = new UserHandle(userId);