Skip to content

Commit 020d652

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Do not vibe when the default notification sound is Silent." into jb-mr1.1-dev
2 parents 83b2596 + d4d2de2 commit 020d652

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,16 +1077,27 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
10771077

10781078
final AudioManager audioManager = (AudioManager) mContext
10791079
.getSystemService(Context.AUDIO_SERVICE);
1080+
10801081
// sound
10811082
final boolean useDefaultSound =
10821083
(notification.defaults & Notification.DEFAULT_SOUND) != 0;
1083-
if (useDefaultSound || notification.sound != null) {
1084-
Uri uri;
1085-
if (useDefaultSound) {
1086-
uri = Settings.System.DEFAULT_NOTIFICATION_URI;
1087-
} else {
1088-
uri = notification.sound;
1089-
}
1084+
1085+
Uri soundUri = null;
1086+
boolean hasValidSound = false;
1087+
1088+
if (useDefaultSound) {
1089+
soundUri = Settings.System.DEFAULT_NOTIFICATION_URI;
1090+
1091+
// check to see if the default notification sound is silent
1092+
ContentResolver resolver = mContext.getContentResolver();
1093+
hasValidSound = Settings.System.getString(resolver,
1094+
Settings.System.NOTIFICATION_SOUND) != null;
1095+
} else if (notification.sound != null) {
1096+
soundUri = notification.sound;
1097+
hasValidSound = (soundUri != null);
1098+
}
1099+
1100+
if (hasValidSound) {
10901101
boolean looping = (notification.flags & Notification.FLAG_INSISTENT) != 0;
10911102
int audioStreamType;
10921103
if (notification.audioStreamType >= 0) {
@@ -1103,7 +1114,7 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
11031114
try {
11041115
final IRingtonePlayer player = mAudioService.getRingtonePlayer();
11051116
if (player != null) {
1106-
player.playAsync(uri, user, looping, audioStreamType);
1117+
player.playAsync(soundUri, user, looping, audioStreamType);
11071118
}
11081119
} catch (RemoteException e) {
11091120
} finally {
@@ -1120,7 +1131,7 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
11201131
// and no other vibration is specified, we apply the default vibration anyway
11211132
final boolean convertSoundToVibration =
11221133
!hasCustomVibrate
1123-
&& (useDefaultSound || notification.sound != null)
1134+
&& hasValidSound
11241135
&& (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE);
11251136

11261137
// The DEFAULT_VIBRATE flag trumps any custom vibration.

0 commit comments

Comments
 (0)