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

Commit 2adf76d3 authored by Matías Hernández's avatar Matías Hernández
Browse files

Change the way ALARMS_ONLY/NO_INTERRUPTIONS rules block priority notifications

Instead of having ZenPolicy.Builder.disallowAllSounds() set priorityAllowed=none, we apply it directly when computing the consolidated policy from rules having one of these zen modes. Otherwise, it would also apply to rules with PRIORITY_ONLY filtering, which breaks existing use-cases.

The XML attribute where this value is stored was renamed so that we don't read previously-saved priorityChannels values. This is okay because the flag has not gotten past trunkfood and thus no rules should have a legitimate allowPriorityChannels=none value set (it being a new API), and neither should the manual rule's policy.

Test: ZenModeHelperTest (existing tests, added in ag/26227699)
Bug: 326306544
Change-Id: Ib1eb971f9bc605558d542909030da4d6eee6995a
parent 7e118827
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ public class ZenModeConfig implements Parcelable {
    private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn";
    private static final String ALLOW_ATT_CONV = "convos";
    private static final String ALLOW_ATT_CONV_FROM = "convosFrom";
    private static final String ALLOW_ATT_CHANNELS = "priorityChannels";
    private static final String ALLOW_ATT_CHANNELS = "priorityChannelsAllowed";
    private static final String POLICY_USER_MODIFIED_FIELDS = "policyUserModifiedFields";
    private static final String DISALLOW_TAG = "disallow";
    private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects";
+0 −4
Original line number Diff line number Diff line
@@ -673,10 +673,6 @@ public final class ZenPolicy implements Parcelable {
            mZenPolicy.mPriorityMessages = PEOPLE_TYPE_NONE;
            mZenPolicy.mPriorityCalls = PEOPLE_TYPE_NONE;
            mZenPolicy.mConversationSenders = CONVERSATION_SENDERS_NONE;

            if (Flags.modesApi()) {
                mZenPolicy.mAllowChannels = CHANNEL_POLICY_NONE;
            }
            return this;
        }

+2 −0
Original line number Diff line number Diff line
@@ -1880,12 +1880,14 @@ public class ZenModeHelper {
        if (rule.zenMode == Global.ZEN_MODE_NO_INTERRUPTIONS) {
            policy.apply(new ZenPolicy.Builder()
                    .disallowAllSounds()
                    .allowPriorityChannels(false)
                    .build());
        } else if (rule.zenMode == Global.ZEN_MODE_ALARMS) {
            policy.apply(new ZenPolicy.Builder()
                    .disallowAllSounds()
                    .allowAlarms(true)
                    .allowMedia(true)
                    .allowPriorityChannels(false)
                    .build());
        } else if (rule.zenPolicy != null) {
            policy.apply(rule.zenPolicy);