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

Commit 46d7f71c authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Remove extra checks for media session token"

parents 9ed5fc69 9403c8e7
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -6822,13 +6822,11 @@ public class NotificationManagerService extends SystemService {


        // blocked apps
        boolean isMediaNotification = n.isMediaNotification()
                && n.extras.getParcelable(Notification.EXTRA_MEDIA_SESSION) != null;
        boolean isBlocked = !areNotificationsEnabledForPackageInt(pkg, uid);
        synchronized (mNotificationLock) {
            isBlocked |= isRecordBlockedLocked(r);
        }
        if (isBlocked && !isMediaNotification) {
        if (isBlocked && !n.isMediaNotification()) {
            if (DBG) {
                Slog.e(TAG, "Suppressing notification from package " + r.getSbn().getPackageName()
                        + " by user request.");
@@ -7217,10 +7215,8 @@ public class NotificationManagerService extends SystemService {
                    final StatusBarNotification n = r.getSbn();
                    final Notification notification = n.getNotification();

                    boolean isMediaNotification = notification.isMediaNotification()
                            && notification.extras.getParcelable(
                                    Notification.EXTRA_MEDIA_SESSION) != null;
                    if (!isMediaNotification && (appBanned || isRecordBlockedLocked(r))) {
                    if (!notification.isMediaNotification()
                            && (appBanned || isRecordBlockedLocked(r))) {
                        mUsageStats.registerBlocked(r);
                        if (DBG) {
                            Slog.e(TAG, "Suppressing notification from package " + pkg);
+12 −0
Original line number Diff line number Diff line
@@ -8508,6 +8508,18 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);

        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();

        // using the style, but incorrect type in session - blocked
        nb.setStyle(new Notification.MediaStyle());
        Bundle extras = new Bundle();
        extras.putParcelable(Notification.EXTRA_MEDIA_SESSION, new Intent());
        nb.addExtras(extras);
        sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0,
                nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);

        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();

+13 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ import android.media.AudioManager;
import android.media.session.MediaSession;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
import android.os.Process;
@@ -743,6 +744,18 @@ public class NotificationPermissionMigrationTest extends UiServiceTestCase {
                nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);

        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();

        // using the style, but incorrect type in session - blocked
        nb.setStyle(new Notification.MediaStyle());
        Bundle extras = new Bundle();
        extras.putParcelable(Notification.EXTRA_MEDIA_SESSION, new Intent());
        nb.addExtras(extras);
        sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0,
                nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);

        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();