Introduce vibration options for voicemail notification
[android/platform/packages/apps/Phone.git] / src / com / android / phone / NotificationMgr.java
index fc7cc87..39fcbd1 100644 (file)
@@ -1122,7 +1122,19 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
                     pendingIntent  // contentIntent
                     );
             notification.defaults |= Notification.DEFAULT_SOUND;
-            notification.defaults |= Notification.DEFAULT_VIBRATE;
+
+            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
+            String vibrateWhen = prefs.getString(
+                    CallFeaturesSetting.BUTTON_VOICEMAIL_NOTIFICATION_VIBRATE_WHEN_KEY, "never");
+            boolean vibrateAlways = vibrateWhen.equals("always");
+            boolean vibrateSilent = vibrateWhen.equals("silent");
+            AudioManager audioManager =
+                    (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+            boolean nowSilent = audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE;
+            if (vibrateAlways || (vibrateSilent && nowSilent)) {
+                notification.defaults |= Notification.DEFAULT_VIBRATE;
+            }
+
             notification.flags |= Notification.FLAG_NO_CLEAR;
             configureLedNotification(notification);
             mNotificationManager.notify(VOICEMAIL_NOTIFICATION, notification);