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

Commit 131ffc4b authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Use default zen policy's callers/messages"

parents 467fe4d6 877d5193
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -958,13 +958,15 @@ public class ZenModeConfig implements Parcelable {
        if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_MESSAGES,
                isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MESSAGES, defaultPolicy))) {
            priorityCategories |= Policy.PRIORITY_CATEGORY_MESSAGES;
            messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders());
            messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders(),
                    messageSenders);
        }

        if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_CALLS,
                isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS, defaultPolicy))) {
            priorityCategories |= Policy.PRIORITY_CATEGORY_CALLS;
            callSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders());
            callSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders(),
                    callSenders);
        }

        if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_REPEAT_CALLERS,
@@ -1056,16 +1058,17 @@ public class ZenModeConfig implements Parcelable {
        return (policy.suppressedVisualEffects & visualEffect) == 0;
    }

    private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders) {
    private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders,
            int defaultPolicySender) {
        switch (senders) {
            case ZenPolicy.PEOPLE_TYPE_ANYONE:
                return Policy.PRIORITY_SENDERS_ANY;
            case ZenPolicy.PEOPLE_TYPE_CONTACTS:

                return Policy.PRIORITY_SENDERS_CONTACTS;
            case ZenPolicy.PEOPLE_TYPE_STARRED:
            default:
                return Policy.PRIORITY_SENDERS_STARRED;
            default:
                return defaultPolicySender;
        }
    }

+20 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public class ZenModeConfigTest extends UiServiceTestCase {

    @Test
    public void testZenPolicyNothingSetToNotificationPolicy() {
        ZenModeConfig config = getMutedAllConfig();
        ZenModeConfig config = getCustomConfig();
        ZenPolicy zenPolicy = new ZenPolicy.Builder().build();
        assertEquals(config.toNotificationPolicy(), config.toNotificationPolicy(zenPolicy));
    }
@@ -219,6 +219,25 @@ public class ZenModeConfigTest extends UiServiceTestCase {
        return config;
    }

    private ZenModeConfig getCustomConfig() {
        ZenModeConfig config = new ZenModeConfig();
        // Some sounds allowed
        config.allowAlarms = true;
        config.allowMedia = false;
        config.allowSystem = false;
        config.allowCalls = true;
        config.allowRepeatCallers = true;
        config.allowMessages = false;
        config.allowReminders = false;
        config.allowEvents = false;
        config.areChannelsBypassingDnd = false;
        config.allowCallsFrom = ZenModeConfig.SOURCE_ANYONE;
        config.allowMessagesFrom = ZenModeConfig.SOURCE_ANYONE;

        config.suppressedVisualEffects = 0;
        return config;
    }

    private ZenModeConfig getMutedAllConfig() {
        ZenModeConfig config = new ZenModeConfig();
        // No sounds allowed