下面列出了android.provider.Settings.Global#isValidZenMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
}
private static boolean isValidManualRule(ZenRule rule) {
return rule == null || Global.isValidZenMode(rule.zenMode) && sameCondition(rule);
}
private static boolean isValidAutomaticRule(ZenRule rule) {
return rule != null && !TextUtils.isEmpty(rule.name) && Global.isValidZenMode(rule.zenMode)
&& rule.conditionId != null && sameCondition(rule);
}
private static int tryParseZenMode(String value, int defValue) {
final int rt = tryParseInt(value, defValue);
return Global.isValidZenMode(rt) ? rt : defValue;
}