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

Commit 41103f42 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Support for showing deleted channel count in settings.

Bug: 36119790
Test: runtest systemui-notification
Change-Id: Ie30243314d64ded66267d0dc85cc0ad940d917f8
parent e7f26511
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ interface INotificationManager
    ParceledListSlice getNotificationChannels(String pkg);
    ParceledListSlice getNotificationChannelsForPackage(String pkg, int uid, boolean includeDeleted);
    int getNumNotificationChannelsForPackage(String pkg, int uid, boolean includeDeleted);
    int getDeletedChannelCount(String pkg, int uid);

    // TODO: Remove this when callers have been migrated to the equivalent
    // INotificationListener method.
+6 −0
Original line number Diff line number Diff line
@@ -1697,6 +1697,12 @@ public class NotificationManagerService extends SystemService {
                    .getList().size();
        }

        @Override
        public int getDeletedChannelCount(String pkg, int uid) {
            enforceSystemOrSystemUI("getDeletedChannelCount");
            return mRankingHelper.getDeletedChannelCount(pkg, uid);
        }

        @Override
        public ParceledListSlice<NotificationChannelGroup> getNotificationChannelGroupsForPackage(
                String pkg, int uid, boolean includeDeleted) {
+17 −0
Original line number Diff line number Diff line
@@ -766,6 +766,23 @@ public class RankingHelper implements RankingConfig {
        return new ParceledListSlice<>(channels);
    }

    public int getDeletedChannelCount(String pkg, int uid) {
        Preconditions.checkNotNull(pkg);
        int deletedCount = 0;
        Record r = getRecord(pkg, uid);
        if (r == null) {
            return deletedCount;
        }
        int N = r.channels.size();
        for (int i = 0; i < N; i++) {
            final NotificationChannel nc = r.channels.valueAt(i);
            if (nc.isDeleted()) {
                deletedCount++;
            }
        }
        return deletedCount;
    }

    /**
     * Sets importance.
     */
+19 −0
Original line number Diff line number Diff line
@@ -722,6 +722,25 @@ public class RankingHelperTest {
        }
    }

    @Test
    public void testGetDeletedChannelCount() throws Exception {
        NotificationChannel channel =
                new NotificationChannel("id2", "name2", IMPORTANCE_LOW);
        NotificationChannel channel2 =
                new NotificationChannel("id4", "a", NotificationManager.IMPORTANCE_HIGH);
        NotificationChannel channel3 =
                new NotificationChannel("id4", "a", NotificationManager.IMPORTANCE_HIGH);
        mHelper.createNotificationChannel(pkg, uid, channel, true);
        mHelper.createNotificationChannel(pkg, uid, channel2, true);
        mHelper.createNotificationChannel(pkg, uid, channel3, true);

        mHelper.deleteNotificationChannel(pkg, uid, channel.getId());
        mHelper.deleteNotificationChannel(pkg, uid, channel3.getId());

        assertEquals(2, mHelper.getDeletedChannelCount(pkg, uid));
        assertEquals(0, mHelper.getDeletedChannelCount(pkg2, uid2));
    }

    @Test
    public void testUpdateDeletedChannels() throws Exception {
        NotificationChannel channel =