Loading core/java/android/app/NotificationHistory.java +3 −1 Original line number Diff line number Diff line Loading @@ -315,7 +315,9 @@ public final class NotificationHistory implements Parcelable { for (int i = 0; i < mNotificationsToWrite.size(); i++) { final HistoricalNotification notification = mNotificationsToWrite.get(i); mStringsToWrite.add(notification.getPackage()); if (!TextUtils.isEmpty(notification.getChannelName())) { mStringsToWrite.add(notification.getChannelName()); } mStringsToWrite.add(notification.getChannelId()); if (!TextUtils.isEmpty(notification.getConversationId())) { mStringsToWrite.add(notification.getConversationId()); Loading services/core/java/com/android/server/notification/NotificationHistoryManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -248,7 +248,7 @@ public class NotificationHistoryManager { final NotificationHistoryDatabase userHistory = getUserHistoryAndInitializeIfNeededLocked(notification.getUserId()); if (userHistory == null) { Slog.w(TAG, "Attempted to add notif for locked/gone/disabled user " Slog.v(TAG, "Attempted to add notif for locked/gone/disabled user " + notification.getUserId()); return; } Loading services/core/java/com/android/server/notification/NotificationHistoryProtoHelper.java +14 −9 Original line number Diff line number Diff line Loading @@ -106,8 +106,10 @@ final class NotificationHistoryProtoHelper { break; case (int) Notification.CHANNEL_NAME: String channelName = parser.readString(Notification.CHANNEL_NAME); if (!TextUtils.isEmpty(channelName)) { notification.setChannelName(channelName); stringPool.add(channelName); } break; case (int) Notification.CHANNEL_NAME_INDEX: notification.setChannelName(stringPool.get(parser.readInt( Loading Loading @@ -266,7 +268,9 @@ final class NotificationHistoryProtoHelper { + ") not found in string cache"); proto.write(Notification.PACKAGE, notification.getPackage()); } final int channelNameIndex = Arrays.binarySearch(stringPool, notification.getChannelName()); if (!TextUtils.isEmpty(notification.getChannelName())) { final int channelNameIndex = Arrays.binarySearch(stringPool, notification.getChannelName()); if (channelNameIndex >= 0) { proto.write(Notification.CHANNEL_NAME_INDEX, channelNameIndex + 1); } else { Loading @@ -274,6 +278,7 @@ final class NotificationHistoryProtoHelper { + ") not found in string cache"); proto.write(Notification.CHANNEL_NAME, notification.getChannelName()); } } final int channelIdIndex = Arrays.binarySearch(stringPool, notification.getChannelId()); if (channelIdIndex >= 0) { proto.write(Notification.CHANNEL_ID_INDEX, channelIdIndex + 1); Loading services/core/java/com/android/server/notification/NotificationManagerService.java +13 −6 Original line number Diff line number Diff line Loading @@ -3879,23 +3879,30 @@ public class NotificationManagerService extends SystemService { @GuardedBy("mNotificationLock") protected void maybeRecordInterruptionLocked(NotificationRecord r) { if (r.isInterruptive() && !r.hasRecordedInterruption()) { String channelId = r.getChannel().getId(); if (android.app.Flags.notificationClassificationUi()) { channelId = r.getNotification().getChannelId(); } mAppUsageStats.reportInterruptiveNotification(r.getSbn().getPackageName(), r.getChannel().getId(), channelId, getRealUserId(r.getSbn().getUserId())); Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "notifHistoryAddItem"); try { if (r.getNotification().getSmallIcon() != null) { mHistoryManager.addNotification(new HistoricalNotification.Builder() final HistoricalNotification.Builder builder = new HistoricalNotification.Builder() .setPackage(r.getSbn().getPackageName()) .setUid(r.getSbn().getUid()) .setUserId(r.getSbn().getNormalizedUserId()) .setChannelId(r.getChannel().getId()) .setChannelName(r.getChannel().getName().toString()) .setChannelId(channelId) .setPostedTimeMs(System.currentTimeMillis()) .setTitle(getHistoryTitle(r.getNotification())) .setText(getHistoryText(r.getNotification())) .setIcon(r.getNotification().getSmallIcon()) .build()); .setIcon(r.getNotification().getSmallIcon()); if (!android.app.Flags.notificationClassificationUi()) { builder.setChannelName(r.getChannel().getName().toString()); } mHistoryManager.addNotification(builder.build()); } } finally { Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER); Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationHistoryProtoHelperTest.java +19 −6 Original line number Diff line number Diff line Loading @@ -49,7 +49,10 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { } private HistoricalNotification getHistoricalNotification(String packageName, int index) { String expectedChannelName = "channelName" + index; String expectedChannelName = null; if (index % 2 == 0) { expectedChannelName = "channelName" + index; } String expectedChannelId = "channelId" + index; int expectedUid = 1123456 + index; int expectedUserId = 11 + index; Loading Loading @@ -143,7 +146,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { if (i % 2 == 0) { expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (!TextUtils.isEmpty(n.getConversationId())) { expectedStrings.add(n.getConversationId()); Loading Loading @@ -185,7 +190,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { if (i <= maxCount) { expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (!TextUtils.isEmpty(n.getConversationId())) { expectedStrings.add(n.getConversationId()); Loading Loading @@ -237,7 +244,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { if (i <= (maxCount - 2)) { expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (n.getConversationId() != null) { expectedStrings.add(n.getConversationId()); Loading Loading @@ -277,7 +286,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { HistoricalNotification n = getHistoricalNotification(i); expectedEntries.add(n); expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (n.getConversationId() != null) { expectedStrings.add(n.getConversationId()); Loading @@ -295,7 +306,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { HistoricalNotification n = getHistoricalNotification(i); expectedEntries.add(n); expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (n.getConversationId() != null) { expectedStrings.add(n.getConversationId()); Loading Loading
core/java/android/app/NotificationHistory.java +3 −1 Original line number Diff line number Diff line Loading @@ -315,7 +315,9 @@ public final class NotificationHistory implements Parcelable { for (int i = 0; i < mNotificationsToWrite.size(); i++) { final HistoricalNotification notification = mNotificationsToWrite.get(i); mStringsToWrite.add(notification.getPackage()); if (!TextUtils.isEmpty(notification.getChannelName())) { mStringsToWrite.add(notification.getChannelName()); } mStringsToWrite.add(notification.getChannelId()); if (!TextUtils.isEmpty(notification.getConversationId())) { mStringsToWrite.add(notification.getConversationId()); Loading
services/core/java/com/android/server/notification/NotificationHistoryManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -248,7 +248,7 @@ public class NotificationHistoryManager { final NotificationHistoryDatabase userHistory = getUserHistoryAndInitializeIfNeededLocked(notification.getUserId()); if (userHistory == null) { Slog.w(TAG, "Attempted to add notif for locked/gone/disabled user " Slog.v(TAG, "Attempted to add notif for locked/gone/disabled user " + notification.getUserId()); return; } Loading
services/core/java/com/android/server/notification/NotificationHistoryProtoHelper.java +14 −9 Original line number Diff line number Diff line Loading @@ -106,8 +106,10 @@ final class NotificationHistoryProtoHelper { break; case (int) Notification.CHANNEL_NAME: String channelName = parser.readString(Notification.CHANNEL_NAME); if (!TextUtils.isEmpty(channelName)) { notification.setChannelName(channelName); stringPool.add(channelName); } break; case (int) Notification.CHANNEL_NAME_INDEX: notification.setChannelName(stringPool.get(parser.readInt( Loading Loading @@ -266,7 +268,9 @@ final class NotificationHistoryProtoHelper { + ") not found in string cache"); proto.write(Notification.PACKAGE, notification.getPackage()); } final int channelNameIndex = Arrays.binarySearch(stringPool, notification.getChannelName()); if (!TextUtils.isEmpty(notification.getChannelName())) { final int channelNameIndex = Arrays.binarySearch(stringPool, notification.getChannelName()); if (channelNameIndex >= 0) { proto.write(Notification.CHANNEL_NAME_INDEX, channelNameIndex + 1); } else { Loading @@ -274,6 +278,7 @@ final class NotificationHistoryProtoHelper { + ") not found in string cache"); proto.write(Notification.CHANNEL_NAME, notification.getChannelName()); } } final int channelIdIndex = Arrays.binarySearch(stringPool, notification.getChannelId()); if (channelIdIndex >= 0) { proto.write(Notification.CHANNEL_ID_INDEX, channelIdIndex + 1); Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +13 −6 Original line number Diff line number Diff line Loading @@ -3879,23 +3879,30 @@ public class NotificationManagerService extends SystemService { @GuardedBy("mNotificationLock") protected void maybeRecordInterruptionLocked(NotificationRecord r) { if (r.isInterruptive() && !r.hasRecordedInterruption()) { String channelId = r.getChannel().getId(); if (android.app.Flags.notificationClassificationUi()) { channelId = r.getNotification().getChannelId(); } mAppUsageStats.reportInterruptiveNotification(r.getSbn().getPackageName(), r.getChannel().getId(), channelId, getRealUserId(r.getSbn().getUserId())); Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "notifHistoryAddItem"); try { if (r.getNotification().getSmallIcon() != null) { mHistoryManager.addNotification(new HistoricalNotification.Builder() final HistoricalNotification.Builder builder = new HistoricalNotification.Builder() .setPackage(r.getSbn().getPackageName()) .setUid(r.getSbn().getUid()) .setUserId(r.getSbn().getNormalizedUserId()) .setChannelId(r.getChannel().getId()) .setChannelName(r.getChannel().getName().toString()) .setChannelId(channelId) .setPostedTimeMs(System.currentTimeMillis()) .setTitle(getHistoryTitle(r.getNotification())) .setText(getHistoryText(r.getNotification())) .setIcon(r.getNotification().getSmallIcon()) .build()); .setIcon(r.getNotification().getSmallIcon()); if (!android.app.Flags.notificationClassificationUi()) { builder.setChannelName(r.getChannel().getName().toString()); } mHistoryManager.addNotification(builder.build()); } } finally { Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER); Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationHistoryProtoHelperTest.java +19 −6 Original line number Diff line number Diff line Loading @@ -49,7 +49,10 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { } private HistoricalNotification getHistoricalNotification(String packageName, int index) { String expectedChannelName = "channelName" + index; String expectedChannelName = null; if (index % 2 == 0) { expectedChannelName = "channelName" + index; } String expectedChannelId = "channelId" + index; int expectedUid = 1123456 + index; int expectedUserId = 11 + index; Loading Loading @@ -143,7 +146,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { if (i % 2 == 0) { expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (!TextUtils.isEmpty(n.getConversationId())) { expectedStrings.add(n.getConversationId()); Loading Loading @@ -185,7 +190,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { if (i <= maxCount) { expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (!TextUtils.isEmpty(n.getConversationId())) { expectedStrings.add(n.getConversationId()); Loading Loading @@ -237,7 +244,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { if (i <= (maxCount - 2)) { expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (n.getConversationId() != null) { expectedStrings.add(n.getConversationId()); Loading Loading @@ -277,7 +286,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { HistoricalNotification n = getHistoricalNotification(i); expectedEntries.add(n); expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (n.getConversationId() != null) { expectedStrings.add(n.getConversationId()); Loading @@ -295,7 +306,9 @@ public class NotificationHistoryProtoHelperTest extends UiServiceTestCase { HistoricalNotification n = getHistoricalNotification(i); expectedEntries.add(n); expectedStrings.add(n.getPackage()); if (i % 2 == 0) { expectedStrings.add(n.getChannelName()); } expectedStrings.add(n.getChannelId()); if (n.getConversationId() != null) { expectedStrings.add(n.getConversationId()); Loading