Merge "Add UIEvent for NotificationDrag" into tm-qpr-dev am: 8f9e218330
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20076376 Change-Id: Ibd05fc71d114610ef837645bc5161790dc11a00c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -45,11 +45,21 @@ public interface NotificationPanelLogger {
|
|||||||
void logPanelShown(boolean isLockscreen,
|
void logPanelShown(boolean isLockscreen,
|
||||||
@Nullable List<NotificationEntry> visibleNotifications);
|
@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 {
|
enum NotificationPanelEvent implements UiEventLogger.UiEventEnum {
|
||||||
@UiEvent(doc = "Notification panel shown from status bar.")
|
@UiEvent(doc = "Notification panel shown from status bar.")
|
||||||
NOTIFICATION_PANEL_OPEN_STATUS_BAR(200),
|
NOTIFICATION_PANEL_OPEN_STATUS_BAR(200),
|
||||||
@UiEvent(doc = "Notification panel shown from lockscreen.")
|
@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;
|
private final int mId;
|
||||||
NotificationPanelEvent(int id) {
|
NotificationPanelEvent(int id) {
|
||||||
|
|||||||
@@ -16,12 +16,15 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.notification.logging;
|
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.shared.system.SysUiStatsLog;
|
||||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||||
import com.android.systemui.statusbar.notification.logging.nano.Notifications;
|
import com.android.systemui.statusbar.notification.logging.nano.Notifications;
|
||||||
|
|
||||||
import com.google.protobuf.nano.MessageNano;
|
import com.google.protobuf.nano.MessageNano;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,4 +41,14 @@ public class NotificationPanelLoggerImpl implements NotificationPanelLogger {
|
|||||||
/* int num_notifications*/ proto.notifications.length,
|
/* int num_notifications*/ proto.notifications.length,
|
||||||
/* byte[] notifications*/ MessageNano.toByteArray(proto));
|
/* 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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,12 +45,17 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
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.R;
|
||||||
import com.android.systemui.animation.Interpolators;
|
import com.android.systemui.animation.Interpolators;
|
||||||
import com.android.systemui.shade.ShadeController;
|
import com.android.systemui.shade.ShadeController;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
|
import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger;
|
||||||
import com.android.systemui.statusbar.policy.HeadsUpManager;
|
import com.android.systemui.statusbar.policy.HeadsUpManager;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,14 +68,17 @@ public class ExpandableNotificationRowDragController {
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final HeadsUpManager mHeadsUpManager;
|
private final HeadsUpManager mHeadsUpManager;
|
||||||
private final ShadeController mShadeController;
|
private final ShadeController mShadeController;
|
||||||
|
private NotificationPanelLogger mNotificationPanelLogger;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ExpandableNotificationRowDragController(Context context,
|
public ExpandableNotificationRowDragController(Context context,
|
||||||
HeadsUpManager headsUpManager,
|
HeadsUpManager headsUpManager,
|
||||||
ShadeController shadeController) {
|
ShadeController shadeController,
|
||||||
|
NotificationPanelLogger notificationPanelLogger) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mHeadsUpManager = headsUpManager;
|
mHeadsUpManager = headsUpManager;
|
||||||
mShadeController = shadeController;
|
mShadeController = shadeController;
|
||||||
|
mNotificationPanelLogger = notificationPanelLogger;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -120,12 +128,16 @@ public class ExpandableNotificationRowDragController {
|
|||||||
dragIntent.putExtra(ClipDescription.EXTRA_PENDING_INTENT, contentIntent);
|
dragIntent.putExtra(ClipDescription.EXTRA_PENDING_INTENT, contentIntent);
|
||||||
dragIntent.putExtra(Intent.EXTRA_USER, android.os.Process.myUserHandle());
|
dragIntent.putExtra(Intent.EXTRA_USER, android.os.Process.myUserHandle());
|
||||||
ClipData.Item item = new ClipData.Item(dragIntent);
|
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);
|
ClipData dragData = new ClipData(clipDescription, item);
|
||||||
View.DragShadowBuilder myShadow = new View.DragShadowBuilder(snapshot);
|
View.DragShadowBuilder myShadow = new View.DragShadowBuilder(snapshot);
|
||||||
view.setOnDragListener(getDraggedViewDragListener());
|
view.setOnDragListener(getDraggedViewDragListener());
|
||||||
boolean result = view.startDragAndDrop(dragData, myShadow, null, View.DRAG_FLAG_GLOBAL
|
boolean result = view.startDragAndDrop(dragData, myShadow, null, View.DRAG_FLAG_GLOBAL
|
||||||
| View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION);
|
| View.DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
// Log notification drag only if it succeeds
|
||||||
|
mNotificationPanelLogger.logNotificationDrag(enr.getEntry());
|
||||||
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
if (enr.isPinned()) {
|
if (enr.isPinned()) {
|
||||||
mHeadsUpManager.releaseAllImmediately();
|
mHeadsUpManager.releaseAllImmediately();
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ public class NotificationPanelLoggerFake implements NotificationPanelLogger {
|
|||||||
NotificationPanelLogger.toNotificationProto(visibleNotifications)));
|
NotificationPanelLogger.toNotificationProto(visibleNotifications)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logNotificationDrag(NotificationEntry draggedNotification) {
|
||||||
|
}
|
||||||
|
|
||||||
public static class CallRecord {
|
public static class CallRecord {
|
||||||
public boolean isLockscreen;
|
public boolean isLockscreen;
|
||||||
public Notifications.NotificationList list;
|
public Notifications.NotificationList list;
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ import androidx.test.filters.SmallTest;
|
|||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
|
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
|
||||||
import com.android.systemui.shade.ShadeController;
|
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 com.android.systemui.statusbar.policy.HeadsUpManager;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -63,6 +65,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase {
|
|||||||
private NotificationMenuRowPlugin.MenuItem mMenuItem =
|
private NotificationMenuRowPlugin.MenuItem mMenuItem =
|
||||||
mock(NotificationMenuRowPlugin.MenuItem.class);
|
mock(NotificationMenuRowPlugin.MenuItem.class);
|
||||||
private ShadeController mShadeController = mock(ShadeController.class);
|
private ShadeController mShadeController = mock(ShadeController.class);
|
||||||
|
private NotificationPanelLogger mNotificationPanelLogger = mock(NotificationPanelLogger.class);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -82,7 +85,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase {
|
|||||||
when(mMenuRow.getLongpressMenuItem(any(Context.class))).thenReturn(mMenuItem);
|
when(mMenuRow.getLongpressMenuItem(any(Context.class))).thenReturn(mMenuItem);
|
||||||
|
|
||||||
mController = new ExpandableNotificationRowDragController(mContext, mHeadsUpManager,
|
mController = new ExpandableNotificationRowDragController(mContext, mHeadsUpManager,
|
||||||
mShadeController);
|
mShadeController, mNotificationPanelLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -96,6 +99,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase {
|
|||||||
mRow.doDragCallback(0, 0);
|
mRow.doDragCallback(0, 0);
|
||||||
verify(controller).startDragAndDrop(mRow);
|
verify(controller).startDragAndDrop(mRow);
|
||||||
verify(mHeadsUpManager, times(1)).releaseAllImmediately();
|
verify(mHeadsUpManager, times(1)).releaseAllImmediately();
|
||||||
|
verify(mNotificationPanelLogger, times(1)).logNotificationDrag(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -107,6 +111,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase {
|
|||||||
verify(controller).startDragAndDrop(mRow);
|
verify(controller).startDragAndDrop(mRow);
|
||||||
verify(mShadeController).animateCollapsePanels(eq(0), eq(true),
|
verify(mShadeController).animateCollapsePanels(eq(0), eq(true),
|
||||||
eq(false), anyFloat());
|
eq(false), anyFloat());
|
||||||
|
verify(mNotificationPanelLogger, times(1)).logNotificationDrag(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -124,6 +129,7 @@ public class ExpandableNotificationRowDragControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
// Verify that we never start the actual drag since there is no content
|
// Verify that we never start the actual drag since there is no content
|
||||||
verify(mRow, never()).startDragAndDrop(any(), any(), any(), anyInt());
|
verify(mRow, never()).startDragAndDrop(any(), any(), any(), anyInt());
|
||||||
|
verify(mNotificationPanelLogger, never()).logNotificationDrag(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExpandableNotificationRowDragController createSpyController() {
|
private ExpandableNotificationRowDragController createSpyController() {
|
||||||
|
|||||||
Reference in New Issue
Block a user