Loading services/core/java/com/android/server/notification/NotificationManagerService.java +3 −7 Original line number Diff line number Diff line Loading @@ -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."); Loading Loading @@ -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); Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationPermissionMigrationTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +3 −7 Original line number Diff line number Diff line Loading @@ -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."); Loading Loading @@ -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); Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationPermissionMigrationTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading