summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2017-08-04 16:48:03 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-08-04 16:48:03 +0000
commit3b4b1f000d3f80d520365621133e8189db856c4a (patch)
treed3cdfcc47470dee30ed8f391f1ba981b8341740a /src
parent9bdb06ab7281d7816ad5581d681e3f5c8cc69952 (diff)
parent9d52d391d66a0fb65063f8c5063a37e3c8d32452 (diff)
downloadandroid_packages_services_Telecomm-3b4b1f000d3f80d520365621133e8189db856c4a.tar.gz
android_packages_services_Telecomm-3b4b1f000d3f80d520365621133e8189db856c4a.tar.bz2
android_packages_services_Telecomm-3b4b1f000d3f80d520365621133e8189db856c4a.zip
Merge "Adding new haptic pattern for ringing incoming calls." into oc-dr1-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/server/telecom/Ringer.java33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index d9552279..36bb4ed8 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -19,6 +19,7 @@ package com.android.server.telecom;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
+import android.os.VibrationEffect;
import android.telecom.Log;
import android.media.AudioAttributes;
import android.media.AudioManager;
@@ -33,20 +34,30 @@ import com.android.internal.annotations.VisibleForTesting;
*/
@VisibleForTesting
public class Ringer {
- private static final long[] VIBRATION_PATTERN = new long[] {
- 0, // No delay before starting
- 1000, // How long to vibrate
- 1000, // How long to wait before vibrating again
- };
+ VibrationEffect mVibrationEffect;
+
+ private static final long[] PULSE_PATTERN = {0,12,250,12,500, // priming + interval
+ 50,50,50,50,50,50,50,50,50,50,50,50,50,50, // ease-in
+ 300, // Peak
+ 1000}; // pause before repetition
+
+ private static final int[] PULSE_AMPLITUDE = {0,255,0,255,0, // priming + interval
+ 77,77,78,79,81,84,87,93,101,114,133,162,205,255, // ease-in (min amplitude = 30%)
+ 255, // Peak
+ 0}; // pause before repetition
+
+ /**
+ * Indicates that vibration should be repeated at element 5 in the {@link #PULSE_AMPLITUDE} and
+ * {@link #PULSE_PATTERN} arrays. This means repetition will happen for the main ease-in/peak
+ * pattern, but the priming + interval part will not be repeated.
+ */
+ private static final int REPEAT_VIBRATION_AT = 5;
private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
.build();
- /** Indicate that we want the pattern to repeat at the step which turns on vibration. */
- private static final int VIBRATION_PATTERN_REPEAT = 1;
-
/**
* Used to keep ordering of unanswered incoming calls. There can easily exist multiple incoming
* calls and explicit ordering is useful for maintaining the proper state of the ringer.
@@ -95,6 +106,9 @@ public class Ringer {
mRingtonePlayer = asyncRingtonePlayer;
mRingtoneFactory = ringtoneFactory;
mInCallController = inCallController;
+
+ mVibrationEffect = VibrationEffect.createWaveform(PULSE_PATTERN, PULSE_AMPLITUDE,
+ REPEAT_VIBRATION_AT);
}
public boolean startRinging(Call foregroundCall, boolean isHfpDeviceAttached) {
@@ -151,8 +165,7 @@ public class Ringer {
if (shouldVibrate(mContext, foregroundCall) && !mIsVibrating && shouldRingForContact) {
mVibratingCall = foregroundCall;
- mVibrator.vibrate(VIBRATION_PATTERN, VIBRATION_PATTERN_REPEAT,
- VIBRATION_ATTRIBUTES);
+ mVibrator.vibrate(mVibrationEffect, VIBRATION_ATTRIBUTES);
mIsVibrating = true;
} else if (mIsVibrating) {
Log.addEvent(foregroundCall, LogUtils.Events.SKIP_VIBRATION, "already vibrating");