summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Michael Wright <michaelwr@google.com> 2017-10-10 18:41:28 +0000
committer android-build-merger <android-build-merger@google.com> 2017-10-10 18:41:28 +0000
commitd3a55f4a1a5cb46b7a61993c831532800ffcd05a (patch)
treeaca6d981bfef1400b6763fb22ca6e49b543aeab4
parente2ce9017cd598c7c4b4d5bb98fac15792d4b6803 (diff)
parent9880b151751334f1218cef142736a33b53818119 (diff)
Merge "Ignore non-repeating vibrations in favor of repeating vibrations." into oc-mr1-dev am: 33238f213f
am: 9880b15175 Change-Id: I4876a17560bc082abfec5918005386777c7d04cb
-rw-r--r--services/core/java/com/android/server/VibratorService.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java
index 046eb761d1c0..8b79b9ddfef2 100644
--- a/services/core/java/com/android/server/VibratorService.java
+++ b/services/core/java/com/android/server/VibratorService.java
@@ -373,12 +373,24 @@ public class VibratorService extends IVibratorService.Stub
if (mCurrentVibration.hasLongerTimeout(newOneShot.getTiming())
&& newOneShot.getAmplitude() == currentOneShot.getAmplitude()) {
if (DEBUG) {
- Slog.e(TAG, "Ignoring incoming vibration in favor of current vibration");
+ Slog.d(TAG, "Ignoring incoming vibration in favor of current vibration");
}
return;
}
}
+ // If the current vibration is repeating and the incoming one is non-repeating, then ignore
+ // the non-repeating vibration. This is so that we don't cancel vibrations that are meant
+ // to grab the attention of the user, like ringtones and alarms, in favor of one-shot
+ // vibrations that are likely quite short.
+ if (!isRepeatingVibration(effect)
+ && mCurrentVibration != null && isRepeatingVibration(mCurrentVibration.mEffect)) {
+ if (DEBUG) {
+ Slog.d(TAG, "Ignoring incoming vibration in favor of alarm vibration");
+ }
+ return;
+ }
+
Vibration vib = new Vibration(token, effect, usageHint, uid, opPkg);
// Only link against waveforms since they potentially don't have a finish if
@@ -404,6 +416,16 @@ public class VibratorService extends IVibratorService.Stub
}
}
+ private static boolean isRepeatingVibration(VibrationEffect effect) {
+ if (effect instanceof VibrationEffect.Waveform) {
+ final VibrationEffect.Waveform waveform = (VibrationEffect.Waveform) effect;
+ if (waveform.getRepeatIndex() >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private void addToPreviousVibrationsLocked(Vibration vib) {
if (mPreviousVibrations.size() > mPreviousVibrationsLimit) {
mPreviousVibrations.removeFirst();