use of android.service.notification.ZenModeConfig.ZenRule in project platform_frameworks_base by android.
the class ZenModeConditions method evaluateConfig.
public void evaluateConfig(ZenModeConfig config, boolean processSubscriptions) {
if (config == null)
return;
if (config.manualRule != null && config.manualRule.condition != null && !config.manualRule.isTrueOrUnknown()) {
if (DEBUG)
Log.d(TAG, "evaluateConfig: clearing manual rule");
config.manualRule = null;
}
final ArraySet<Uri> current = new ArraySet<>();
evaluateRule(config.manualRule, current, processSubscriptions);
for (ZenRule automaticRule : config.automaticRules.values()) {
evaluateRule(automaticRule, current, processSubscriptions);
updateSnoozing(automaticRule);
}
synchronized (mSubscriptions) {
final int N = mSubscriptions.size();
for (int i = N - 1; i >= 0; i--) {
final Uri id = mSubscriptions.keyAt(i);
final ComponentName component = mSubscriptions.valueAt(i);
if (processSubscriptions) {
if (!current.contains(id)) {
mConditionProviders.unsubscribeIfNecessary(component, id);
mSubscriptions.removeAt(i);
}
}
}
}
mFirstEvaluation = false;
}
use of android.service.notification.ZenModeConfig.ZenRule in project platform_frameworks_base by android.
the class ZenModeHelper method updateAutomaticZenRule.
public boolean updateAutomaticZenRule(String ruleId, AutomaticZenRule automaticZenRule, String reason) {
ZenModeConfig newConfig;
synchronized (mConfig) {
if (mConfig == null)
return false;
if (DEBUG) {
Log.d(TAG, "updateAutomaticZenRule zenRule=" + automaticZenRule + " reason=" + reason);
}
newConfig = mConfig.copy();
ZenModeConfig.ZenRule rule;
if (ruleId == null) {
throw new IllegalArgumentException("Rule doesn't exist");
} else {
rule = newConfig.automaticRules.get(ruleId);
if (rule == null || !canManageAutomaticZenRule(rule)) {
throw new SecurityException("Cannot update rules not owned by your condition provider");
}
}
populateZenRule(automaticZenRule, rule, false);
newConfig.automaticRules.put(ruleId, rule);
return setConfigLocked(newConfig, reason, true);
}
}
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 android_frameworks_base by DirtyUnicorns.
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 android_frameworks_base by DirtyUnicorns.
the class ZenModeHelper method cleanUpZenRules.
/**
* Removes old rule instances whose owner is not installed.
*/
private void cleanUpZenRules() {
long currentTime = System.currentTimeMillis();
synchronized (mConfig) {
final ZenModeConfig newConfig = mConfig.copy();
if (newConfig.automaticRules != null) {
for (int i = newConfig.automaticRules.size() - 1; i >= 0; i--) {
ZenRule rule = newConfig.automaticRules.get(newConfig.automaticRules.keyAt(i));
if (RULE_INSTANCE_GRACE_PERIOD < (currentTime - rule.creationTime)) {
try {
mPm.getPackageInfo(rule.component.getPackageName(), PackageManager.MATCH_UNINSTALLED_PACKAGES);
} catch (PackageManager.NameNotFoundException e) {
newConfig.automaticRules.removeAt(i);
}
}
}
}
setConfigLocked(newConfig, "cleanUpZenRules");
}
}
Aggregations