diff options
| author | 2022-10-04 22:49:48 +0000 | |
|---|---|---|
| committer | 2022-10-04 22:49:48 +0000 | |
| commit | c6bf573dabb645b465cf884c41c038d676f9e4a8 (patch) | |
| tree | 359f73722eeb2dda98b68d7ebb9a1351a3edbe6c | |
| parent | 80953337ca3cfddaa8905d1cdd5d1959bba9214d (diff) | |
| parent | a60e9c21a3bd0d116f80a805f626d3f6021722a8 (diff) | |
Merge "Add UIEvent for NotificationDrag" into tm-qpr-dev am: 8f9e218330 am: a60e9c21a3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20076376
Change-Id: I3771b9dc3fe8b421d21e661719302fee63b1b569
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
5 files changed, 48 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLogger.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLogger.java index 9faef1b43bc1..5ca13c95309f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLogger.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLogger.java @@ -45,11 +45,21 @@ public interface NotificationPanelLogger { void logPanelShown(boolean isLockscreen, @Nullable List<NotificationEntry> visibleNotifications); + /** + * Log a NOTIFICATION_PANEL_REPORTED statsd event, with + * {@link NotificationPanelEvent#NOTIFICATION_DRAG} as the eventID. + * + * @param draggedNotification the notification that is being dragged + */ + void logNotificationDrag(NotificationEntry draggedNotification); + enum NotificationPanelEvent implements UiEventLogger.UiEventEnum { @UiEvent(doc = "Notification panel shown from status bar.") NOTIFICATION_PANEL_OPEN_STATUS_BAR(200), @UiEvent(doc = "Notification panel shown from lockscreen.") - NOTIFICATION_PANEL_OPEN_LOCKSCREEN(201); + NOTIFICATION_PANEL_OPEN_LOCKSCREEN(201), + @UiEvent(doc = "Notification was dragged") + NOTIFICATION_DRAG(1226); private final int mId; NotificationPanelEvent(int id) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerImpl.java index 75a60194f2fa..9a632282ae16 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerImpl.java @@ -16,12 +16,15 @@ package com.android.systemui.statusbar.notification.logging; +import static com.android.systemui.statusbar.notification.logging.NotificationPanelLogger.NotificationPanelEvent.NOTIFICATION_DRAG; + import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.logging.nano.Notifications; import com.google.protobuf.nano.MessageNano; +import java.util.Collections; import java.util.List; /** @@ -38,4 +41,14 @@ public class NotificationPanelLoggerImpl implements NotificationPanelLogger { /* int num_notifications*/ proto.notifications.length, /* byte[] notifications*/ MessageNano.toByteArray(proto)); } + + @Override + public void logNotificationDrag(NotificationEntry draggedNotification) { + final Notifications.NotificationList proto = NotificationPanelLogger.toNotificationProto( + Collections.singletonList(draggedNotification)); + SysUiStatsLog.write(SysUiStatsLog.NOTIFICATION_PANEL_REPORTED, + /* int event_id */ NOTIFICATION_DRAG.getId(), + /* int num_notifications*/ proto.notifications.length, + /* byte[] notifications*/ MessageNano.toByteArray(proto)); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java index 4939a9c22cf8..64f87cabaf74 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragController.java @@ -45,12 +45,17 @@ import android.widget.Toast; import androidx.annotation.VisibleForTesting; +import com.android.internal.logging.InstanceId; +import com.android.internal.logging.InstanceIdSequence; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; import com.android.systemui.shade.ShadeController; import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger; import com.android.systemui.statusbar.policy.HeadsUpManager; +import java.util.Collections; + import javax.inject.Inject; /** @@ -63,14 +68,17 @@ public class ExpandableNotificationRowDragController { private final Context mContext; private final HeadsUpManager mHeadsUpManager; private final ShadeController mShadeController; + private NotificationPanelLogger mNotificationPanelLogger; @Inject public ExpandableNotificationRowDragController(Context context, HeadsUpManager headsUpManager, - ShadeController shadeController) { + ShadeController shadeController, + NotificationPanelLogger notificationPanelLogger) { mContext = context; mHeadsUpManager = headsUpManager; mShadeController = shadeController; + mNotificationPanelLogger = notificationPanelLogger; init(); } @@ -120,12 +128,16 @@ public class ExpandableNotificationRowDragController { dragIntent.putExtra(ClipDescription.EXTRA_PENDING_INTENT, contentIntent); dragIntent.putExtra(Intent.EXTRA_USER, android.os.Process.myUserHandle()); ClipData.Item item = new ClipData.Item(dragIntent); + InstanceId instanceId = new InstanceIdSequence(Integer.MAX_VALUE).newInstanceId(); + item.getIntent().putExtra(ClipDescription.EXTRA_LOGGING_INSTANCE_ID, instanceId); ClipData dragData = new ClipData(clipDescription, item); View.DragShadowBuilder myShadow = new View.DragShadowBuilder(snapshot); view.setOnDragListener(getDraggedViewDragListener()); boolean result = view.startDragAndDrop(dragData, myShadow, null, View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION); if (result) { + // Log notification drag only if it succeeds + mNotificationPanelLogger.logNotificationDrag(enr.getEntry()); view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); if (enr.isPinned()) { mHeadsUpManager.releaseAllImmediately(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerFake.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerFake.java index 7e97629e82e2..dae0aa229dbf 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerFake.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/logging/NotificationPanelLoggerFake.java @@ -40,6 +40,10 @@ public class NotificationPanelLoggerFake implements NotificationPanelLogger { NotificationPanelLogger.toNotificationProto(visibleNotifications))); } + @Override + public void logNotificationDrag(NotificationEntry draggedNotification) { + } + public static class CallRecord { public boolean isLockscreen; public Notifications.NotificationList list; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java index 922e93d06efc..ed2afe753a5e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowDragControllerTest.java @@ -40,6 +40,8 @@ import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.shade.ShadeController; +import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger; +import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerFake; import com.android.systemui.statusbar.policy.HeadsUpManager; import org.junit.Before; @@ -63,6 +65,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase { private NotificationMenuRowPlugin.MenuItem mMenuItem = mock(NotificationMenuRowPlugin.MenuItem.class); private ShadeController mShadeController = mock(ShadeController.class); + private NotificationPanelLogger mNotificationPanelLogger = mock(NotificationPanelLogger.class); @Before public void setUp() throws Exception { @@ -82,7 +85,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase { when(mMenuRow.getLongpressMenuItem(any(Context.class))).thenReturn(mMenuItem); mController = new ExpandableNotificationRowDragController(mContext, mHeadsUpManager, - mShadeController); + mShadeController, mNotificationPanelLogger); } @Test @@ -96,6 +99,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase { mRow.doDragCallback(0, 0); verify(controller).startDragAndDrop(mRow); verify(mHeadsUpManager, times(1)).releaseAllImmediately(); + verify(mNotificationPanelLogger, times(1)).logNotificationDrag(any()); } @Test @@ -107,6 +111,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase { verify(controller).startDragAndDrop(mRow); verify(mShadeController).animateCollapsePanels(eq(0), eq(true), eq(false), anyFloat()); + verify(mNotificationPanelLogger, times(1)).logNotificationDrag(any()); } @Test @@ -124,6 +129,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase { // Verify that we never start the actual drag since there is no content verify(mRow, never()).startDragAndDrop(any(), any(), any(), anyInt()); + verify(mNotificationPanelLogger, never()).logNotificationDrag(any()); } private ExpandableNotificationRowDragController createSpyController() { |