Java Code Examples for android.provider.Settings.Global#isValidZenMode()

The following examples show how to use android.provider.Settings.Global#isValidZenMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZenModeHelper.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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, null, setRingerMode);
    }
}
 
Example 2
Source File: ZenModeConfig.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private static boolean isValidManualRule(ZenRule rule) {
    return rule == null || Global.isValidZenMode(rule.zenMode) && sameCondition(rule);
}
 
Example 3
Source File: ZenModeConfig.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private static boolean isValidAutomaticRule(ZenRule rule) {
    return rule != null && !TextUtils.isEmpty(rule.name) && Global.isValidZenMode(rule.zenMode)
            && rule.conditionId != null && sameCondition(rule);
}
 
Example 4
Source File: ZenModeConfig.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private static int tryParseZenMode(String value, int defValue) {
    final int rt = tryParseInt(value, defValue);
    return Global.isValidZenMode(rt) ? rt : defValue;
}