android.provider.Settings.Global Java Examples
The following examples show how to use
android.provider.Settings.Global.
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: ZenModeFiltering.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * @param extras extras of the notification with EXTRA_PEOPLE populated * @param contactsTimeoutMs timeout in milliseconds to wait for contacts response * @param timeoutAffinity affinity to return when the timeout specified via * <code>contactsTimeoutMs</code> is hit */ public static boolean matchesCallFilter(Context context, int zen, ZenModeConfig config, UserHandle userHandle, Bundle extras, ValidateNotificationPeople validator, int contactsTimeoutMs, float timeoutAffinity) { if (zen == Global.ZEN_MODE_NO_INTERRUPTIONS) return false; // nothing gets through if (zen == Global.ZEN_MODE_ALARMS) return false; // not an alarm if (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) { if (config.allowRepeatCallers && REPEAT_CALLERS.isRepeat(context, extras)) { return true; } if (!config.allowCalls) return false; // no other calls get through if (validator != null) { final float contactAffinity = validator.getContactAffinity(userHandle, extras, contactsTimeoutMs, timeoutAffinity); return audienceMatches(config.allowCallsFrom, contactAffinity); } } return true; }
Example #2
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void populateZenRule(AutomaticZenRule automaticZenRule, ZenRule rule, boolean isNew) { if (isNew) { rule.id = ZenModeConfig.newRuleId(); rule.creationTime = System.currentTimeMillis(); rule.component = automaticZenRule.getOwner(); } if (rule.enabled != automaticZenRule.isEnabled()) { rule.snoozing = false; } rule.name = automaticZenRule.getName(); rule.condition = null; rule.conditionId = automaticZenRule.getConditionId(); rule.enabled = automaticZenRule.isEnabled(); rule.zenMode = NotificationManager.zenModeFromInterruptionFilter( automaticZenRule.getInterruptionFilter(), Global.ZEN_MODE_OFF); }
Example #3
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void dump(PrintWriter pw, String prefix) { pw.print(prefix); pw.print("mZenMode="); pw.println(Global.zenModeToString(mZenMode)); final int N = mConfigs.size(); for (int i = 0; i < N; i++) { dump(pw, prefix, "mConfigs[u=" + mConfigs.keyAt(i) + "]", mConfigs.valueAt(i)); } pw.print(prefix); pw.print("mUser="); pw.println(mUser); synchronized (mConfig) { dump(pw, prefix, "mConfig", mConfig); } pw.print(prefix); pw.print("mSuppressedEffects="); pw.println(mSuppressedEffects); mFiltering.dump(pw, prefix); mConditions.dump(pw, prefix); }
Example #4
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private int computeZenMode() { if (mConfig == null) return Global.ZEN_MODE_OFF; synchronized (mConfig) { if (mConfig.manualRule != null) return mConfig.manualRule.zenMode; int zen = Global.ZEN_MODE_OFF; for (ZenRule automaticRule : mConfig.automaticRules.values()) { if (automaticRule.isAutomaticActive()) { if (zenSeverity(automaticRule.zenMode) > zenSeverity(zen)) { // automatic rule triggered dnd and user hasn't seen update dnd dialog if (Settings.Global.getInt(mContext.getContentResolver(), Global.ZEN_SETTINGS_SUGGESTION_VIEWED, 1) == 0) { Settings.Global.putInt(mContext.getContentResolver(), Global.SHOW_ZEN_SETTINGS_SUGGESTION, 1); } zen = automaticRule.zenMode; } } } return zen; } }
Example #5
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void appendDefaultEventRules(ZenModeConfig config) { if (config == null) return; final EventInfo events = new EventInfo(); events.calendar = null; // any calendar events.reply = EventInfo.REPLY_YES_OR_MAYBE; final ZenRule rule = new ZenRule(); rule.enabled = false; rule.name = mDefaultRuleEventsName; rule.conditionId = ZenModeConfig.toEventConditionId(events); rule.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; rule.component = EventConditionProvider.COMPONENT; rule.id = ZenModeConfig.EVENTS_DEFAULT_RULE_ID; rule.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule.id, rule); }
Example #6
Source File: ZenModeConfig.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public static ZenRule readRuleXml(XmlPullParser parser) { final ZenRule rt = new ZenRule(); rt.enabled = safeBoolean(parser, RULE_ATT_ENABLED, true); rt.snoozing = safeBoolean(parser, RULE_ATT_SNOOZING, false); rt.name = parser.getAttributeValue(null, RULE_ATT_NAME); final String zen = parser.getAttributeValue(null, RULE_ATT_ZEN); rt.zenMode = tryParseZenMode(zen, -1); if (rt.zenMode == -1) { Slog.w(TAG, "Bad zen mode in rule xml:" + zen); return null; } rt.conditionId = safeUri(parser, RULE_ATT_CONDITION_ID); rt.component = safeComponentName(parser, RULE_ATT_COMPONENT); rt.creationTime = safeLong(parser, RULE_ATT_CREATION_TIME, 0); rt.enabler = parser.getAttributeValue(null, RULE_ATT_ENABLER); rt.condition = readConditionXml(parser); // all default rules and user created rules updated to zenMode important interruptions if (rt.zenMode != Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && Condition.isValidId(rt.conditionId, SYSTEM_AUTHORITY)) { Slog.i(TAG, "Updating zenMode of automatic rule " + rt.name); rt.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; } return rt; }
Example #7
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void appendDefaultEveryNightRule(ZenModeConfig config) { if (config == null) return; final ScheduleInfo weeknights = new ScheduleInfo(); weeknights.days = ZenModeConfig.ALL_DAYS; weeknights.startHour = 22; weeknights.endHour = 7; weeknights.exitAtAlarm = true; final ZenRule rule = new ZenRule(); rule.enabled = false; rule.name = mDefaultRuleEveryNightName; rule.conditionId = ZenModeConfig.toScheduleConditionId(weeknights); rule.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; rule.component = ScheduleConditionProvider.COMPONENT; rule.id = ZenModeConfig.EVERY_NIGHT_DEFAULT_RULE_ID; rule.creationTime = System.currentTimeMillis(); config.automaticRules.put(rule.id, rule); }
Example #8
Source File: AudioCapabilities.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Returns the global settings {@link Uri} used by the device to specify external surround sound, * or null if the device does not support this functionality. */ @Nullable /* package */ static Uri getExternalSurroundSoundGlobalSettingUri() { return deviceMaySetExternalSurroundSoundGlobalSetting() ? Global.getUriFor(EXTERNAL_SURROUND_SOUND_KEY) : null; }
Example #9
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public int onSetRingerModeExternal(int ringerModeOld, int ringerModeNew, String caller, int ringerModeInternal, VolumePolicy policy) { int ringerModeInternalOut = ringerModeNew; final boolean isChange = ringerModeOld != ringerModeNew; final boolean isVibrate = ringerModeInternal == AudioManager.RINGER_MODE_VIBRATE; int newZen = -1; switch (ringerModeNew) { case AudioManager.RINGER_MODE_SILENT: if (isChange) { if (mZenMode == Global.ZEN_MODE_OFF) { newZen = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; } ringerModeInternalOut = isVibrate ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT; } else { ringerModeInternalOut = ringerModeInternal; } break; case AudioManager.RINGER_MODE_VIBRATE: case AudioManager.RINGER_MODE_NORMAL: if (mZenMode != Global.ZEN_MODE_OFF) { newZen = Global.ZEN_MODE_OFF; } break; } if (newZen != -1) { setManualZenMode(newZen, null, "ringerModeExternal", caller, false /*setRingerMode*/); } ZenLog.traceSetRingerModeExternal(ringerModeOld, ringerModeNew, caller, ringerModeInternal, ringerModeInternalOut); return ringerModeInternalOut; }
Example #10
Source File: AudioCapabilities.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@SuppressLint("InlinedApi") /* package */ static AudioCapabilities getCapabilities(Context context, @Nullable Intent intent) { if (deviceMaySetExternalSurroundSoundGlobalSetting() && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) { return EXTERNAL_SURROUND_SOUND_CAPABILITIES; } if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; } return new AudioCapabilities( intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS), intent.getIntExtra( AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT)); }
Example #11
Source File: GlobalSetting.java From Noyze with Apache License 2.0 | 5 votes |
public void setListening(boolean listening) { if (listening) { mContext.getContentResolver().registerContentObserver( Global.getUriFor(mSettingName), false, this); } else { mContext.getContentResolver().unregisterContentObserver(this); } }
Example #12
Source File: GlobalSetting.java From Noyze with Apache License 2.0 | 5 votes |
public void setListening(boolean listening) { if (listening) { mContext.getContentResolver().registerContentObserver( Global.getUriFor(mSettingName), false, this); } else { mContext.getContentResolver().unregisterContentObserver(this); } }
Example #13
Source File: ZenModeConfig.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public String toString() { return new StringBuilder(ZenRule.class.getSimpleName()).append('[') .append("id=").append(id) .append(",enabled=").append(String.valueOf(enabled).toUpperCase()) .append(",snoozing=").append(snoozing) .append(",name=").append(name) .append(",zenMode=").append(Global.zenModeToString(zenMode)) .append(",conditionId=").append(conditionId) .append(",condition=").append(condition) .append(",component=").append(component) .append(",creationTime=").append(creationTime) .append(",enabler=").append(enabler) .append(']').toString(); }
Example #14
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void showZenUpgradeNotification(int zen) { final boolean showNotification = mIsBootComplete && zen != Global.ZEN_MODE_OFF && Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 0) != 0; if (showNotification) { mNotificationManager.notify(TAG, SystemMessage.NOTE_ZEN_UPGRADE, createZenUpgradeNotification()); Settings.Global.putInt(mContext.getContentResolver(), Global.SHOW_ZEN_UPGRADE_NOTIFICATION, 0); } }
Example #15
Source File: NotificationManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** @hide */ public static int zenModeToInterruptionFilter(int zen) { switch (zen) { case Global.ZEN_MODE_OFF: return INTERRUPTION_FILTER_ALL; case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: return INTERRUPTION_FILTER_PRIORITY; case Global.ZEN_MODE_ALARMS: return INTERRUPTION_FILTER_ALARMS; case Global.ZEN_MODE_NO_INTERRUPTIONS: return INTERRUPTION_FILTER_NONE; default: return INTERRUPTION_FILTER_UNKNOWN; } }
Example #16
Source File: NotificationManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** @hide */ public static int zenModeFromInterruptionFilter(int interruptionFilter, int defValue) { switch (interruptionFilter) { case INTERRUPTION_FILTER_ALL: return Global.ZEN_MODE_OFF; case INTERRUPTION_FILTER_PRIORITY: return Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; case INTERRUPTION_FILTER_ALARMS: return Global.ZEN_MODE_ALARMS; case INTERRUPTION_FILTER_NONE: return Global.ZEN_MODE_NO_INTERRUPTIONS; default: return defValue; } }
Example #17
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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 #18
Source File: ZenModeConfig.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Determines if DND is currently overriding the ringer */ public static boolean isZenOverridingRinger(int zen, ZenModeConfig zenConfig) { return zen == Global.ZEN_MODE_NO_INTERRUPTIONS || zen == Global.ZEN_MODE_ALARMS || (zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(zenConfig)); }
Example #19
Source File: SeekBarVolumizer.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private boolean isZenMuted() { return mNotificationOrRing && mZenMode == Global.ZEN_MODE_ALARMS || mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS || (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ((!mAllowAlarms && isAlarmsStream(mStreamType)) || (!mAllowMedia && isMediaStream(mStreamType)) || (!mAllowRinger && isNotificationOrRing(mStreamType)))); }
Example #20
Source File: AudioCapabilities.java From Telegram with GNU General Public License v2.0 | 5 votes |
@SuppressLint("InlinedApi") /* package */ static AudioCapabilities getCapabilities(Context context, @Nullable Intent intent) { if (deviceMaySetExternalSurroundSoundGlobalSetting() && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) { return EXTERNAL_SURROUND_SOUND_CAPABILITIES; } if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; } return new AudioCapabilities( intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS), intent.getIntExtra( AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT)); }
Example #21
Source File: AudioCapabilities.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Returns the global settings {@link Uri} used by the device to specify external surround sound, * or null if the device does not support this functionality. */ @Nullable /* package */ static Uri getExternalSurroundSoundGlobalSettingUri() { return deviceMaySetExternalSurroundSoundGlobalSetting() ? Global.getUriFor(EXTERNAL_SURROUND_SOUND_KEY) : null; }
Example #22
Source File: ProgressIndicator.java From material-components-android with Apache License 2.0 | 5 votes |
/** Returns the animator duration scale from developer options setting. */ private float getSystemAnimatorDurationScale() { if (VERSION.SDK_INT >= 17) { return Global.getFloat(getContext().getContentResolver(), Global.ANIMATOR_DURATION_SCALE, 1f); } if (VERSION.SDK_INT == 16) { return System.getFloat(getContext().getContentResolver(), System.ANIMATOR_DURATION_SCALE, 1f); } return 1f; }
Example #23
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public int getRingerModeAffectedStreams(int streams) { // ringtone and notification streams are always affected by ringer mode // system stream is affected by ringer mode when not in priority-only streams |= (1 << AudioSystem.STREAM_RING) | (1 << AudioSystem.STREAM_NOTIFICATION) | (1 << AudioSystem.STREAM_SYSTEM); if (mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS) { // alarm and music streams affected by ringer mode when in total silence streams |= (1 << AudioSystem.STREAM_ALARM) | (1 << AudioSystem.STREAM_MUSIC); } else { streams &= ~((1 << AudioSystem.STREAM_ALARM) | (1 << AudioSystem.STREAM_MUSIC)); } if (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(mConfig)) { // system stream is not affected by ringer mode in priority only when the ringer // is zen muted (all other notification categories are muted) streams &= ~(1 << AudioSystem.STREAM_SYSTEM); } else { streams |= (1 << AudioSystem.STREAM_SYSTEM); } return streams; }
Example #24
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static int zenSeverity(int zen) { switch (zen) { case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: return 1; case Global.ZEN_MODE_ALARMS: return 2; case Global.ZEN_MODE_NO_INTERRUPTIONS: return 3; default: return 0; } }
Example #25
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@VisibleForTesting protected void applyZenToRingerMode() { if (mAudioManager == null) return; // force the ringer mode into compliance final int ringerModeInternal = mAudioManager.getRingerModeInternal(); int newRingerModeInternal = ringerModeInternal; switch (mZenMode) { case Global.ZEN_MODE_NO_INTERRUPTIONS: case Global.ZEN_MODE_ALARMS: if (ringerModeInternal != AudioManager.RINGER_MODE_SILENT) { setPreviousRingerModeSetting(ringerModeInternal); newRingerModeInternal = AudioManager.RINGER_MODE_SILENT; } break; case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: // do not apply zen to ringer, streams zen muted in AudioService break; case Global.ZEN_MODE_OFF: if (ringerModeInternal == AudioManager.RINGER_MODE_SILENT) { newRingerModeInternal = getPreviousRingerModeSetting(); setPreviousRingerModeSetting(null); } break; } if (newRingerModeInternal != -1) { mAudioManager.setRingerModeInternal(newRingerModeInternal, TAG); } }
Example #26
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void applyConfig(ZenModeConfig config, String reason, ComponentName triggeringComponent, boolean setRingerMode) { final String val = Integer.toString(config.hashCode()); Global.putString(mContext.getContentResolver(), Global.ZEN_MODE_CONFIG_ETAG, val); if (!evaluateZenMode(reason, setRingerMode)) { applyRestrictions(); // evaluateZenMode will also apply restrictions if changed } mConditions.evaluateConfig(config, triggeringComponent, true /*processSubscriptions*/); }
Example #27
Source File: AudioCapabilities.java From MediaSDK with Apache License 2.0 | 5 votes |
@SuppressLint("InlinedApi") /* package */ static AudioCapabilities getCapabilities(Context context, @Nullable Intent intent) { if (deviceMaySetExternalSurroundSoundGlobalSetting() && Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) { return EXTERNAL_SURROUND_SOUND_CAPABILITIES; } if (intent == null || intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 0) { return DEFAULT_AUDIO_CAPABILITIES; } return new AudioCapabilities( intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS), intent.getIntExtra( AudioManager.EXTRA_MAX_CHANNEL_COUNT, /* defaultValue= */ DEFAULT_MAX_CHANNEL_COUNT)); }
Example #28
Source File: ZenLog.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static String zenModeToString(int zenMode) { switch (zenMode) { case Global.ZEN_MODE_OFF: return "off"; case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: return "important_interruptions"; case Global.ZEN_MODE_ALARMS: return "alarms"; case Global.ZEN_MODE_NO_INTERRUPTIONS: return "no_interruptions"; default: return "unknown"; } }
Example #29
Source File: NetworkScoreService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void registerRecommendationSettingsObserver() { final Uri packageNameUri = Global.getUriFor(Global.NETWORK_RECOMMENDATIONS_PACKAGE); mRecommendationSettingsObserver.observe(packageNameUri, ServiceHandler.MSG_RECOMMENDATIONS_PACKAGE_CHANGED); final Uri settingUri = Global.getUriFor(Global.NETWORK_RECOMMENDATIONS_ENABLED); mRecommendationSettingsObserver.observe(settingUri, ServiceHandler.MSG_RECOMMENDATION_ENABLED_SETTING_CHANGED); }
Example #30
Source File: HdmiCecLocalDevicePlayback.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
HdmiCecLocalDevicePlayback(HdmiControlService service) { super(service, HdmiDeviceInfo.DEVICE_PLAYBACK); mAutoTvOff = mService.readBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, false); // The option is false by default. Update settings db as well to have the right // initial setting on UI. mService.writeBooleanSetting(Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, mAutoTvOff); }