Loading core/java/android/service/notification/StatusBarNotification.java +4 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; import com.android.internal.logging.nano.MetricsProto; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; /** Loading Loading @@ -410,7 +411,9 @@ public class StatusBarNotification implements Parcelable { .clearSubtype() .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_ID, getGroupLogTag()) .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_SUMMARY, getNotification().isGroupSummary() ? 1 : 0); getNotification().isGroupSummary() ? 1 : 0) .addTaggedData(MetricsProto.MetricsEvent.FIELD_NOTIFICATION_CATEGORY, getNotification().category); } private String getGroupLogTag() { Loading core/tests/coretests/src/android/service/notification/StatusBarNotificationTest.java +21 −3 Original line number Diff line number Diff line Loading @@ -77,7 +77,6 @@ public class StatusBarNotificationTest { @Test public void testLogMaker() { final LogMaker logMaker = getNotification(PKG, GROUP_ID_1, CHANNEL_ID).getLogMaker(); assertEquals(CHANNEL_ID, (String) logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_CHANNEL_ID)); assertEquals(PKG, logMaker.getPackageName()); Loading @@ -85,6 +84,18 @@ public class StatusBarNotificationTest { assertEquals(TAG, logMaker.getTaggedData(MetricsEvent.NOTIFICATION_TAG)); assertEquals(GROUP_ID_1, logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_ID)); assertEquals(0, logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_SUMMARY)); assertNull(logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_CATEGORY)); } @Test public void testLogMakerWithCategory() { Notification.Builder builder = getNotificationBuilder(GROUP_ID_1, CHANNEL_ID) .setCategory(Notification.CATEGORY_MESSAGE); final LogMaker logMaker = getNotification(PKG, builder).getLogMaker(); assertEquals(Notification.CATEGORY_MESSAGE, logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_CATEGORY)); } @Test Loading Loading @@ -138,6 +149,10 @@ public class StatusBarNotificationTest { } private StatusBarNotification getNotification(String pkg, String group, String channelId) { return getNotification(pkg, getNotificationBuilder(group, channelId)); } private Notification.Builder getNotificationBuilder(String group, String channelId) { final Notification.Builder builder = new Notification.Builder(mMockContext, channelId) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon); Loading @@ -145,10 +160,13 @@ public class StatusBarNotificationTest { if (group != null) { builder.setGroup(group); } return builder; } private StatusBarNotification getNotification(String pkg, Notification.Builder builder) { Notification n = builder.build(); return new StatusBarNotification( pkg, pkg, ID, TAG, UID, UID, n, USER, null, UID); pkg, pkg, ID, TAG, UID, UID, builder.build(), USER, null, UID); } } proto/src/metrics_constants/metrics_constants.proto +6 −0 Original line number Diff line number Diff line Loading @@ -6904,6 +6904,12 @@ message MetricsEvent { // OS: Q FIELD_TEXT_CLASSIFIER_WIDGET_VERSION = 1640; // Tagged data for NOTIFICATION_ITEM. One of the CATEGORY String constants from // https://developer.android.com/reference/android/app/Notification . // OS: Q // CATEGORY: NOTIFICATION FIELD_NOTIFICATION_CATEGORY = 1641; // ---- End Q Constants, all Q constants go above this line ---- // Add new aosp constants above this line. // END OF AOSP CONSTANTS Loading Loading
core/java/android/service/notification/StatusBarNotification.java +4 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; import com.android.internal.logging.nano.MetricsProto; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; /** Loading Loading @@ -410,7 +411,9 @@ public class StatusBarNotification implements Parcelable { .clearSubtype() .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_ID, getGroupLogTag()) .addTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_SUMMARY, getNotification().isGroupSummary() ? 1 : 0); getNotification().isGroupSummary() ? 1 : 0) .addTaggedData(MetricsProto.MetricsEvent.FIELD_NOTIFICATION_CATEGORY, getNotification().category); } private String getGroupLogTag() { Loading
core/tests/coretests/src/android/service/notification/StatusBarNotificationTest.java +21 −3 Original line number Diff line number Diff line Loading @@ -77,7 +77,6 @@ public class StatusBarNotificationTest { @Test public void testLogMaker() { final LogMaker logMaker = getNotification(PKG, GROUP_ID_1, CHANNEL_ID).getLogMaker(); assertEquals(CHANNEL_ID, (String) logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_CHANNEL_ID)); assertEquals(PKG, logMaker.getPackageName()); Loading @@ -85,6 +84,18 @@ public class StatusBarNotificationTest { assertEquals(TAG, logMaker.getTaggedData(MetricsEvent.NOTIFICATION_TAG)); assertEquals(GROUP_ID_1, logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_ID)); assertEquals(0, logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_GROUP_SUMMARY)); assertNull(logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_CATEGORY)); } @Test public void testLogMakerWithCategory() { Notification.Builder builder = getNotificationBuilder(GROUP_ID_1, CHANNEL_ID) .setCategory(Notification.CATEGORY_MESSAGE); final LogMaker logMaker = getNotification(PKG, builder).getLogMaker(); assertEquals(Notification.CATEGORY_MESSAGE, logMaker.getTaggedData(MetricsEvent.FIELD_NOTIFICATION_CATEGORY)); } @Test Loading Loading @@ -138,6 +149,10 @@ public class StatusBarNotificationTest { } private StatusBarNotification getNotification(String pkg, String group, String channelId) { return getNotification(pkg, getNotificationBuilder(group, channelId)); } private Notification.Builder getNotificationBuilder(String group, String channelId) { final Notification.Builder builder = new Notification.Builder(mMockContext, channelId) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon); Loading @@ -145,10 +160,13 @@ public class StatusBarNotificationTest { if (group != null) { builder.setGroup(group); } return builder; } private StatusBarNotification getNotification(String pkg, Notification.Builder builder) { Notification n = builder.build(); return new StatusBarNotification( pkg, pkg, ID, TAG, UID, UID, n, USER, null, UID); pkg, pkg, ID, TAG, UID, UID, builder.build(), USER, null, UID); } }
proto/src/metrics_constants/metrics_constants.proto +6 −0 Original line number Diff line number Diff line Loading @@ -6904,6 +6904,12 @@ message MetricsEvent { // OS: Q FIELD_TEXT_CLASSIFIER_WIDGET_VERSION = 1640; // Tagged data for NOTIFICATION_ITEM. One of the CATEGORY String constants from // https://developer.android.com/reference/android/app/Notification . // OS: Q // CATEGORY: NOTIFICATION FIELD_NOTIFICATION_CATEGORY = 1641; // ---- End Q Constants, all Q constants go above this line ---- // Add new aosp constants above this line. // END OF AOSP CONSTANTS Loading