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

Commit f2b2daaa authored by Chloris Kuo's avatar Chloris Kuo
Browse files

Apply adjustment to all enqueued notification records with matched key

Test: atest NotificationManagerServiceTest
Bug: 161928116
Change-Id: I45d5c1797bb308fbd1beed2c2829a3287c90b3c8
parent c1f8735e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -4853,7 +4853,6 @@ public class NotificationManagerService extends SystemService {
                            // calculate the final importance here
                            r.calculateImportance();
                            foundEnqueued = true;
                            break;
                        }
                    }
                    if (!foundEnqueued) {
+21 −1
Original line number Diff line number Diff line
@@ -178,7 +178,6 @@ import com.android.server.wm.WindowManagerInternal;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -3773,6 +3772,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertEquals(USER_SENTIMENT_NEGATIVE, r.getUserSentiment());
    }

    @Test
    public void testEnqueuedAdjustmentAppliesAdjustments_MultiNotifications() throws Exception {
        final NotificationRecord r1 = generateNotificationRecord(mTestNotificationChannel);
        final NotificationRecord r2 = generateNotificationRecord(mTestNotificationChannel);
        mService.addEnqueuedNotification(r1);
        mService.addEnqueuedNotification(r2);
        when(mAssistants.isSameUser(eq(null), anyInt())).thenReturn(true);

        Bundle signals = new Bundle();
        signals.putInt(Adjustment.KEY_IMPORTANCE,
                IMPORTANCE_HIGH);
        Adjustment adjustment = new Adjustment(
                r1.getSbn().getPackageName(), r1.getKey(), signals,
                "", r1.getUser().getIdentifier());

        mBinderService.applyEnqueuedAdjustmentFromAssistant(null, adjustment);

        assertEquals(IMPORTANCE_HIGH, r1.getImportance());
        assertEquals(IMPORTANCE_HIGH, r2.getImportance());
    }

    @Test
    public void testRestore() throws Exception {
        int systemChecks = mService.countSystemChecks;