Loading services/core/java/com/android/server/notification/ZenModeHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,7 @@ public class ZenModeHelper { newConfig = mConfig.copy(); ZenRule rule = new ZenRule(); populateZenRule(automaticZenRule, rule, true); newConfig.automaticRules.put(rule.id, rule); if (setConfigLocked(newConfig, reason, rule.component, true)) { return rule.id; } else { Loading services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import static org.mockito.Mockito.when; import android.app.AppGlobals; import android.app.AppOpsManager; import android.app.AutomaticZenRule; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.content.ComponentName; Loading Loading @@ -1097,6 +1098,25 @@ public class ZenModeHelperTest extends UiServiceTestCase { assertFalse(Objects.equals(defaultRuleName, ruleAfterUpdating.name)); // update name } @Test public void testAddAutomaticZenRule() { AutomaticZenRule zenRule = new AutomaticZenRule("name", new ComponentName("android", "ScheduleConditionProvider"), ZenModeConfig.toScheduleConditionId(new ScheduleInfo()), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); String id = mZenModeHelperSpy.addAutomaticZenRule(zenRule, "test"); assertTrue(id != null); ZenModeConfig.ZenRule ruleInConfig = mZenModeHelperSpy.mConfig.automaticRules.get(id); assertTrue(ruleInConfig != null); assertEquals(zenRule.isEnabled(), ruleInConfig.enabled); assertEquals(zenRule.isModified(), ruleInConfig.modified); assertEquals(zenRule.getConditionId(), ruleInConfig.conditionId); assertEquals(NotificationManager.zenModeFromInterruptionFilter( zenRule.getInterruptionFilter(), -1), ruleInConfig.zenMode); assertEquals(zenRule.getName(), ruleInConfig.name); } private void setupZenConfig() { mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; mZenModeHelperSpy.mConfig.allowAlarms = false; Loading Loading
services/core/java/com/android/server/notification/ZenModeHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -309,6 +309,7 @@ public class ZenModeHelper { newConfig = mConfig.copy(); ZenRule rule = new ZenRule(); populateZenRule(automaticZenRule, rule, true); newConfig.automaticRules.put(rule.id, rule); if (setConfigLocked(newConfig, reason, rule.component, true)) { return rule.id; } else { Loading
services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ import static org.mockito.Mockito.when; import android.app.AppGlobals; import android.app.AppOpsManager; import android.app.AutomaticZenRule; import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.content.ComponentName; Loading Loading @@ -1097,6 +1098,25 @@ public class ZenModeHelperTest extends UiServiceTestCase { assertFalse(Objects.equals(defaultRuleName, ruleAfterUpdating.name)); // update name } @Test public void testAddAutomaticZenRule() { AutomaticZenRule zenRule = new AutomaticZenRule("name", new ComponentName("android", "ScheduleConditionProvider"), ZenModeConfig.toScheduleConditionId(new ScheduleInfo()), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); String id = mZenModeHelperSpy.addAutomaticZenRule(zenRule, "test"); assertTrue(id != null); ZenModeConfig.ZenRule ruleInConfig = mZenModeHelperSpy.mConfig.automaticRules.get(id); assertTrue(ruleInConfig != null); assertEquals(zenRule.isEnabled(), ruleInConfig.enabled); assertEquals(zenRule.isModified(), ruleInConfig.modified); assertEquals(zenRule.getConditionId(), ruleInConfig.conditionId); assertEquals(NotificationManager.zenModeFromInterruptionFilter( zenRule.getInterruptionFilter(), -1), ruleInConfig.zenMode); assertEquals(zenRule.getName(), ruleInConfig.name); } private void setupZenConfig() { mZenModeHelperSpy.mZenMode = Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; mZenModeHelperSpy.mConfig.allowAlarms = false; Loading