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

Commit ad1400b7 authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Merge "Ensure group summary (and any notifications added directly by NMS) have...

Merge "Ensure group summary (and any notifications added directly by NMS) have the correct token" into main
parents f7c8ac59 c18c614a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -8565,6 +8565,13 @@ public class NotificationManagerService extends SystemService {
         */
        private boolean enqueueNotification() {
            synchronized (mNotificationLock) {
                if (android.app.Flags.secureAllowlistToken()) {
                    // allowlistToken is populated by unparceling, so it will be absent if the
                    // EnqueueNotificationRunnable is created directly by NMS (as we do for group
                    // summaries) instead of via notify(). Fix that.
                    r.getNotification().overrideAllowlistToken(ALLOWLIST_TOKEN);
                }
                final long snoozeAt =
                        mSnoozeHelper.getSnoozeTimeForUnpostedNotification(
                                r.getUser().getIdentifier(),
+23 −0
Original line number Diff line number Diff line
@@ -14333,6 +14333,29 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .isEqualTo(NotificationManagerService.ALLOWLIST_TOKEN);
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_SECURE_ALLOWLIST_TOKEN)
    public void enqueueNotification_directlyThroughRunnable_populatesAllowlistToken() {
        Notification receivedWithoutParceling = new Notification.Builder(mContext, TEST_CHANNEL_ID)
                .setContentIntent(createPendingIntent("content"))
                .build();
        NotificationRecord record = new NotificationRecord(
                mContext,
                new StatusBarNotification(mPkg, mPkg, 1, "tag", mUid, 44, receivedWithoutParceling,
                        mUser, "groupKey", 0),
                mTestNotificationChannel);
        assertThat(record.getNotification().getAllowlistToken()).isNull();
        mWorkerHandler.post(
                mService.new EnqueueNotificationRunnable(mUserId, record, false, false,
                mPostNotificationTrackerFactory.newTracker(null)));
        waitForIdle();
        assertThat(mService.mNotificationList).hasSize(1);
        assertThat(mService.mNotificationList.get(0).getNotification().getAllowlistToken())
                .isEqualTo(NotificationManagerService.ALLOWLIST_TOKEN);
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_SECURE_ALLOWLIST_TOKEN)
    public void enqueueNotification_rejectsOtherToken() throws RemoteException {