Respect setting for incoming call to vibrate

+ Previously the Dialer would always play a vibration pattern for
incoming calls, regardless of whether the user toggled the vibrate
setting off. This change causes the Dialer to respect that setting.

Bug=27353237

Change-Id: I65987cea0c13dd50fba5e0edacfba88b3e3ecbd7
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
index 1a4ec09..315c0d0 100644
--- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java
+++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java
@@ -315,7 +315,9 @@
             audioAttributes.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
             audioAttributes.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE);
             notification.audioAttributes = audioAttributes.build();
-            notification.vibrate = VIBRATE_PATTERN;
+            if (mDialerRingtoneManager.shouldVibrate(mContext.getContentResolver())) {
+                notification.vibrate = VIBRATE_PATTERN;
+            }
         }
         if (mDialerRingtoneManager.shouldPlayCallWaitingTone(callState)) {
             Log.v(this, "Playing call waiting tone");
diff --git a/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java b/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java
index 38b37a2..3803a3e 100644
--- a/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java
+++ b/InCallUI/src/com/android/incallui/ringtone/DialerRingtoneManager.java
@@ -18,7 +18,9 @@
 
 import com.google.common.base.Preconditions;
 
+import android.content.ContentResolver;
 import android.net.Uri;
+import android.provider.Settings;
 import android.support.annotation.Nullable;
 
 import com.android.contacts.common.compat.CompatUtils;
@@ -70,6 +72,17 @@
     }
 
     /**
+     * Determines if an incoming call should vibrate as well as ring.
+     *
+     * @param resolver {@link ContentResolver} used to look up the
+     * {@link Settings.System#VIBRATE_WHEN_RINGING} setting.
+     * @return {@code true} if the call should vibrate, {@code false} otherwise.
+     */
+    public boolean shouldVibrate(ContentResolver resolver) {
+        return Settings.System.getInt(resolver, Settings.System.VIBRATE_WHEN_RINGING, 0) != 0;
+    }
+
+    /**
      * The incoming callState is never set as {@link State#CALL_WAITING} because
      * {@link Call#translateState(int)} doesn't account for that case, check for it here
      */