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

Commit e60537b7 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Attribute notifications to their original channels

Since the UI doesn't show channel details for bundle channels
anymore

Test: manual
Flag: android.app.notification_classification_ui
Fixes: 416040573
Change-Id: Ie086ab6b88e9ebb55d7776f734259c897a736d1c
parent 713fd43d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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());
+1 −1
Original line number Diff line number Diff line
@@ -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;
                }
+13 −6
Original line number Diff line number Diff line
@@ -3870,23 +3870,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);