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

Commit a917a114 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Channel updates should trigger ranking updates

- Uid, not user id
- unspecified importance really does mean 'don't override'

Change-Id: Ia60aade179f70cd5d5278eed41c707b9ab6590e0
Fixes: 36007628
Fixes: 36355913
Test: manual, runtest systemui-notification
parent 7c8e0918
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1305,14 +1305,16 @@ public class NotificationManagerService extends SystemService {
            mRankingHelper.updateNotificationChannel(pkg, uid, channel);
        }

        synchronized (mNotificationList) {
        synchronized (mNotificationLock) {
            final int N = mNotificationList.size();
            for (int i = N - 1; i >= 0; --i) {
                NotificationRecord r = mNotificationList.get(i);
                if (channel.getId() != null && channel.getId().equals(r.getChannel().getId())) {
                if (r.sbn.getPackageName().equals(pkg)
                        && r.sbn.getUid() == uid
                        && channel.getId() != null
                        && channel.getId().equals(r.getChannel().getId())) {
                    r.updateNotificationChannel(mRankingHelper.getNotificationChannel(
                            r.sbn.getPackageName(), r.getUser().getIdentifier(),
                            channel.getId(), false));
                            pkg, uid, channel.getId(), false));
                }
            }
        }
+50 −48
Original line number Diff line number Diff line
@@ -294,8 +294,9 @@ public final class NotificationRecord {
        stats.isNoisy = mSound != null || mVibration != null;

        if (mPreChannelsNotification
                && (getChannel().getUserLockedFields()
                & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0) {
                && (importance == IMPORTANCE_UNSPECIFIED
                || (getChannel().getUserLockedFields()
                & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0)) {
            if (!stats.isNoisy && requestedImportance > IMPORTANCE_LOW) {
                requestedImportance = IMPORTANCE_LOW;
            }
@@ -358,6 +359,7 @@ public final class NotificationRecord {
    }

    void dump(PrintWriter pw, String prefix, Context baseContext, boolean redact) {
        prefix = prefix + "  ";
        final Notification notification = sbn.getNotification();
        final Icon icon = notification.getSmallIcon();
        String iconStr = String.valueOf(icon);
+3 −1
Original line number Diff line number Diff line
@@ -94,10 +94,12 @@ public class ImportanceExtractorTest {
                new NotificationChannel("a", "a", NotificationManager.IMPORTANCE_UNSPECIFIED);

        NotificationRecord r = getNotificationRecord(channel);
        int notificationImportance = r.getImportance();

        extractor.process(r);

        assertEquals(r.getUserImportance(), NotificationManager.IMPORTANCE_UNSPECIFIED);
        assertEquals(NotificationManager.IMPORTANCE_UNSPECIFIED, r.getUserImportance());
        assertEquals(notificationImportance, r.getImportance());
    }

    @Test
+12 −0
Original line number Diff line number Diff line
@@ -288,6 +288,18 @@ public class NotificationRecordTest {
        assertEquals(NotificationManager.IMPORTANCE_LOW, record.getImportance());
    }

    @Test
    public void testImportance_locked_unspecified_preUpgrade() throws Exception {
        defaultChannel.setImportance(NotificationManager.IMPORTANCE_UNSPECIFIED);
        defaultChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
        StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */,
                true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
                false /* lights */, false /*defaultLights */);

        NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
        assertEquals(NotificationManager.IMPORTANCE_HIGH, record.getImportance());
    }

    @Test
    public void testImportance_upgrade() throws Exception {
        StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */,