Search in sources :

Example 46 with ZenModeConfig

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

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

Example 47 with ZenModeConfig

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

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 48 with ZenModeConfig

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

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

Example 49 with ZenModeConfig

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

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 50 with ZenModeConfig

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

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

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