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

Commit 28e00e01 authored by Will Brockman's avatar Will Brockman Committed by Automerger Merge Worker
Browse files

Merge "Distinguish statsd notification actions logs." into rvc-dev am: 54343748 am: 8e5e1384

Change-Id: I97ea7a15c988fe283918ff9b445f3f7f9fb55d15
parents a2677f59 8e5e1384
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -943,7 +943,8 @@ public class NotificationManagerService extends SystemService {
                        .addTaggedData(MetricsEvent.NOTIFICATION_LOCATION,
                                nv.location.toMetricsEventEnum()));
                mNotificationRecordLogger.log(
                        NotificationRecordLogger.NotificationEvent.NOTIFICATION_ACTION_CLICKED, r);
                        NotificationRecordLogger.NotificationEvent.fromAction(actionIndex,
                                generatedByAssistant, action.isContextual()), r);
                EventLogTags.writeNotificationActionClicked(key, actionIndex,
                        r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now),
                        nv.rank, nv.count);
+34 −2
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ public interface NotificationRecordLogger {
        NOTIFICATION_NOT_POSTED_SNOOZED(319),
        @UiEvent(doc = "Notification was clicked.")
        NOTIFICATION_CLICKED(320),
        @UiEvent(doc = "Notification action was clicked.")
        @UiEvent(doc = "Notification action was clicked; unexpected position.")
        NOTIFICATION_ACTION_CLICKED(321),
        @UiEvent(doc = "Notification detail was expanded due to non-user action.")
        NOTIFICATION_DETAIL_OPEN_SYSTEM(327),
@@ -245,7 +245,24 @@ public interface NotificationRecordLogger {
        NOTIFICATION_SMART_REPLIED(332),
        @UiEvent(doc = "Notification smart reply action was visible.")
        NOTIFICATION_SMART_REPLY_VISIBLE(333),
        ;
        @UiEvent(doc = "App-generated notification action at position 0 was clicked.")
        NOTIFICATION_ACTION_CLICKED_0(450),
        @UiEvent(doc = "App-generated notification action at position 1 was clicked.")
        NOTIFICATION_ACTION_CLICKED_1(451),
        @UiEvent(doc = "App-generated notification action at position 2 was clicked.")
        NOTIFICATION_ACTION_CLICKED_2(452),
        @UiEvent(doc = "Contextual notification action at position 0 was clicked.")
        NOTIFICATION_CONTEXTUAL_ACTION_CLICKED_0(453),
        @UiEvent(doc = "Contextual notification action at position 1 was clicked.")
        NOTIFICATION_CONTEXTUAL_ACTION_CLICKED_1(454),
        @UiEvent(doc = "Contextual notification action at position 2 was clicked.")
        NOTIFICATION_CONTEXTUAL_ACTION_CLICKED_2(455),
        @UiEvent(doc = "Notification assistant generated notification action at 0 was clicked.")
        NOTIFICATION_ASSIST_ACTION_CLICKED_0(456),
        @UiEvent(doc = "Notification assistant generated notification action at 1 was clicked.")
        NOTIFICATION_ASSIST_ACTION_CLICKED_1(457),
        @UiEvent(doc = "Notification assistant generated notification action at 2 was clicked.")
        NOTIFICATION_ASSIST_ACTION_CLICKED_2(458);

        private final int mId;
        NotificationEvent(int id) {
@@ -264,6 +281,21 @@ public interface NotificationRecordLogger {
            }
            return expanded ? NOTIFICATION_DETAIL_OPEN_SYSTEM : NOTIFICATION_DETAIL_CLOSE_SYSTEM;
        }
        public static NotificationEvent fromAction(int index, boolean isAssistant,
                boolean isContextual) {
            if (index < 0 || index > 2) {
                return NOTIFICATION_ACTION_CLICKED;
            }
            if (isAssistant) {  // Assistant actions are contextual by definition
                return NotificationEvent.values()[
                        NOTIFICATION_ASSIST_ACTION_CLICKED_0.ordinal() + index];
            }
            if (isContextual) {
                return NotificationEvent.values()[
                        NOTIFICATION_CONTEXTUAL_ACTION_CLICKED_0.ordinal() + index];
            }
            return NotificationEvent.values()[NOTIFICATION_ACTION_CLICKED_0.ordinal() + index];
        }
    }

    enum NotificationPanelEvent implements UiEventLogger.UiEventEnum {
+26 −1
Original line number Diff line number Diff line
@@ -4932,7 +4932,32 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                eq(r.getSbn()), eq(actionIndex), eq(action), eq(generatedByAssistant));

        assertEquals(1, mNotificationRecordLogger.numCalls());
        assertEquals(NotificationRecordLogger.NotificationEvent.NOTIFICATION_ACTION_CLICKED,
        assertEquals(
                NotificationRecordLogger.NotificationEvent.NOTIFICATION_ACTION_CLICKED_2,
                mNotificationRecordLogger.event(0));
    }

    @Test
    public void testOnAssistantNotificationActionClick() {
        final int actionIndex = 1;
        final Notification.Action action =
                new Notification.Action.Builder(null, "text", null).build();
        final boolean generatedByAssistant = true;

        NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);
        mService.addNotification(r);

        NotificationVisibility notificationVisibility =
                NotificationVisibility.obtain(r.getKey(), 1, 2, true);
        mService.mNotificationDelegate.onNotificationActionClick(
                10, 10, r.getKey(), actionIndex, action, notificationVisibility,
                generatedByAssistant);
        verify(mAssistants).notifyAssistantActionClicked(
                eq(r.getSbn()), eq(actionIndex), eq(action), eq(generatedByAssistant));

        assertEquals(1, mNotificationRecordLogger.numCalls());
        assertEquals(
                NotificationRecordLogger.NotificationEvent.NOTIFICATION_ASSIST_ACTION_CLICKED_1,
                mNotificationRecordLogger.event(0));
    }