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

Commit 549b7127 authored by Hui Yu's avatar Hui Yu Committed by Automerger Merge Worker
Browse files

Merge "Add a flag byForegroundService to enqueueNotification() call." into...

Merge "Add a flag byForegroundService to enqueueNotification() call." into udc-qpr-dev am: d0b8361e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24151947



Change-Id: I00a4c5c3b37e2418ac3fbe7bc4cd1d40e564db1c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents efe9e7ab d0b8361e
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -2414,7 +2414,7 @@ public final class ActiveServices {
                    // Even if the service is already a FGS, we need to update the notification,
                    // Even if the service is already a FGS, we need to update the notification,
                    // so we need to call it again.
                    // so we need to call it again.
                    signalForegroundServiceObserversLocked(r);
                    signalForegroundServiceObserversLocked(r);
                    r.postNotification();
                    r.postNotification(true);
                    if (r.app != null) {
                    if (r.app != null) {
                        updateServiceForegroundLocked(psr, true);
                        updateServiceForegroundLocked(psr, true);
                    }
                    }
@@ -2472,7 +2472,7 @@ public final class ActiveServices {
                } else if (r.appInfo.targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
                } else if (r.appInfo.targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
                    // if it's been deferred, force to visibility
                    // if it's been deferred, force to visibility
                    if (!r.mFgsNotificationShown) {
                    if (!r.mFgsNotificationShown) {
                        r.postNotification();
                        r.postNotification(false);
                    }
                    }
                    dropFgsNotificationStateLocked(r);
                    dropFgsNotificationStateLocked(r);
                    if ((flags & Service.STOP_FOREGROUND_DETACH) != 0) {
                    if ((flags & Service.STOP_FOREGROUND_DETACH) != 0) {
@@ -2916,7 +2916,7 @@ public final class ActiveServices {
                        // in the interval, so we lazy check whether we still need to show
                        // in the interval, so we lazy check whether we still need to show
                        // the notification.
                        // the notification.
                        if (r.isForeground && r.app != null) {
                        if (r.isForeground && r.app != null) {
                            r.postNotification();
                            r.postNotification(true);
                            r.mFgsNotificationShown = true;
                            r.mFgsNotificationShown = true;
                        } else {
                        } else {
                            if (DEBUG_FOREGROUND_SERVICE) {
                            if (DEBUG_FOREGROUND_SERVICE) {
@@ -5340,7 +5340,7 @@ public final class ActiveServices {
            thread.scheduleCreateService(r, r.serviceInfo,
            thread.scheduleCreateService(r, r.serviceInfo,
                    null /* compatInfo (unused but need to keep method signature) */,
                    null /* compatInfo (unused but need to keep method signature) */,
                    app.mState.getReportedProcState());
                    app.mState.getReportedProcState());
            r.postNotification();
            r.postNotification(false);
            created = true;
            created = true;
        } catch (DeadObjectException e) {
        } catch (DeadObjectException e) {
            Slog.w(TAG, "Application dead when creating service " + r);
            Slog.w(TAG, "Application dead when creating service " + r);
+2 −2
Original line number Original line Diff line number Diff line
@@ -1324,7 +1324,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
        });
        });
    }
    }


    public void postNotification() {
    public void postNotification(boolean byForegroundService) {
        if (isForeground && foregroundNoti != null && app != null) {
        if (isForeground && foregroundNoti != null && app != null) {
            final int appUid = appInfo.uid;
            final int appUid = appInfo.uid;
            final int appPid = app.getPid();
            final int appPid = app.getPid();
@@ -1432,7 +1432,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
                        }
                        }
                        nm.enqueueNotification(localPackageName, localPackageName,
                        nm.enqueueNotification(localPackageName, localPackageName,
                                appUid, appPid, null, localForegroundId, localForegroundNoti,
                                appUid, appPid, null, localForegroundId, localForegroundNoti,
                                userId);
                                userId, byForegroundService /* byForegroundService */);


                        foregroundNoti = localForegroundNoti; // save it for amending next time
                        foregroundNoti = localForegroundNoti; // save it for amending next time


+3 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,9 @@ public interface NotificationManagerInternal {
    NotificationChannelGroup getNotificationChannelGroup(String pkg, int uid, String channelId);
    NotificationChannelGroup getNotificationChannelGroup(String pkg, int uid, String channelId);
    void enqueueNotification(String pkg, String basePkg, int callingUid, int callingPid,
    void enqueueNotification(String pkg, String basePkg, int callingUid, int callingPid,
            String tag, int id, Notification notification, int userId);
            String tag, int id, Notification notification, int userId);
    void enqueueNotification(String pkg, String basePkg, int callingUid, int callingPid,
            String tag, int id, Notification notification, int userId,
            boolean byForegroundService);
    void cancelNotification(String pkg, String basePkg, int callingUid, int callingPid,
    void cancelNotification(String pkg, String basePkg, int callingUid, int callingPid,
            String tag, int id, int userId);
            String tag, int id, int userId);


+24 −13
Original line number Original line Diff line number Diff line
@@ -2531,7 +2531,8 @@ public class NotificationManagerService extends SystemService {
                }
                }
                enqueueNotificationInternal(r.getSbn().getPackageName(), r.getSbn().getOpPkg(),
                enqueueNotificationInternal(r.getSbn().getPackageName(), r.getSbn().getOpPkg(),
                        r.getSbn().getUid(), r.getSbn().getInitialPid(), r.getSbn().getTag(),
                        r.getSbn().getUid(), r.getSbn().getInitialPid(), r.getSbn().getTag(),
                        r.getSbn().getId(),  r.getSbn().getNotification(), userId, muteOnReturn);
                        r.getSbn().getId(),  r.getSbn().getNotification(), userId, muteOnReturn,
                        false /* byForegroundService */);
            } catch (Exception e) {
            } catch (Exception e) {
                Slog.e(TAG, "Cannot un-snooze notification", e);
                Slog.e(TAG, "Cannot un-snooze notification", e);
            }
            }
@@ -3526,7 +3527,8 @@ public class NotificationManagerService extends SystemService {
        public void enqueueNotificationWithTag(String pkg, String opPkg, String tag, int id,
        public void enqueueNotificationWithTag(String pkg, String opPkg, String tag, int id,
                Notification notification, int userId) throws RemoteException {
                Notification notification, int userId) throws RemoteException {
            enqueueNotificationInternal(pkg, opPkg, Binder.getCallingUid(),
            enqueueNotificationInternal(pkg, opPkg, Binder.getCallingUid(),
                    Binder.getCallingPid(), tag, id, notification, userId);
                    Binder.getCallingPid(), tag, id, notification, userId,
                    false /* byForegroundService */);
        }
        }
        @Override
        @Override
@@ -6095,7 +6097,7 @@ public class NotificationManagerService extends SystemService {
            }
            }
            if (summaryRecord != null && checkDisqualifyingFeatures(userId, uid,
            if (summaryRecord != null && checkDisqualifyingFeatures(userId, uid,
                    summaryRecord.getSbn().getId(), summaryRecord.getSbn().getTag(), summaryRecord,
                    summaryRecord.getSbn().getId(), summaryRecord.getSbn().getTag(), summaryRecord,
                    true)) {
                    true, false)) {
                return summaryRecord;
                return summaryRecord;
            }
            }
        }
        }
@@ -6424,7 +6426,15 @@ public class NotificationManagerService extends SystemService {
        public void enqueueNotification(String pkg, String opPkg, int callingUid, int callingPid,
        public void enqueueNotification(String pkg, String opPkg, int callingUid, int callingPid,
                String tag, int id, Notification notification, int userId) {
                String tag, int id, Notification notification, int userId) {
            enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id, notification,
            enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id, notification,
                    userId);
                    userId, false /* byForegroundService */);
        }
        @Override
        public void enqueueNotification(String pkg, String opPkg, int callingUid, int callingPid,
                String tag, int id, Notification notification, int userId,
                boolean byForegroundService) {
            enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id, notification,
                    userId, byForegroundService);
        }
        }
        @Override
        @Override
