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

Commit d3cd29af authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Allow call notifications to be non-dismissible" into udc-dev

parents dc9db97e fe88d699
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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) {
+25 −0
Original line number Diff line number Diff line
@@ -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