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

Commit 61ae286a authored by Will Brockman's avatar Will Brockman
Browse files

Update section enum for statsd notif panel logs.

Add explicit mapping to reduce churn in the logs as notification section list changes.

Fixes: 159568541
Test: statsd_testdrive
Test: atest NotificationLoggerTest
Change-Id: I7f0fe1a4dbed4a4b965154230b937659026b7493
parent a019160b
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -16,6 +16,13 @@

package com.android.systemui.statusbar.notification.logging;

import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_ALERTING;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_FOREGROUND_SERVICE;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_HEADS_UP;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_MEDIA_CONTROLS;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_PEOPLE;
import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_SILENT;

import android.annotation.Nullable;
import android.service.notification.StatusBarNotification;

@@ -23,6 +30,7 @@ import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.logging.nano.Notifications;
import com.android.systemui.statusbar.notification.stack.PriorityBucket;

import java.util.List;
/**
@@ -84,7 +92,7 @@ public interface NotificationPanelLogger {
                if (n.getNotification() != null) {
                    proto.isGroupSummary = n.getNotification().isGroupSummary();
                }
                proto.section = 1 + ne.getBucket();  // We want 0 to mean not set / unknown
                proto.section = toNotificationSection(ne.getBucket());
                proto_array[i] = proto;
            }
            ++i;
@@ -92,4 +100,25 @@ public interface NotificationPanelLogger {
        notificationList.notifications = proto_array;
        return notificationList;
    }

    /**
     * Maps PriorityBucket enum to Notification.SECTION constant. The two lists should generally
     * use matching names, but the values may differ, because PriorityBucket order changes from
     * time to time, while logs need to have stable meanings.
     * @param bucket PriorityBucket constant
     * @return Notification.SECTION constant
     */
    static int toNotificationSection(@PriorityBucket int bucket) {
        switch(bucket) {
            case BUCKET_MEDIA_CONTROLS : return Notifications.Notification.SECTION_MEDIA_CONTROLS;
            case BUCKET_HEADS_UP: return Notifications.Notification.SECTION_HEADS_UP;
            case BUCKET_FOREGROUND_SERVICE:
                return Notifications.Notification.SECTION_FOREGROUND_SERVICE;
            case BUCKET_PEOPLE: return Notifications.Notification.SECTION_PEOPLE;
            case BUCKET_ALERTING: return Notifications.Notification.SECTION_ALERTING;
            case BUCKET_SILENT: return Notifications.Notification.SECTION_SILENT;
        }
        return Notifications.Notification.SECTION_UNKNOWN;
    }

}
+7 −4
Original line number Diff line number Diff line
@@ -33,13 +33,16 @@ message Notification {
    optional bool is_group_summary = 5;

    // The section of the shade that the notification is in.
    // See NotificationSectionsManager.PriorityBucket.
    // Sections follow NotificationSectionsManager.PriorityBucket but enum constants do not,
    // as PriorityBucket order changes from time to time, while logs need to have stable meanings.
    enum NotificationSection {
        SECTION_UNKNOWN = 0;
        SECTION_HEADS_UP = 1;
        SECTION_PEOPLE = 2;
        SECTION_ALERTING = 3;
        SECTION_SILENT = 4;
        SECTION_MEDIA_CONTROLS = 2;
        SECTION_PEOPLE = 3;
        SECTION_ALERTING = 4;
        SECTION_SILENT = 5;
        SECTION_FOREGROUND_SERVICE = 6;
    }
    optional NotificationSection section = 6;
}
+2 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.statusbar.notification.logging;

import static com.android.systemui.statusbar.notification.stack.NotificationSectionsManagerKt.BUCKET_ALERTING;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -200,7 +198,7 @@ public class NotificationLoggerTest extends SysuiTestCase {
        assertEquals(TEST_UID, n.uid);
        assertEquals(1, n.instanceId);
        assertFalse(n.isGroupSummary);
        assertEquals(1 + BUCKET_ALERTING, n.section);
        assertEquals(Notifications.Notification.SECTION_ALERTING, n.section);
    }

    @Test
@@ -217,7 +215,7 @@ public class NotificationLoggerTest extends SysuiTestCase {
        assertEquals(TEST_UID, n.uid);
        assertEquals(1, n.instanceId);
        assertFalse(n.isGroupSummary);
        assertEquals(1 + BUCKET_ALERTING, n.section);
        assertEquals(Notifications.Notification.SECTION_ALERTING, n.section);
    }