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

Commit d2f82a15 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Remove SBNHolder" into main

parents 4ec85a58 c7ad530e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -268,3 +268,10 @@ flag {
  description: "Adds UI for NAS classification of notifications"
  bug: "367996732"
}

flag {
  name: "no_sbnholder"
  namespace: "systemui"
  description: "removes sbnholder from NLS"
  bug: "362981561"
}
+6 −0
Original line number Diff line number Diff line
@@ -34,10 +34,14 @@ oneway interface INotificationListener
    void onListenerConnected(in NotificationRankingUpdate update);
    void onNotificationPosted(in IStatusBarNotificationHolder notificationHolder,
            in NotificationRankingUpdate update);
    void onNotificationPostedFull(in StatusBarNotification sbn,
            in NotificationRankingUpdate update);
    void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons);
    // stats only for assistant
    void onNotificationRemoved(in IStatusBarNotificationHolder notificationHolder,
            in NotificationRankingUpdate update, in NotificationStats stats, int reason);
    void onNotificationRemovedFull(in StatusBarNotification sbn,
                in NotificationRankingUpdate update, in NotificationStats stats, int reason);
    void onNotificationRankingUpdate(in NotificationRankingUpdate update);
    void onListenerHintsChanged(int hints);
    void onInterruptionFilterChanged(int interruptionFilter);
@@ -48,7 +52,9 @@ oneway interface INotificationListener

    // assistants only
    void onNotificationEnqueuedWithChannel(in IStatusBarNotificationHolder notificationHolder, in NotificationChannel channel, in NotificationRankingUpdate update);
    void onNotificationEnqueuedWithChannelFull(in StatusBarNotification sbn, in NotificationChannel channel, in NotificationRankingUpdate update);
    void onNotificationSnoozedUntilContext(in IStatusBarNotificationHolder notificationHolder, String snoozeCriterionId);
    void onNotificationSnoozedUntilContextFull(in StatusBarNotification sbn, String snoozeCriterionId);
    void onNotificationsSeen(in List<String> keys);
    void onPanelRevealed(int items);
    void onPanelHidden();
+10 −0
Original line number Diff line number Diff line
@@ -423,7 +423,12 @@ public abstract class NotificationAssistantService extends NotificationListenerS
                        + "Error receiving StatusBarNotification");
                return;
            }
            onNotificationEnqueuedWithChannelFull(sbn, channel, update);
        }

        @Override
        public void onNotificationEnqueuedWithChannelFull(StatusBarNotification sbn,
                NotificationChannel channel, NotificationRankingUpdate update) {
            applyUpdateLocked(update);
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = sbn;
@@ -447,7 +452,12 @@ public abstract class NotificationAssistantService extends NotificationListenerS
                Log.w(TAG, "onNotificationSnoozed: Error receiving StatusBarNotification");
                return;
            }
            onNotificationSnoozedUntilContextFull(sbn, snoozeCriterionId);
        }

        @Override
        public void onNotificationSnoozedUntilContextFull(
                StatusBarNotification sbn, String snoozeCriterionId) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = sbn;
            args.arg2 = snoozeCriterionId;
+26 −3
Original line number Diff line number Diff line
@@ -1490,7 +1490,12 @@ public abstract class NotificationListenerService extends Service {
                Log.w(TAG, "onNotificationPosted: Error receiving StatusBarNotification");
                return;
            }
            onNotificationPostedFull(sbn, update);
        }

        @Override
        public void onNotificationPostedFull(StatusBarNotification sbn,
                NotificationRankingUpdate update) {
            try {
                // convert icon metadata to legacy format for older clients
                createLegacyIconExtras(sbn.getNotification());
@@ -1518,7 +1523,6 @@ public abstract class NotificationListenerService extends Service {
                            mRankingMap).sendToTarget();
                }
            }

        }

        @Override