@@ -6602,19 +6612,19 @@ public class NotificationManagerService extends SystemService {
    void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,
    void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,
            final int callingPid, final String tag, final int id, final Notification notification,
            final int callingPid, final String tag, final int id, final Notification notification,
            int incomingUserId) {
            int incomingUserId, boolean byForegroundService) {
        enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id, notification,
        enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id, notification,
                incomingUserId, false);
                incomingUserId, false /* postSilently */, byForegroundService);
    }
    }
    void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,
    void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,
            final int callingPid, final String tag, final int id, final Notification notification,
            final int callingPid, final String tag, final int id, final Notification notification,
            int incomingUserId, boolean postSilently) {
            int incomingUserId, boolean postSilently, boolean byForegroundService) {
        PostNotificationTracker tracker = acquireWakeLockForPost(pkg, callingUid);
        PostNotificationTracker tracker = acquireWakeLockForPost(pkg, callingUid);
        boolean enqueued = false;
        boolean enqueued = false;
        try {
        try {
            enqueued = enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id,
            enqueued = enqueueNotificationInternal(pkg, opPkg, callingUid, callingPid, tag, id,
                    notification, incomingUserId, postSilently, tracker);
                    notification, incomingUserId, postSilently, tracker, byForegroundService);
        } finally {
        } finally {
            if (!enqueued) {
            if (!enqueued) {
                tracker.cancel();
                tracker.cancel();
@@ -6645,10 +6655,10 @@ public class NotificationManagerService extends SystemService {
     * @return True if we successfully processed the notification and handed off the task of
     * @return True if we successfully processed the notification and handed off the task of
     * enqueueing it to a background thread; false otherwise.
     * enqueueing it to a background thread; false otherwise.
     */
     */
    private boolean enqueueNotificationInternal(final String pkg, final String opPkg,
    private boolean enqueueNotificationInternal(final String pkg, final String opPkg,  //HUI
            final int callingUid, final int callingPid, final String tag, final int id,
            final int callingUid, final int callingPid, final String tag, final int id,
            final Notification notification, int incomingUserId, boolean postSilently,
            final Notification notification, int incomingUserId, boolean postSilently,
            PostNotificationTracker tracker) {
            PostNotificationTracker tracker, boolean byForegroundService) {
        if (DBG) {
        if (DBG) {
            Slog.v(TAG, "enqueueNotificationInternal: pkg=" + pkg + " id=" + id
            Slog.v(TAG, "enqueueNotificationInternal: pkg=" + pkg + " id=" + id
                    + " notification=" + notification);
                    + " notification=" + notification);
@@ -6794,7 +6804,7 @@ public class NotificationManagerService extends SystemService {
                mPreferencesHelper.hasUserDemotedInvalidMsgApp(pkg, notificationUid));
                mPreferencesHelper.hasUserDemotedInvalidMsgApp(pkg, notificationUid));
        if (!checkDisqualifyingFeatures(userId, notificationUid, id, tag, r,
        if (!checkDisqualifyingFeatures(userId, notificationUid, id, tag, r,
                r.getSbn().getOverrideGroupKey() != null)) {
                r.getSbn().getOverrideGroupKey() != null, byForegroundService)) {
            return false;
            return false;
        }
        }
@@ -7214,7 +7224,7 @@ public class NotificationManagerService extends SystemService {
     * Has side effects.
     * Has side effects.
     */
     */
    boolean checkDisqualifyingFeatures(int userId, int uid, int id, String tag,
    boolean checkDisqualifyingFeatures(int userId, int uid, int id, String tag,
            NotificationRecord r, boolean isAutogroup) {
            NotificationRecord r, boolean isAutogroup, boolean byForegroundService) {
        Notification n = r.getNotification();
        Notification n = r.getNotification();
        final String pkg = r.getSbn().getPackageName();
        final String pkg = r.getSbn().getPackageName();
        final boolean isSystemNotification =
        final boolean isSystemNotification =
@@ -7305,7 +7315,8 @@ public class NotificationManagerService extends SystemService {
        if (n.isStyle(Notification.CallStyle.class)) {
        if (n.isStyle(Notification.CallStyle.class)) {
            boolean hasFullScreenIntent = n.fullScreenIntent != null;
            boolean hasFullScreenIntent = n.fullScreenIntent != null;
            boolean requestedFullScreenIntent = (n.flags & FLAG_FSI_REQUESTED_BUT_DENIED) != 0;
            boolean requestedFullScreenIntent = (n.flags & FLAG_FSI_REQUESTED_BUT_DENIED) != 0;
            if (!n.isFgsOrUij() && !hasFullScreenIntent && !requestedFullScreenIntent) {
            if (!n.isFgsOrUij() && !hasFullScreenIntent && !requestedFullScreenIntent
                    && !byForegroundService) {
                throw new IllegalArgumentException(r.getKey() + " Not posted."
                throw new IllegalArgumentException(r.getKey() + " Not posted."
                        + " CallStyle notifications must be for a foreground service or"
                        + " CallStyle notifications must be for a foreground service or"
                        + " user initated job or use a fullScreenIntent.");
                        + " user initated job or use a fullScreenIntent.");
+37 −19
Original line number Original line Diff line number Diff line
@@ -10244,7 +10244,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        try {
        try {
            mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(), r.getSbn().getId(),
            mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(), r.getSbn().getId(),
                    r.getSbn().getTag(), r,false);
                    r.getSbn().getTag(), r, false, false);
            fail("Allowed a contextual direct reply with an immutable intent to be posted");
            fail("Allowed a contextual direct reply with an immutable intent to be posted");
        } catch (IllegalArgumentException e) {
        } catch (IllegalArgumentException e) {
            // good
            // good
@@ -10275,7 +10275,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r.applyAdjustments();
        r.applyAdjustments();
        mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(), r.getSbn().getId(),
        mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(), r.getSbn().getId(),
                r.getSbn().getTag(), r,false);
                r.getSbn().getTag(), r, false, false);
    }
    }
    @Test
    @Test
@@ -10309,7 +10309,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r.applyAdjustments();
        r.applyAdjustments();
        mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(), r.getSbn().getId(),
        mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(), r.getSbn().getId(),
                    r.getSbn().getTag(), r,false);
                    r.getSbn().getTag(), r, false, false);
    }
    }
    @Test
    @Test
@@ -10522,7 +10522,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // normal blocked notifications - blocked
        // normal blocked notifications - blocked
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isFalse();
        // just using the style - blocked
        // just using the style - blocked
        nb.setStyle(new Notification.MediaStyle());
        nb.setStyle(new Notification.MediaStyle());
@@ -10531,7 +10531,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isFalse();
        // using the style, but incorrect type in session - blocked
        // using the style, but incorrect type in session - blocked
        nb.setStyle(new Notification.MediaStyle());
        nb.setStyle(new Notification.MediaStyle());
@@ -10543,7 +10543,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isFalse();
        // style + media session - bypasses block
        // style + media session - bypasses block
        nb.setStyle(new Notification.MediaStyle().setMediaSession(mock(MediaSession.Token.class)));
        nb.setStyle(new Notification.MediaStyle().setMediaSession(mock(MediaSession.Token.class)));
@@ -10552,7 +10552,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isTrue();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
    }
    }
    @Test
    @Test
@@ -10635,7 +10635,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // normal blocked notifications - blocked
        // normal blocked notifications - blocked
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isFalse();
        // just using the style - blocked
        // just using the style - blocked
        Person person = new Person.Builder()
        Person person = new Person.Builder()
@@ -10649,36 +10649,36 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isFalse();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isFalse();
        // style + managed call - bypasses block
        // style + managed call - bypasses block
        when(mTelecomManager.isInManagedCall()).thenReturn(true);
        when(mTelecomManager.isInManagedCall()).thenReturn(true);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isTrue();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
        // style + self managed call - bypasses block
        // style + self managed call - bypasses block
        when(mTelecomManager.isInSelfManagedCall(
        when(mTelecomManager.isInSelfManagedCall(
                r.getSbn().getPackageName(), r.getUser())).thenReturn(true);
                r.getSbn().getPackageName(), r.getUser())).thenReturn(true);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isTrue();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
        // set telecom manager to null - blocked
        // set telecom manager to null - blocked
        mService.setTelecomManager(null);
        mService.setTelecomManager(null);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                           r.getSbn().getId(), r.getSbn().getTag(), r, false))
                           r.getSbn().getId(), r.getSbn().getTag(), r, false, false))
                .isFalse();
                .isFalse();
        // set telecom feature to false - blocked
        // set telecom feature to false - blocked
        when(mPackageManagerClient.hasSystemFeature(FEATURE_TELECOM)).thenReturn(false);
        when(mPackageManagerClient.hasSystemFeature(FEATURE_TELECOM)).thenReturn(false);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                           r.getSbn().getId(), r.getSbn().getTag(), r, false))
                           r.getSbn().getId(), r.getSbn().getTag(), r, false, false))
                .isFalse();
                .isFalse();
        // telecom manager is not ready - blocked
        // telecom manager is not ready - blocked
        mService.setTelecomManager(mTelecomManager);
        mService.setTelecomManager(mTelecomManager);
        when(mTelecomManager.isInCall()).thenThrow(new IllegalStateException("not ready"));
        when(mTelecomManager.isInCall()).thenThrow(new IllegalStateException("not ready"));
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false))
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false))
                .isFalse();
                .isFalse();
    }
    }
