Merge "Log when bubble is dismissed via drag" into main
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
index c81ffda..eb9cdab 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java
@@ -1246,9 +1246,12 @@
*/
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
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
index 5996ef1..1ceb20a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java
@@ -198,6 +198,8 @@
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.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 @@
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 @@
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 @@
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;