Loading services/core/java/com/android/server/notification/NotificationManagerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -6864,7 +6864,8 @@ public class NotificationManagerService extends SystemService { * A notification should be dismissible, unless it's exempted for some reason. */ private boolean canBeNonDismissible(ApplicationInfo ai, Notification notification) { return notification.isMediaNotification() || isEnterpriseExempted(ai); return notification.isMediaNotification() || isEnterpriseExempted(ai) || isCallNotification(ai.packageName, ai.uid, notification); } private boolean isEnterpriseExempted(ApplicationInfo ai) { Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -10440,6 +10440,31 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test public void fixCallNotification_withOnGoingFlag_shouldNotBeNonDismissible() throws Exception { // Given: a call notification has the flag FLAG_ONGOING_EVENT set // feature flag: ALLOW_DISMISS_ONGOING is on mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); when(mTelecomManager.isInManagedCall()).thenReturn(true); Person person = new Person.Builder() .setName("caller") .build(); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .setStyle(Notification.CallStyle.forOngoingCall( person, mock(PendingIntent.class))) .build(); // When: fix the notification with NotificationManagerService mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should be set assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test public void fixNonExemptNotification_withOnGoingFlag_shouldBeDismissible() throws Exception { // Given: a non-exempt notification has the flag FLAG_ONGOING_EVENT set Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +2 −1 Original line number Diff line number Diff line Loading @@ -6864,7 +6864,8 @@ public class NotificationManagerService extends SystemService { * A notification should be dismissible, unless it's exempted for some reason. */ private boolean canBeNonDismissible(ApplicationInfo ai, Notification notification) { return notification.isMediaNotification() || isEnterpriseExempted(ai); return notification.isMediaNotification() || isEnterpriseExempted(ai) || isCallNotification(ai.packageName, ai.uid, notification); } private boolean isEnterpriseExempted(ApplicationInfo ai) { Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -10440,6 +10440,31 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test public void fixCallNotification_withOnGoingFlag_shouldNotBeNonDismissible() throws Exception { // Given: a call notification has the flag FLAG_ONGOING_EVENT set // feature flag: ALLOW_DISMISS_ONGOING is on mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true); when(mTelecomManager.isInManagedCall()).thenReturn(true); Person person = new Person.Builder() .setName("caller") .build(); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .setStyle(Notification.CallStyle.forOngoingCall( person, mock(PendingIntent.class))) .build(); // When: fix the notification with NotificationManagerService mService.fixNotification(n, PKG, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE); // Then: the notification's flag FLAG_NO_DISMISS should be set assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test public void fixNonExemptNotification_withOnGoingFlag_shouldBeDismissible() throws Exception { // Given: a non-exempt notification has the flag FLAG_ONGOING_EVENT set Loading