Java Code Examples for android.provider.Settings.Global#ZEN_MODE_NO_INTERRUPTIONS
The following examples show how to use
android.provider.Settings.Global#ZEN_MODE_NO_INTERRUPTIONS .
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: 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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
Source File: ZenModeFiltering.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public boolean shouldIntercept(int zen, ZenModeConfig config, NotificationRecord record) { if (zen == ZEN_MODE_OFF) { return false; } // Make an exception to policy for the notification saying that policy has changed if (NotificationManager.Policy.areAllVisualEffectsSuppressed(config.suppressedVisualEffects) && "android".equals(record.sbn.getPackageName()) && SystemMessageProto.SystemMessage.NOTE_ZEN_UPGRADE == record.sbn.getId()) { ZenLog.traceNotIntercepted(record, "systemDndChangedNotification"); return false; } switch (zen) { case Global.ZEN_MODE_NO_INTERRUPTIONS: // #notevenalarms ZenLog.traceIntercepted(record, "none"); return true; case Global.ZEN_MODE_ALARMS: if (isAlarm(record)) { // Alarms only return false; } ZenLog.traceIntercepted(record, "alarmsOnly"); return true; case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: // allow user-prioritized packages through in priority mode if (record.getPackagePriority() == Notification.PRIORITY_MAX) { ZenLog.traceNotIntercepted(record, "priorityApp"); return false; } if (isAlarm(record)) { if (!config.allowAlarms) { ZenLog.traceIntercepted(record, "!allowAlarms"); return true; } return false; } if (isCall(record)) { if (config.allowRepeatCallers && REPEAT_CALLERS.isRepeat(mContext, extras(record))) { ZenLog.traceNotIntercepted(record, "repeatCaller"); return false; } if (!config.allowCalls) { ZenLog.traceIntercepted(record, "!allowCalls"); return true; } return shouldInterceptAudience(config.allowCallsFrom, record); } if (isMessage(record)) { if (!config.allowMessages) { ZenLog.traceIntercepted(record, "!allowMessages"); return true; } return shouldInterceptAudience(config.allowMessagesFrom, record); } if (isEvent(record)) { if (!config.allowEvents) { ZenLog.traceIntercepted(record, "!allowEvents"); return true; } return false; } if (isReminder(record)) { if (!config.allowReminders) { ZenLog.traceIntercepted(record, "!allowReminders"); return true; } return false; } if (isMedia(record)) { if (!config.allowMedia) { ZenLog.traceIntercepted(record, "!allowMedia"); return true; } return false; } if (isSystem(record)) { if (!config.allowSystem) { ZenLog.traceIntercepted(record, "!allowSystem"); return true; } return false; } ZenLog.traceIntercepted(record, "!priority"); return true; default: return false; } }
Example 11
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@VisibleForTesting protected void applyRestrictions() { final boolean zenPriorityOnly = mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; final boolean zenSilence = mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS; final boolean zenAlarmsOnly = mZenMode == Global.ZEN_MODE_ALARMS; // notification restrictions final boolean muteNotifications = (mSuppressedEffects & SUPPRESSED_EFFECT_NOTIFICATIONS) != 0; // call restrictions final boolean muteCalls = zenAlarmsOnly || (zenPriorityOnly && !mConfig.allowCalls && !mConfig.allowRepeatCallers) || (mSuppressedEffects & SUPPRESSED_EFFECT_CALLS) != 0; // alarm restrictions final boolean muteAlarms = zenPriorityOnly && !mConfig.allowAlarms; // media restrictions final boolean muteMedia = zenPriorityOnly && !mConfig.allowMedia; // system restrictions final boolean muteSystem = zenAlarmsOnly || (zenPriorityOnly && !mConfig.allowSystem); // total silence restrictions final boolean muteEverything = zenSilence || (zenPriorityOnly && ZenModeConfig.areAllZenBehaviorSoundsMuted(mConfig)); for (int usage : AudioAttributes.SDK_USAGES) { final int suppressionBehavior = AudioAttributes.SUPPRESSIBLE_USAGES.get(usage); if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_NEVER) { applyRestrictions(false /*mute*/, usage); } else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_NOTIFICATION) { applyRestrictions(muteNotifications || muteEverything, usage); } else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_CALL) { applyRestrictions(muteCalls || muteEverything, usage); } else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_ALARM) { applyRestrictions(muteAlarms || muteEverything, usage); } else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_MEDIA) { applyRestrictions(muteMedia || muteEverything, usage); } else if (suppressionBehavior == AudioAttributes.SUPPRESSIBLE_SYSTEM) { if (usage == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) { // normally DND will only restrict touch sounds, not haptic feedback/vibrations applyRestrictions(muteSystem || muteEverything, usage, AppOpsManager.OP_PLAY_AUDIO); applyRestrictions(false, usage, AppOpsManager.OP_VIBRATE); } else { applyRestrictions(muteSystem || muteEverything, usage); } } else { applyRestrictions(muteEverything, usage); } } }
Example 12
Source File: ZenModeHelper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public int onSetRingerModeInternal(int ringerModeOld, int ringerModeNew, String caller, int ringerModeExternal, VolumePolicy policy) { final boolean isChange = ringerModeOld != ringerModeNew; int ringerModeExternalOut = ringerModeNew; if (mZenMode == Global.ZEN_MODE_OFF || (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted(mConfig))) { // in priority only with ringer not muted, save ringer mode changes // in dnd off, save ringer mode changes setPreviousRingerModeSetting(ringerModeNew); } int newZen = -1; switch (ringerModeNew) { case AudioManager.RINGER_MODE_SILENT: if (isChange && policy.doNotDisturbWhenSilent) { if (mZenMode == Global.ZEN_MODE_OFF) { newZen = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; } setPreviousRingerModeSetting(ringerModeOld); } break; case AudioManager.RINGER_MODE_VIBRATE: case AudioManager.RINGER_MODE_NORMAL: if (isChange && ringerModeOld == AudioManager.RINGER_MODE_SILENT && (mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS || mZenMode == Global.ZEN_MODE_ALARMS || (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted( mConfig)))) { newZen = Global.ZEN_MODE_OFF; } else if (mZenMode != Global.ZEN_MODE_OFF) { ringerModeExternalOut = AudioManager.RINGER_MODE_SILENT; } break; } if (newZen != -1) { setManualZenMode(newZen, null, "ringerModeInternal", null, false /*setRingerMode*/); } if (isChange || newZen != -1 || ringerModeExternal != ringerModeExternalOut) { ZenLog.traceSetRingerModeInternal(ringerModeOld, ringerModeNew, caller, ringerModeExternal, ringerModeExternalOut); } return ringerModeExternalOut; }