From 1cc502fe20dbb120e4eed14e1017dc3d4486de69 Mon Sep 17 00:00:00 2001 From: Beverly Date: Mon, 15 Apr 2019 11:21:25 -0400 Subject: [PATCH] Check zen modes+manual rule for in consol zen pol When creating the consolidated zen policy: - Check the zen mode of the automatic zen rules. These will take precendence over the ZenPolicy. - Check the manual zen rule. Test: atest SystemUITests Bug: 130152926 Change-Id: Ie7604d8f4fd625ea0e0c2fc701c5b903402f8494 --- .../server/notification/ZenModeHelper.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java index 1f5b99cb3349d..981e0f58ef2bb 100644 --- a/services/core/java/com/android/server/notification/ZenModeHelper.java +++ b/services/core/java/com/android/server/notification/ZenModeHelper.java @@ -940,13 +940,34 @@ public class ZenModeHelper { } } + private void applyCustomPolicy(ZenPolicy policy, ZenRule rule) { + if (rule.zenMode == NotificationManager.INTERRUPTION_FILTER_NONE) { + policy.apply(new ZenPolicy.Builder() + .disallowAllSounds() + .build()); + } else if (rule.zenMode + == NotificationManager.INTERRUPTION_FILTER_ALARMS) { + policy.apply(new ZenPolicy.Builder() + .disallowAllSounds() + .allowAlarms(true) + .allowMedia(true) + .build()); + } else { + policy.apply(rule.zenPolicy); + } + } + private void updateConsolidatedPolicy(String reason) { if (mConfig == null) return; synchronized (mConfig) { ZenPolicy policy = new ZenPolicy(); + if (mConfig.manualRule != null) { + applyCustomPolicy(policy, mConfig.manualRule); + } + for (ZenRule automaticRule : mConfig.automaticRules.values()) { if (automaticRule.isAutomaticActive()) { - policy.apply(automaticRule.zenPolicy); + applyCustomPolicy(policy, automaticRule); } } Policy newPolicy = mConfig.toNotificationPolicy(policy);