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

Commit 1af50e2d authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Show channel groups in settings"

parents df9a4f9a f02562ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public final class NotificationChannelGroup implements Parcelable {
            mId = null;
        }
        mName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
        in.readList(mChannels, NotificationChannel.class.getClassLoader());
        in.readParcelableList(mChannels, NotificationChannel.class.getClassLoader());
    }

    @Override
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.content.pm.ParceledListSlice;

import java.util.Collection;

public interface RankingConfig {

    void setImportance(String packageName, int uid, int importance);
@@ -26,6 +28,8 @@ public interface RankingConfig {
    void setShowBadge(String packageName, int uid, boolean showBadge);
    boolean canShowBadge(String packageName, int uid);

    Collection<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
            int uid);
    void createNotificationChannelGroup(String pkg, int uid, NotificationChannelGroup group,
            boolean fromTargetApp);
    ParceledListSlice<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
+17 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -691,13 +692,28 @@ public class RankingHelper implements RankingConfig {
                }
            }
        }
        groups.addAll(r.groups.values());
        for (NotificationChannelGroup group : r.groups.values()) {
            if (group.getChannels().size() > 0) {
                groups.add(group);
            }
        }
        if (nonGrouped.getChannels().size() > 0) {
            groups.add(nonGrouped);
        }
        return new ParceledListSlice<>(groups);
    }

    @Override
    @VisibleForTesting
    public Collection<NotificationChannelGroup> getNotificationChannelGroups(String pkg,
            int uid) {
        Record r = getRecord(pkg, uid);
        if (r == null) {
            return new ArrayList<>();
        }
        return r.groups.values();
    }

    @Override
    public ParceledListSlice<NotificationChannel> getNotificationChannels(String pkg, int uid,
            boolean includeDeleted) {
+3 −1
Original line number Diff line number Diff line
@@ -805,7 +805,7 @@ public class RankingHelperTest {
    public void testCreateGroup() throws Exception {
        NotificationChannelGroup ncg = new NotificationChannelGroup("group1", "name1");
        mHelper.createNotificationChannelGroup(pkg, uid, ncg, true);
        assertEquals(ncg, mHelper.getNotificationChannelGroups(pkg, uid, false).getList().get(0));
        assertEquals(ncg, mHelper.getNotificationChannelGroups(pkg, uid).iterator().next());
    }

    @Test
@@ -834,6 +834,8 @@ public class RankingHelperTest {

    @Test
    public void testGetChannelGroups() throws Exception {
        NotificationChannelGroup unused = new NotificationChannelGroup("unused", "s");
        mHelper.createNotificationChannelGroup(pkg, uid, unused, true);
        NotificationChannelGroup ncg = new NotificationChannelGroup("group1", "name1");
        mHelper.createNotificationChannelGroup(pkg, uid, ncg, true);
        NotificationChannelGroup ncg2 = new NotificationChannelGroup("group2", "name2");