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

Commit c6bf573d authored by Vinit Nayak's avatar Vinit Nayak Committed by Automerger Merge Worker
Browse files

Merge "Add UIEvent for NotificationDrag" into tm-qpr-dev am: 8f9e2183 am: a60e9c21

parents 80953337 a60e9c21
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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) {
+13 −0
Original line number Diff line number Diff line
@@ -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));
    }
}
+13 −1
Original line number Diff line number Diff line
@@ -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();
+4 −0
Original line number Diff line number Diff line
@@ -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;
+7 −1
Original line number Diff line number Diff line
@@ -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() {