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

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

Early checks to avoid unneeded binder calls

We check in NMS also, in case some talks to INotificationManager,
but we should bail in the client process if we can, because there are
many apps that frequently try to delete any notificationchannel that
doesn't match their current desired set

Test: NotificationAssistantServiceTest
Flag: android.service.notification.notification_classification
Fixes: 362327403
Change-Id: Ie118e478b4dc0b2b8ac91fdabd3fccda67c3366a
parent e1b76619
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app;

import static android.service.notification.Flags.notificationClassification;

import android.annotation.CallbackExecutor;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
@@ -752,6 +754,11 @@ public class NotificationManager {
        INotificationManager service = getService();
        String pkg = mContext.getPackageName();

        if (notificationClassification()
                && NotificationChannel.SYSTEM_RESERVED_IDS.contains(notification.getChannelId())) {
            return;
        }

        try {
            if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")");
            service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id,
@@ -1131,6 +1138,10 @@ public class NotificationManager {
     * had before it was deleted.
     */
    public void deleteNotificationChannel(String channelId) {
        if (notificationClassification()
                && NotificationChannel.SYSTEM_RESERVED_IDS.contains(channelId)) {
            return;
        }
        INotificationManager service = getService();
        try {
            service.deleteNotificationChannel(mContext.getPackageName(), channelId);