@@ -11243,7 +11243,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        try {
        try {
            mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
            mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                    r.getSbn().getId(), r.getSbn().getTag(), r, false);
                    r.getSbn().getId(), r.getSbn().getTag(), r, false, false);
            assertFalse("CallStyle should not be allowed without a valid use case", true);
            assertFalse("CallStyle should not be allowed without a valid use case", true);
        } catch (IllegalArgumentException error) {
        } catch (IllegalArgumentException error) {
            assertThat(error.getMessage()).contains("CallStyle");
            assertThat(error.getMessage()).contains("CallStyle");
@@ -11263,7 +11263,25 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isTrue();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
    }
    @Test
    public void checkCallStyleNotification_allowedForByForegroundService() throws Exception {
        Person person = new Person.Builder().setName("caller").build();
        Notification n = new Notification.Builder(mContext, "test")
                // Without FLAG_FOREGROUND_SERVICE.
                //.setFlag(FLAG_FOREGROUND_SERVICE, true)
                .setStyle(Notification.CallStyle.forOngoingCall(
                        person, mock(PendingIntent.class)))
                .build();
        StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0,
                n, UserHandle.getUserHandleForUid(mUid), null, 0);
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false,
                true /* byForegroundService */)).isTrue();
    }
    }
    @Test
    @Test
@@ -11279,7 +11297,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isTrue();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
    }
    }
    @Test
    @Test
@@ -11295,7 +11313,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isTrue();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
    }
    }
    @Test
    @Test
@@ -11311,7 +11329,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
        assertThat(mService.checkDisqualifyingFeatures(r.getUserId(), r.getUid(),
                r.getSbn().getId(), r.getSbn().getTag(), r, false)).isTrue();
                r.getSbn().getId(), r.getSbn().getTag(), r, false, false)).isTrue();
    }
    }
    @Test
    @Test