@@ -1531,6 +1535,12 @@ public abstract class NotificationListenerService extends Service {
                Log.w(TAG, "onNotificationRemoved: Error receiving StatusBarNotification", e);
                return;
            }
            onNotificationRemovedFull(sbn, update, stats, reason);
        }

        @Override
        public void onNotificationRemovedFull(StatusBarNotification sbn,
                NotificationRankingUpdate update, NotificationStats stats, int reason) {
            if (sbn == null) {
                Log.w(TAG, "onNotificationRemoved: Error receiving StatusBarNotification");
                return;
@@ -1591,6 +1601,14 @@ public abstract class NotificationListenerService extends Service {
            // no-op in the listener
        }

        @Override
        public void onNotificationEnqueuedWithChannelFull(
                StatusBarNotification sbn, NotificationChannel channel,
                NotificationRankingUpdate update)
                throws RemoteException {
            // no-op in the listener
        }

        @Override
        public void onNotificationsSeen(List<String> keys)
                throws RemoteException {
@@ -1620,6 +1638,13 @@ public abstract class NotificationListenerService extends Service {
            // no-op in the listener
        }

        @Override
        public void onNotificationSnoozedUntilContextFull(
                StatusBarNotification sbn, String snoozeCriterionId)
                throws RemoteException {
            // no-op in the listener
        }

        @Override
        public void onNotificationExpansionChanged(
                String key, boolean isUserAction, boolean isExpanded) {
@@ -1688,8 +1713,6 @@ public abstract class NotificationListenerService extends Service {
                Bundle feedback) {
            // no-op in the listener
        }


    }

    /**
+41 −25
Original line number Diff line number Diff line
@@ -11937,16 +11937,19 @@ public class NotificationManagerService extends SystemService {
                    TrimCache trimCache = new TrimCache(sbn);
                    final INotificationListener assistant = (INotificationListener) info.service;
                    final StatusBarNotification sbnToPost = trimCache.ForListener(info);
                    final NotificationRankingUpdate update = makeRankingUpdateLocked(info);
                    try {
                        if (android.app.Flags.noSbnholder()) {
                            assistant.onNotificationEnqueuedWithChannelFull(sbnToPost,
                                    r.getChannel(), update);
                        } else {
                            final StatusBarNotificationHolder sbnHolder =
                                    new StatusBarNotificationHolder(sbnToPost);
                    try {
                        if (debug) {
                            Slog.v(TAG,
                                    "calling onNotificationEnqueuedWithChannel " + sbnHolder);
                        }
                        final NotificationRankingUpdate update = makeRankingUpdateLocked(info);
                            assistant.onNotificationEnqueuedWithChannel(sbnHolder, r.getChannel(),
                                    update);
                        }
                    } catch (RemoteException ex) {
                        Slog.e(TAG, "unable to notify assistant (enqueued): " + assistant, ex);
                    }
@@ -11966,7 +11969,7 @@ public class NotificationManagerService extends SystemService {
                    r.getSbn(),
                    r.getNotificationType(),
                    true /* sameUserOnly */,
                    (assistant, sbnHolder) -> {
                    (assistant, unused) -> {
                        try {
                            assistant.onNotificationVisibilityChanged(key, isVisible);
                        } catch (RemoteException ex) {
@@ -11986,7 +11989,7 @@ public class NotificationManagerService extends SystemService {
                    sbn,
                    notificationType,
                    true /* sameUserOnly */,
                    (assistant, sbnHolder) -> {
                    (assistant, unused) -> {
                        try {
                            assistant.onNotificationExpansionChanged(key, isUserAction, isExpanded);
                        } catch (RemoteException ex) {
@@ -12003,7 +12006,7 @@ public class NotificationManagerService extends SystemService {
                    r.getSbn(),
                    r.getNotificationType(),
                    true /* sameUserOnly */,
                    (assistant, sbnHolder) -> {
                    (assistant, unused) -> {
                        try {
                            assistant.onNotificationDirectReply(key);
                        } catch (RemoteException ex) {
@@ -12021,7 +12024,7 @@ public class NotificationManagerService extends SystemService {
                    sbn,
                    notificationType,
                    true /* sameUserOnly */,
                    (assistant, sbnHolder) -> {
                    (assistant, unused) -> {
                        try {
                            assistant.onSuggestedReplySent(
                                    key,
@@ -12044,7 +12047,7 @@ public class NotificationManagerService extends SystemService {
                    r.getSbn(),
                    r.getNotificationType(),
                    true /* sameUserOnly */,
                    (assistant, sbnHolder) -> {
                    (assistant, unused) -> {
                        try {
                            assistant.onActionClicked(
                                    key,
@@ -12069,10 +12072,17 @@ public class NotificationManagerService extends SystemService {
                    r.getSbn(),
                    r.getNotificationType(),
                    true /* sameUserOnly */,
                    (assistant, sbnHolder) -> {
                    (assistant, sbnToPost) -> {
                        try {
                            if (android.app.Flags.noSbnholder()) {
                                assistant.onNotificationSnoozedUntilContextFull(
                                        sbnToPost, snoozeCriterionId);
                            } else {
                                final StatusBarNotificationHolder sbnHolder =
                                        new StatusBarNotificationHolder(sbnToPost);
                                assistant.onNotificationSnoozedUntilContext(
                                        sbnHolder, snoozeCriterionId);
                            }
                        } catch (RemoteException ex) {
                            Slog.e(TAG, "unable to notify assistant (snoozed): " + assistant, ex);
                        }
@@ -12086,7 +12096,7 @@ public class NotificationManagerService extends SystemService {
                    r.getSbn(),
                    r.getNotificationType(),
                    true /* sameUserOnly */,
                    (assistant, sbnHolder) -> {
                    (assistant, unused) -> {
                        try {
                            assistant.onNotificationClicked(key);
                        } catch (RemoteException ex) {
@@ -12129,7 +12139,7 @@ public class NotificationManagerService extends SystemService {
                final StatusBarNotification sbn,
                int notificationType,
                boolean sameUserOnly,
                BiConsumer<INotificationListener, StatusBarNotificationHolder> callback) {
                BiConsumer<INotificationListener, StatusBarNotification> callback) {
            TrimCache trimCache = new TrimCache(sbn);
            // There should be only one, but it's a list, so while we enforce
            // singularity elsewhere, we keep it general here, to avoid surprises.
@@ -12151,9 +12161,7 @@ public class NotificationManagerService extends SystemService {
                }
                final INotificationListener assistant = (INotificationListener) info.service;
                final StatusBarNotification sbnToPost = trimCache.ForListener(info);
                final StatusBarNotificationHolder sbnHolder =
                        new StatusBarNotificationHolder(sbnToPost);
                mHandler.post(() -> callback.accept(assistant, sbnHolder));
                mHandler.post(() -> callback.accept(assistant, sbnToPost));
            }
        }
@@ -13399,9 +13407,13 @@ public class NotificationManagerService extends SystemService {
        private void notifyPosted(final ManagedServiceInfo info,
                final StatusBarNotification sbn, NotificationRankingUpdate rankingUpdate) {
            final INotificationListener listener = (INotificationListener) info.service;
            StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
            try {
                if (android.app.Flags.noSbnholder()) {
                    listener.onNotificationPostedFull(sbn, rankingUpdate);
                } else {
                    StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
                    listener.onNotificationPosted(sbnHolder, rankingUpdate);
                }
            } catch (DeadObjectException ex) {
                Slog.wtf(TAG, "unable to notify listener (posted): " + info, ex);
            } catch (RemoteException ex) {
@@ -13412,7 +13424,6 @@ public class NotificationManagerService extends SystemService {
        private void notifyRemoved(ManagedServiceInfo info, StatusBarNotification sbn,
                NotificationRankingUpdate rankingUpdate, NotificationStats stats, int reason) {
            final INotificationListener listener = (INotificationListener) info.service;
            StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
            try {
                if (!CompatChanges.isChangeEnabled(NOTIFICATION_CANCELLATION_REASONS, info.uid)
                        && (reason == REASON_CHANNEL_REMOVED || reason == REASON_CLEAR_DATA)) {
@@ -13424,7 +13435,12 @@ public class NotificationManagerService extends SystemService {
                        && reason == REASON_ASSISTANT_CANCEL) {
                    reason = REASON_LISTENER_CANCEL;
                }
                if (android.app.Flags.noSbnholder()) {
                    listener.onNotificationRemovedFull(sbn, rankingUpdate, stats, reason);
                } else {
                    StatusBarNotificationHolder sbnHolder = new StatusBarNotificationHolder(sbn);
                    listener.onNotificationRemoved(sbnHolder, rankingUpdate, stats, reason);
                }
            } catch (DeadObjectException ex) {
                Slog.wtf(TAG, "unable to notify listener (removed): " + info, ex);
            } catch (RemoteException ex) {