Search in sources :

Example 11 with ZenModeConfig

use of android.service.notification.ZenModeConfig in project android_frameworks_base by DirtyUnicorns.

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");
    }
}
Also used : ZenRule(android.service.notification.ZenModeConfig.ZenRule) ZenModeConfig(android.service.notification.ZenModeConfig)

Example 12 with ZenModeConfig

use of android.service.notification.ZenModeConfig in project android_frameworks_base by AOSPA.

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);
}
Also used : ZenRule(android.service.notification.ZenModeConfig.ZenRule) ZenModeConfig(android.service.notification.ZenModeConfig)

Example 13 with ZenModeConfig

use of android.service.notification.ZenModeConfig in project android_frameworks_base by AOSPA.

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");
    }
}
Also used : ZenRule(android.service.notification.ZenModeConfig.ZenRule) ZenModeConfig(android.service.notification.ZenModeConfig)

Example 14 with ZenModeConfig

use of android.service.notification.ZenModeConfig in project android_frameworks_base by AOSPA.

the class ZenModeHelper method removeAutomaticZenRule.

public boolean removeAutomaticZenRule(String id, String reason) {
    ZenModeConfig newConfig;
    synchronized (mConfig) {
        if (mConfig == null)
            return false;
        newConfig = mConfig.copy();
        ZenRule rule = newConfig.automaticRules.get(id);
        if (rule == null)
            return false;
        if (canManageAutomaticZenRule(rule)) {
            newConfig.automaticRules.remove(id);
            if (DEBUG)
                Log.d(TAG, "removeZenRule zenRule=" + id + " reason=" + reason);
        } else {
            throw new SecurityException("Cannot delete rules not owned by your condition provider");
        }
        return setConfigLocked(newConfig, reason, true);
    }
}
Also used : AutomaticZenRule(android.app.AutomaticZenRule) ZenRule(android.service.notification.ZenModeConfig.ZenRule) ZenModeConfig(android.service.notification.ZenModeConfig)

Example 15 with ZenModeConfig

use of android.service.notification.ZenModeConfig in project android_frameworks_base by AOSPA.

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);
    }
}
Also used : ZenModeConfig(android.service.notification.ZenModeConfig) ZenRule(android.service.notification.ZenModeConfig.ZenRule)

Aggregations

ZenModeConfig (android.service.notification.ZenModeConfig)50 ZenRule (android.service.notification.ZenModeConfig.ZenRule)40 AutomaticZenRule (android.app.AutomaticZenRule)25 PackageManager (android.content.pm.PackageManager)5 ServiceInfo (android.content.pm.ServiceInfo)5 AndroidRuntimeException (android.util.AndroidRuntimeException)5