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

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

Allow delegates to see the notifications they post

Via getActiveNotifications().

Test: cts
Bug: 116512137
Change-Id: Ic5a95725ab4297b25d75d375f6fdb2bd34b55306
parent 1519a9a9
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1759,12 +1759,17 @@ public class NotificationManager {
     * Recover a list of active notifications: ones that have been posted by the calling app that
     * have not yet been dismissed by the user or {@link #cancel(String, int)}ed by the app.
     *
     * Each notification is embedded in a {@link StatusBarNotification} object, including the
     * <p><Each notification is embedded in a {@link StatusBarNotification} object, including the
     * original <code>tag</code> and <code>id</code> supplied to
     * {@link #notify(String, int, Notification) notify()}
     * (via {@link StatusBarNotification#getTag() getTag()} and
     * {@link StatusBarNotification#getId() getId()}) as well as a copy of the original
     * {@link Notification} object (via {@link StatusBarNotification#getNotification()}).
     * </p>
     * <p>From {@link Build.VERSION_CODES#Q}, will also return notifications you've posted as an
     * app's notification delegate via
     * {@link NotificationManager#notifyAsPackage(String, String, int, Notification)}.
     * </p>
     *
     * @return An array of {@link StatusBarNotification}.
     */
+16 −10
Original line number Diff line number Diff line
@@ -2632,6 +2632,10 @@ public class NotificationManagerService extends SystemService {
         * Note that since notification posting is done asynchronously, this will not return
         * notifications that are in the process of being posted.
         *
         * From {@link Build.VERSION_CODES#Q}, will also return notifications you've posted as
         * an app's notification delegate via
         * {@link NotificationManager#notifyAsPackage(String, String, int, Notification)}.
         *
         * @returns A list of all the package's notifications, in natural order.
         */
        @Override
@@ -2674,7 +2678,8 @@ public class NotificationManagerService extends SystemService {

        private StatusBarNotification sanitizeSbn(String pkg, int userId,
                StatusBarNotification sbn) {
            if (sbn.getPackageName().equals(pkg) && sbn.getUserId() == userId) {
            if (sbn.getUserId() == userId) {
                if (sbn.getPackageName().equals(pkg) || sbn.getOpPkg().equals(pkg)) {
                    // We could pass back a cloneLight() but clients might get confused and
                    // try to send this thing back to notify() again, which would not work
                    // very well.
@@ -2685,6 +2690,7 @@ public class NotificationManagerService extends SystemService {
                            sbn.getNotification().clone(),
                            sbn.getUser(), sbn.getOverrideGroupKey(), sbn.getPostTime());
                }
            }
            return null;
        }