Skip to content

Commit 4a7a9b9

Browse files
committed
DEFAULT_VIBRATE must always use the default vibe pattern
The logic here was backwards, causing the (softer) fallback vibe pattern to be applied if the notification specified a sound (or DEFAULT_SOUND) and also DEFAULT_VIBRATE. The fallback vibe should only play if you have *no* vibration set. Bug: 7588655 Change-Id: Iecdd362729bccedf779b51cc9b90a12014328aff
1 parent 2656abe commit 4a7a9b9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

services/java/com/android/server/NotificationManagerService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,13 +1128,13 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
11281128
final boolean hasCustomVibrate = notification.vibrate != null;
11291129

11301130
// new in 4.2: if there was supposed to be a sound and we're in vibrate mode,
1131-
// and no other vibration is specified, we apply the default vibration anyway
1131+
// and no other vibration is specified, we fall back to vibration
11321132
final boolean convertSoundToVibration =
11331133
!hasCustomVibrate
11341134
&& hasValidSound
11351135
&& (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE);
11361136

1137-
// The DEFAULT_VIBRATE flag trumps any custom vibration.
1137+
// The DEFAULT_VIBRATE flag trumps any custom vibration AND the fallback.
11381138
final boolean useDefaultVibrate =
11391139
(notification.defaults & Notification.DEFAULT_VIBRATE) != 0;
11401140

@@ -1147,8 +1147,8 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
11471147
// does not have the VIBRATE permission.
11481148
long identity = Binder.clearCallingIdentity();
11491149
try {
1150-
mVibrator.vibrate(convertSoundToVibration ? mFallbackVibrationPattern
1151-
: mDefaultVibrationPattern,
1150+
mVibrator.vibrate(useDefaultVibrate ? mDefaultVibrationPattern
1151+
: mFallbackVibrationPattern,
11521152
((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);
11531153
} finally {
11541154
Binder.restoreCallingIdentity(identity);

0 commit comments

Comments
 (0)