use of android.service.notification.ZenModeConfig in project platform_frameworks_base by android.
the class ZenModeHelper method setNotificationPolicy.
public void setNotificationPolicy(Policy policy) {
if (policy == null || mConfig == null)
return;
synchronized (mConfig) {
final ZenModeConfig newConfig = mConfig.copy();
newConfig.applyNotificationPolicy(policy);
setConfigLocked(newConfig, "setNotificationPolicy");
}
}
use of android.service.notification.ZenModeConfig 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 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 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 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