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

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

Merge "Log when bubble is dismissed via drag" into main

parents 3ce6a828 c62258ba
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1246,9 +1246,12 @@ public class BubbleController implements ConfigurationChangeListener,
     */
    public void dragBubbleToDismiss(String bubbleKey, long timestamp) {
        String selectedBubbleKey = mBubbleData.getSelectedBubbleKey();
        if (mBubbleData.hasAnyBubbleWithKey(bubbleKey)) {
        Bubble bubbleToDismiss = mBubbleData.getAnyBubbleWithkey(bubbleKey);
        if (bubbleToDismiss != null) {
            mBubbleData.dismissBubbleWithKey(
                    bubbleKey, Bubbles.DISMISS_USER_GESTURE_FROM_LAUNCHER, timestamp);
            mLogger.log(bubbleToDismiss,
                    BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_BUBBLE);
        }
        if (mBubbleData.hasBubbles()) {
            // We still have bubbles, if we dragged an individual bubble to dismiss we were expanded
+23 −3
Original line number Diff line number Diff line
@@ -198,6 +198,8 @@ import com.android.wm.shell.taskview.TaskView;
import com.android.wm.shell.taskview.TaskViewTransitions;
import com.android.wm.shell.transition.Transitions;

import kotlin.Lazy;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -216,7 +218,6 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executor;

import kotlin.Lazy;
import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

@@ -2481,7 +2482,7 @@ public class BubblesTest extends SysuiTestCase {

        mEntryListener.onEntryAdded(mRow);

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

@@ -2498,10 +2499,25 @@ public class BubblesTest extends SysuiTestCase {
        NotificationEntryHelper.modifyRanking(mRow).setTextChanged(true).build();
        mEntryListener.onEntryUpdated(mRow, /* fromSystem= */ true);

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

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

        mEntryListener.onEntryAdded(mRow);
        mBubbleController.dragBubbleToDismiss(mRow.getKey(), 1L);

        verify(mBubbleLogger).log(eqBubbleWithKey(mRow.getKey()),
                eq(BubbleLogger.Event.BUBBLE_BAR_BUBBLE_DISMISSED_DRAG_BUBBLE));
    }

    /** Creates a bubble using the userId and package. */
    private Bubble createBubble(int userId, String pkg) {
        final UserHandle userHandle = new UserHandle(userId);
@@ -2687,6 +2703,10 @@ public class BubblesTest extends SysuiTestCase {
        assertThat(mSysUiStateBubblesManageMenuExpanded).isEqualTo(manageMenuExpanded);
    }

    private Bubble eqBubbleWithKey(String key) {
        return argThat(b -> b.getKey().equals(key));
    }

    private static class FakeBubbleStateListener implements Bubbles.BubbleStateListener {

        int mStateChangeCalls = 0;