use of android.service.notification.ZenModeConfig.ZenRule in project platform_frameworks_base by android.
the class ZenModeControllerImpl method updateZenModeConfig.
private void updateZenModeConfig() {
final ZenModeConfig config = mNoMan.getZenModeConfig();
if (Objects.equals(config, mConfig))
return;
final ZenRule oldRule = mConfig != null ? mConfig.manualRule : null;
mConfig = config;
fireConfigChanged(config);
final ZenRule newRule = config != null ? config.manualRule : null;
if (Objects.equals(oldRule, newRule))
return;
fireManualRuleChanged(newRule);
}
use of android.service.notification.ZenModeConfig.ZenRule in project platform_frameworks_base by android.
the class ZenModeHelper method appendDefaultEventRules.
private void appendDefaultEventRules(ZenModeConfig config) {
if (config == null)
return;
final EventInfo events = new EventInfo();
// any calendar
events.calendar = null;
events.reply = EventInfo.REPLY_YES_OR_MAYBE;
final ZenRule rule = new ZenRule();
rule.enabled = false;
rule.name = mContext.getResources().getString(R.string.zen_mode_default_events_name);
rule.conditionId = ZenModeConfig.toEventConditionId(events);
rule.zenMode = Global.ZEN_MODE_ALARMS;
rule.component = EventConditionProvider.COMPONENT;
rule.id = ZenModeConfig.newRuleId();
rule.creationTime = System.currentTimeMillis();
config.automaticRules.put(rule.id, rule);
}
use of android.service.notification.ZenModeConfig.ZenRule in project platform_frameworks_base by android.
the class ZenModeHelper method setManualZenMode.
private void setManualZenMode(int zenMode, Uri conditionId, String reason, String caller, boolean setRingerMode) {
ZenModeConfig newConfig;
synchronized (mConfig) {
if (mConfig == null)
return;
if (!Global.isValidZenMode(zenMode))
return;
if (DEBUG)
Log.d(TAG, "setManualZenMode " + Global.zenModeToString(zenMode) + " conditionId=" + conditionId + " reason=" + reason + " setRingerMode=" + setRingerMode);
newConfig = mConfig.copy();
if (zenMode == Global.ZEN_MODE_OFF) {
newConfig.manualRule = null;
for (ZenRule automaticRule : newConfig.automaticRules.values()) {
if (automaticRule.isAutomaticActive()) {
automaticRule.snoozing = true;
}
}
} else {
final ZenRule newRule = new ZenRule();
newRule.enabled = true;
newRule.zenMode = zenMode;
newRule.conditionId = conditionId;
newRule.enabler = caller;
newConfig.manualRule = newRule;
}
setConfigLocked(newConfig, reason, setRingerMode);
}
}
use of android.service.notification.ZenModeConfig.ZenRule in project platform_frameworks_base by android.
the class ZenModeHelper method appendDefaultScheduleRules.
private void appendDefaultScheduleRules(ZenModeConfig config) {
if (config == null)
return;
final ScheduleInfo weeknights = new ScheduleInfo();
weeknights.days = ZenModeConfig.WEEKNIGHT_DAYS;
weeknights.startHour = 22;
weeknights.endHour = 7;
final ZenRule rule1 = new ZenRule();
rule1.enabled = false;
rule1.name = mContext.getResources().getString(R.string.zen_mode_default_weeknights_name);
rule1.conditionId = ZenModeConfig.toScheduleConditionId(weeknights);
rule1.zenMode = Global.ZEN_MODE_ALARMS;
rule1.component = ScheduleConditionProvider.COMPONENT;
rule1.id = ZenModeConfig.newRuleId();
rule1.creationTime = System.currentTimeMillis();
config.automaticRules.put(rule1.id, rule1);
final ScheduleInfo weekends = new ScheduleInfo();
weekends.days = ZenModeConfig.WEEKEND_DAYS;
weekends.startHour = 23;
weekends.startMinute = 30;
weekends.endHour = 10;
final ZenRule rule2 = new ZenRule();
rule2.enabled = false;
rule2.name = mContext.getResources().getString(R.string.zen_mode_default_weekends_name);
rule2.conditionId = ZenModeConfig.toScheduleConditionId(weekends);
rule2.zenMode = Global.ZEN_MODE_ALARMS;
rule2.component = ScheduleConditionProvider.COMPONENT;
rule2.id = ZenModeConfig.newRuleId();
rule2.creationTime = System.currentTimeMillis();
config.automaticRules.put(rule2.id, rule2);
}
use of android.service.notification.ZenModeConfig.ZenRule in project platform_frameworks_base by android.
the class ZenModeConditions method onConditionChanged.
@Override
public void onConditionChanged(Uri id, Condition condition) {
if (DEBUG)
Log.d(TAG, "onConditionChanged " + id + " " + condition);
ZenModeConfig config = mHelper.getConfig();
if (config == null)
return;
boolean updated = updateCondition(id, condition, config.manualRule);
for (ZenRule automaticRule : config.automaticRules.values()) {
updated |= updateCondition(id, condition, automaticRule);
updated |= updateSnoozing(automaticRule);
}
if (updated) {
mHelper.setConfig(config, "conditionChanged");
}
}
Aggregations