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
This commit is contained in:
Beverly
2019-04-15 11:21:25 -04:00
committed by Beverly Tai
parent b5fa3532db
commit 1cc502fe20

View File

@@ -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);