Java Code Examples for android.app.NotificationManager#INTERRUPTION_FILTER_ALARMS
The following examples show how to use
android.app.NotificationManager#INTERRUPTION_FILTER_ALARMS .
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: DoNotDisturbUtil.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@WorkerThread public static boolean shouldDisturbUserWithCall(@NonNull Context context, @NonNull Recipient recipient) { if (Build.VERSION.SDK_INT <= 23) return true; NotificationManager notificationManager = ServiceUtil.getNotificationManager(context); switch (notificationManager.getCurrentInterruptionFilter()) { case NotificationManager.INTERRUPTION_FILTER_PRIORITY: return handlePriority(context, notificationManager, recipient); case NotificationManager.INTERRUPTION_FILTER_NONE: case NotificationManager.INTERRUPTION_FILTER_ALARMS: return false; default: return true; } }
Example 2
Source File: InterruptionFilterChangedBroadcastReceiver.java From PhoneProfilesPlus with Apache License 2.0 | 6 votes |
public static void requestInterruptionFilter(Context context, final int zenMode) { //if (android.os.Build.VERSION.SDK_INT >= 23) { boolean no60 = !Build.VERSION.RELEASE.equals("6.0"); if (no60 && GlobalGUIRoutines.activityActionExists(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS, context)) { int interruptionFilter = NotificationManager.INTERRUPTION_FILTER_ALL; switch (zenMode) { case ActivateProfileHelper.ZENMODE_ALL: interruptionFilter = NotificationManager.INTERRUPTION_FILTER_ALL; break; case ActivateProfileHelper.ZENMODE_PRIORITY: interruptionFilter = NotificationManager.INTERRUPTION_FILTER_PRIORITY; break; case ActivateProfileHelper.ZENMODE_NONE: interruptionFilter = NotificationManager.INTERRUPTION_FILTER_NONE; break; case ActivateProfileHelper.ZENMODE_ALARMS: interruptionFilter = NotificationManager.INTERRUPTION_FILTER_ALARMS; break; } NotificationManager mNotificationManager = (NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) mNotificationManager.setInterruptionFilter(interruptionFilter); } //} }
Example 3
Source File: InterruptionFilterChangedBroadcastReceiver.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.M) private static int getZenMode(Context context, AudioManager audioManager) { // convert to profile zenMode int zenMode = 0; NotificationManager mNotificationManager = (NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { int interruptionFilter = mNotificationManager.getCurrentInterruptionFilter(); //PPApplication.logE("InterruptionFilterChangedBroadcastReceiver.getZenMode", "interruptionFilter=" + interruptionFilter); int ringerMode = audioManager.getRingerMode(); switch (interruptionFilter) { case NotificationManager.INTERRUPTION_FILTER_ALL: //if (ActivateProfileHelper.vibrationIsOn(/*context, */audioManager, true)) if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) zenMode = 4; else zenMode = 1; break; case NotificationManager.INTERRUPTION_FILTER_PRIORITY: //if (ActivateProfileHelper.vibrationIsOn(/*context, */audioManager, true)) if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) zenMode = 5; else zenMode = 2; break; case NotificationManager.INTERRUPTION_FILTER_NONE: zenMode = 3; break; case NotificationManager.INTERRUPTION_FILTER_ALARMS: zenMode = 6; break; case NotificationManager.INTERRUPTION_FILTER_UNKNOWN: zenMode = 1; break; } //PPApplication.logE("InterruptionFilterChangedBroadcastReceiver.getZenMode", "zenMode=" + zenMode); } return zenMode; }
Example 4
Source File: AlarmNotifications.java From SuntimesWidget with GNU General Public License v3.0 | 4 votes |
private static boolean passesInterruptionFilter(Context context, @NonNull AlarmClockItem item) { if (Build.VERSION.SDK_INT >= 23) { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); int filter = (notificationManager != null) ? notificationManager.getCurrentInterruptionFilter() : NotificationManager.INTERRUPTION_FILTER_UNKNOWN; switch (filter) { case NotificationManager.INTERRUPTION_FILTER_ALARMS: // (4) alarms only return (item.type == AlarmClockItem.AlarmType.ALARM); case NotificationManager.INTERRUPTION_FILTER_NONE: // (3) suppress all return false; case NotificationManager.INTERRUPTION_FILTER_PRIORITY: // (2) allow priority if (Build.VERSION.SDK_INT >= 28) { return (item.type == AlarmClockItem.AlarmType.ALARM) && (isCategorySet(getNotificationPolicy(notificationManager), PRIORITY_CATEGORY_ALARMS)); } else { return (item.type == AlarmClockItem.AlarmType.ALARM); } case NotificationManager.INTERRUPTION_FILTER_ALL: // (1) allow all case NotificationManager.INTERRUPTION_FILTER_UNKNOWN: // (0) unknown default: return true; } } else if (Build.VERSION.SDK_INT >= 21) { try { int zenMode = Settings.Global.getInt(context.getContentResolver(), "zen_mode"); switch (zenMode) { case 2: // Settings.Global.ZEN_MODE_NO_INTERRUPTIONS: return false; case 3: // Settings.Global.ZEN_MODE_ALARMS: case 1: // Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS: return (item.type == AlarmClockItem.AlarmType.ALARM); case 0: // Settings.Global.ZEN_MODE_OFF: default: return true; } } catch (Settings.SettingNotFoundException e) { Log.e(TAG, "interruptionFilter: Setting Not Found: zen_mode .. " + e); return true; } } else return true; }
Example 5
Source File: InterruptionFilterChangedBroadcastReceiver.java From PhoneProfilesPlus with Apache License 2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { //CallsCounter.logCounter(context, "InterruptionFilterChangedBroadcastReceiver.onReceive", "InterruptionFilterChangedBroadcastReceiver_onReceive"); //if (android.os.Build.VERSION.SDK_INT >= 23) { boolean no60 = !Build.VERSION.RELEASE.equals("6.0"); if (no60 && GlobalGUIRoutines.activityActionExists(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS, context)) { if (!RingerModeChangeReceiver.internalChange) { NotificationManager mNotificationManager = (NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { int interruptionFilter = mNotificationManager.getCurrentInterruptionFilter(); final AudioManager audioManager = (AudioManager) context.getApplicationContext().getSystemService(Context.AUDIO_SERVICE); int ringerMode = AudioManager.RINGER_MODE_NORMAL; if (audioManager != null) ringerMode = audioManager.getRingerMode(); // convert to profile zenMode int zenMode = 0; switch (interruptionFilter) { case NotificationManager.INTERRUPTION_FILTER_ALL: //if (ActivateProfileHelper.vibrationIsOn(/*context.getApplicationContext(), */audioManager, true)) if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) zenMode = 4; else zenMode = 1; break; case NotificationManager.INTERRUPTION_FILTER_PRIORITY: //if (ActivateProfileHelper.vibrationIsOn(/*context.getApplicationContext(), */audioManager, true)) if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) zenMode = 5; else zenMode = 2; break; case NotificationManager.INTERRUPTION_FILTER_NONE: zenMode = 3; break; case NotificationManager.INTERRUPTION_FILTER_ALARMS: zenMode = 6; break; case NotificationManager.INTERRUPTION_FILTER_UNKNOWN: zenMode = 1; break; } //PPApplication.logE(TAG, "onReceive(zenMode=" + zenMode + ')'); if (zenMode != 0) { RingerModeChangeReceiver.notUnlinkVolumes = true; ActivateProfileHelper.saveRingerMode(context.getApplicationContext(), 5); ActivateProfileHelper.saveZenMode(context.getApplicationContext(), zenMode); } } } //RingerModeChangeReceiver.setAlarmForDisableInternalChange(getApplicationContext()); } //} }
Example 6
Source File: ApiTwentyThreePlus.java From linphone-android with GNU General Public License v3.0 | 4 votes |
public static boolean isDoNotDisturbPolicyAllowingRinging( Context context, Address remoteAddress) { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); int filter = notificationManager.getCurrentInterruptionFilter(); if (filter == NotificationManager.INTERRUPTION_FILTER_PRIORITY) { Log.w("[Audio Manager] Priority interruption filter detected"); boolean accessGranted = notificationManager.isNotificationPolicyAccessGranted(); if (!accessGranted) { Log.e( "[Audio Manager] Access to policy is denied, let's assume it is not safe for ringing"); return false; } NotificationManager.Policy policy = notificationManager.getNotificationPolicy(); int callPolicy = policy.priorityCallSenders; if (callPolicy == NotificationManager.Policy.PRIORITY_SENDERS_ANY) { Log.i("[Audio Manager] Priority for calls is Any, we can ring"); } else { if (remoteAddress == null) { Log.e( "[Audio Manager] Remote address is null, let's assume it is not safe for ringing"); return false; } LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(remoteAddress); if (callPolicy == NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS) { Log.i("[Audio Manager] Priority for calls is Contacts, let's check"); if (contact == null) { Log.w( "[Audio Manager] Couldn't find a contact for address " + remoteAddress.asStringUriOnly()); return false; } else { Log.i( "[Audio Manager] Contact found for address " + remoteAddress.asStringUriOnly() + ", we can ring"); } } else if (callPolicy == NotificationManager.Policy.PRIORITY_SENDERS_STARRED) { Log.i("[Audio Manager] Priority for calls is Starred Contacts, let's check"); if (contact == null) { Log.w( "[Audio Manager] Couldn't find a contact for address " + remoteAddress.asStringUriOnly()); return false; } else if (!contact.isFavourite()) { Log.w( "[Audio Manager] Contact found for address " + remoteAddress.asStringUriOnly() + ", but it isn't starred"); return false; } else { Log.i( "[Audio Manager] Starred contact found for address " + remoteAddress.asStringUriOnly() + ", we can ring"); } } } } else if (filter == NotificationManager.INTERRUPTION_FILTER_ALARMS) { Log.w("[Audio Manager] Alarms interruption filter detected"); return false; } else { Log.i("[Audio Manager] Interruption filter is " + filter + ", we can ring"); } return true; }