Loading core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -3129,6 +3129,14 @@ public final class Settings { */ public static final String NOTIFICATION_CONVERT_SOUND_TO_VIBRATION = "convert_sound_to_vibration"; /** * Whether to allow notification vibration while notification alerts are disabled * (e.g. during phone calls). The vibration pattern to be used will be a subtle one; * custom vibration is disabled at that point. * @hide */ public static final String NOTIFICATION_VIBRATE_DURING_ALERTS_DISABLED = "vibrate_while_no_alerts"; /** * Custom navring actions * Loading Loading @@ -3217,6 +3225,7 @@ public final class Settings { NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR, NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_ON, NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_OFF, NOTIFICATION_VIBRATE_DURING_ALERTS_DISABLED, SIP_CALL_OPTIONS, SIP_RECEIVE_CALLS, POINTER_SPEED, Loading core/res/res/values/config.xml +10 −0 Original line number Diff line number Diff line Loading @@ -1054,6 +1054,16 @@ <item>100</item> </integer-array> <!-- Vibrator pattern to be used as for notifications while alerts are disabled (e.g. during phone calls) if enabled by the user. --> <integer-array name="config_notificationNoAlertsVibePattern"> <item>0</item> <item>50</item> <item>100</item> <item>50</item> </integer-array> <!-- Flag indicating if the speed up audio on mt call code should be executed --> <bool name="config_speed_up_audio_on_mt_calls">false</bool> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1859,6 +1859,7 @@ <java-symbol type="bool" name="config_intrusiveBatteryLed" /> <java-symbol type="bool" name="config_multiColorBatteryLed" /> <java-symbol type="array" name="notification_light_package_mapping" /> <java-symbol type="array" name="config_notificationNoAlertsVibePattern" /> <!-- Power menu --> <java-symbol type="string" name="global_action_screenshot" /> Loading services/java/com/android/server/NotificationManagerService.java +47 −17 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ public class NotificationManagerService extends INotificationManager.Stub private long[] mDefaultVibrationPattern; private long[] mFallbackVibrationPattern; private long[] mNoAlertsVibrationPattern; private boolean mSystemReady; private int mDisabledNotifications; Loading Loading @@ -775,6 +776,11 @@ public class NotificationManagerService extends INotificationManager.Stub VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN); mNoAlertsVibrationPattern = getLongArray(resources, com.android.internal.R.array.config_notificationNoAlertsVibePattern, VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN); // Don't start allowing notifications until the setup wizard has run once. // After that, including subsequent boots, init with notifications turned on. // This works on the first boot because the setup wizard will toggle this Loading Loading @@ -1215,15 +1221,15 @@ public class NotificationManagerService extends INotificationManager.Stub Log.e(TAG, "An error occurred profiling the notification.", th); } // If we're not supposed to beep, vibrate, etc. then don't. if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0) && (!(old != null && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 )) && (r.userId == UserHandle.USER_ALL || (r.userId == userId && r.userId == currentUser)) && canInterrupt && mSystemReady) { final boolean alertsDisabled = (mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; boolean readyForAlerts = canInterrupt && mSystemReady && (r.userId == UserHandle.USER_ALL || r.userId == userId && r.userId == currentUser) && (old == null || (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) == 0); boolean hasValidSound = false; // If we're not supposed to beep, vibrate, etc. then don't. if (readyForAlerts && !alertsDisabled) { final AudioManager audioManager = (AudioManager) mContext .getSystemService(Context.AUDIO_SERVICE); Loading @@ -1232,7 +1238,6 @@ public class NotificationManagerService extends INotificationManager.Stub (notification.defaults & Notification.DEFAULT_SOUND) != 0; Uri soundUri = null; boolean hasValidSound = false; if (!(inQuietHours && mQuietHoursMute) && useDefaultSound) { soundUri = Settings.System.DEFAULT_NOTIFICATION_URI; Loading Loading @@ -1271,8 +1276,14 @@ public class NotificationManagerService extends INotificationManager.Stub } } } } if (readyForAlerts && (!alertsDisabled || canVibrateDuringAlertsDisabled())) { // vibrate final AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); // Does the notification want to specify its own vibration? final boolean hasCustomVibrate = notification.vibrate != null; Loading @@ -1287,25 +1298,37 @@ public class NotificationManagerService extends INotificationManager.Stub // The DEFAULT_VIBRATE flag trumps any custom vibration AND the fallback. final boolean useDefaultVibrate = (notification.defaults & Notification.DEFAULT_VIBRATE) != 0; if (!(inQuietHours && mQuietHoursStill) && (useDefaultVibrate || convertSoundToVibration || hasCustomVibrate) && !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) { mVibrateNotification = r; int repeat = (notification.flags & Notification.FLAG_INSISTENT) != 0 ? 0: -1; long[] pattern; if (alertsDisabled) { pattern = mNoAlertsVibrationPattern; } else if (useDefaultVibrate) { pattern = mDefaultVibrationPattern; } else if (hasCustomVibrate) { pattern = notification.vibrate; } else { pattern = mFallbackVibrationPattern; } if (useDefaultVibrate || convertSoundToVibration) { // Escalate privileges so we can use the vibrator even if the notifying app // does not have the VIBRATE permission. long identity = Binder.clearCallingIdentity(); try { mVibrator.vibrate(useDefaultVibrate ? mDefaultVibrationPattern : mFallbackVibrationPattern, ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); mVibrator.vibrate(pattern, repeat); } finally { Binder.restoreCallingIdentity(identity); } } else if (notification.vibrate.length > 1) { } else if (pattern.length > 1) { // If you want your own vibration pattern, you need the VIBRATE permission mVibrator.vibrate(notification.vibrate, ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); mVibrator.vibrate(notification.vibrate, repeat); } } } Loading Loading @@ -1338,8 +1361,15 @@ public class NotificationManagerService extends INotificationManager.Stub } private boolean shouldConvertSoundToVibration() { return Settings.System.getInt(mContext.getContentResolver(), Settings.System.NOTIFICATION_CONVERT_SOUND_TO_VIBRATION, 1) != 0; return Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.NOTIFICATION_CONVERT_SOUND_TO_VIBRATION, 1, UserHandle.USER_CURRENT) != 0; } private boolean canVibrateDuringAlertsDisabled() { return Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.NOTIFICATION_VIBRATE_DURING_ALERTS_DISABLED, 0, UserHandle.USER_CURRENT) != 0; } private boolean inQuietHours() { Loading Loading
core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -3129,6 +3129,14 @@ public final class Settings { */ public static final String NOTIFICATION_CONVERT_SOUND_TO_VIBRATION = "convert_sound_to_vibration"; /** * Whether to allow notification vibration while notification alerts are disabled * (e.g. during phone calls). The vibration pattern to be used will be a subtle one; * custom vibration is disabled at that point. * @hide */ public static final String NOTIFICATION_VIBRATE_DURING_ALERTS_DISABLED = "vibrate_while_no_alerts"; /** * Custom navring actions * Loading Loading @@ -3217,6 +3225,7 @@ public final class Settings { NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR, NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_ON, NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_OFF, NOTIFICATION_VIBRATE_DURING_ALERTS_DISABLED, SIP_CALL_OPTIONS, SIP_RECEIVE_CALLS, POINTER_SPEED, Loading
core/res/res/values/config.xml +10 −0 Original line number Diff line number Diff line Loading @@ -1054,6 +1054,16 @@ <item>100</item> </integer-array> <!-- Vibrator pattern to be used as for notifications while alerts are disabled (e.g. during phone calls) if enabled by the user. --> <integer-array name="config_notificationNoAlertsVibePattern"> <item>0</item> <item>50</item> <item>100</item> <item>50</item> </integer-array> <!-- Flag indicating if the speed up audio on mt call code should be executed --> <bool name="config_speed_up_audio_on_mt_calls">false</bool> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1859,6 +1859,7 @@ <java-symbol type="bool" name="config_intrusiveBatteryLed" /> <java-symbol type="bool" name="config_multiColorBatteryLed" /> <java-symbol type="array" name="notification_light_package_mapping" /> <java-symbol type="array" name="config_notificationNoAlertsVibePattern" /> <!-- Power menu --> <java-symbol type="string" name="global_action_screenshot" /> Loading
services/java/com/android/server/NotificationManagerService.java +47 −17 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ public class NotificationManagerService extends INotificationManager.Stub private long[] mDefaultVibrationPattern; private long[] mFallbackVibrationPattern; private long[] mNoAlertsVibrationPattern; private boolean mSystemReady; private int mDisabledNotifications; Loading Loading @@ -775,6 +776,11 @@ public class NotificationManagerService extends INotificationManager.Stub VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN); mNoAlertsVibrationPattern = getLongArray(resources, com.android.internal.R.array.config_notificationNoAlertsVibePattern, VIBRATE_PATTERN_MAXLEN, DEFAULT_VIBRATE_PATTERN); // Don't start allowing notifications until the setup wizard has run once. // After that, including subsequent boots, init with notifications turned on. // This works on the first boot because the setup wizard will toggle this Loading Loading @@ -1215,15 +1221,15 @@ public class NotificationManagerService extends INotificationManager.Stub Log.e(TAG, "An error occurred profiling the notification.", th); } // If we're not supposed to beep, vibrate, etc. then don't. if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0) && (!(old != null && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 )) && (r.userId == UserHandle.USER_ALL || (r.userId == userId && r.userId == currentUser)) && canInterrupt && mSystemReady) { final boolean alertsDisabled = (mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0; boolean readyForAlerts = canInterrupt && mSystemReady && (r.userId == UserHandle.USER_ALL || r.userId == userId && r.userId == currentUser) && (old == null || (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) == 0); boolean hasValidSound = false; // If we're not supposed to beep, vibrate, etc. then don't. if (readyForAlerts && !alertsDisabled) { final AudioManager audioManager = (AudioManager) mContext .getSystemService(Context.AUDIO_SERVICE); Loading @@ -1232,7 +1238,6 @@ public class NotificationManagerService extends INotificationManager.Stub (notification.defaults & Notification.DEFAULT_SOUND) != 0; Uri soundUri = null; boolean hasValidSound = false; if (!(inQuietHours && mQuietHoursMute) && useDefaultSound) { soundUri = Settings.System.DEFAULT_NOTIFICATION_URI; Loading Loading @@ -1271,8 +1276,14 @@ public class NotificationManagerService extends INotificationManager.Stub } } } } if (readyForAlerts && (!alertsDisabled || canVibrateDuringAlertsDisabled())) { // vibrate final AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); // Does the notification want to specify its own vibration? final boolean hasCustomVibrate = notification.vibrate != null; Loading @@ -1287,25 +1298,37 @@ public class NotificationManagerService extends INotificationManager.Stub // The DEFAULT_VIBRATE flag trumps any custom vibration AND the fallback. final boolean useDefaultVibrate = (notification.defaults & Notification.DEFAULT_VIBRATE) != 0; if (!(inQuietHours && mQuietHoursStill) && (useDefaultVibrate || convertSoundToVibration || hasCustomVibrate) && !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) { mVibrateNotification = r; int repeat = (notification.flags & Notification.FLAG_INSISTENT) != 0 ? 0: -1; long[] pattern; if (alertsDisabled) { pattern = mNoAlertsVibrationPattern; } else if (useDefaultVibrate) { pattern = mDefaultVibrationPattern; } else if (hasCustomVibrate) { pattern = notification.vibrate; } else { pattern = mFallbackVibrationPattern; } if (useDefaultVibrate || convertSoundToVibration) { // Escalate privileges so we can use the vibrator even if the notifying app // does not have the VIBRATE permission. long identity = Binder.clearCallingIdentity(); try { mVibrator.vibrate(useDefaultVibrate ? mDefaultVibrationPattern : mFallbackVibrationPattern, ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); mVibrator.vibrate(pattern, repeat); } finally { Binder.restoreCallingIdentity(identity); } } else if (notification.vibrate.length > 1) { } else if (pattern.length > 1) { // If you want your own vibration pattern, you need the VIBRATE permission mVibrator.vibrate(notification.vibrate, ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); mVibrator.vibrate(notification.vibrate, repeat); } } } Loading Loading @@ -1338,8 +1361,15 @@ public class NotificationManagerService extends INotificationManager.Stub } private boolean shouldConvertSoundToVibration() { return Settings.System.getInt(mContext.getContentResolver(), Settings.System.NOTIFICATION_CONVERT_SOUND_TO_VIBRATION, 1) != 0; return Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.NOTIFICATION_CONVERT_SOUND_TO_VIBRATION, 1, UserHandle.USER_CURRENT) != 0; } private boolean canVibrateDuringAlertsDisabled() { return Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.NOTIFICATION_VIBRATE_DURING_ALERTS_DISABLED, 0, UserHandle.USER_CURRENT) != 0; } private boolean inQuietHours() { Loading