summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHall Liu <hallliu@google.com>2019-06-13 18:59:59 -0700
committerHall Liu <hallliu@google.com>2019-06-14 21:28:02 +0000
commitf430e0a9c8a111138e59347ec0de5e50842a68fa (patch)
treede8a8b7e2fc09ed8359f0f67da728cbdb242efbf /src
parent92d32918d87205238e56fff02c0eedb3c1c5cbe6 (diff)
downloadandroid_packages_services_Telecomm-f430e0a9c8a111138e59347ec0de5e50842a68fa.tar.gz
android_packages_services_Telecomm-f430e0a9c8a111138e59347ec0de5e50842a68fa.tar.bz2
android_packages_services_Telecomm-f430e0a9c8a111138e59347ec0de5e50842a68fa.zip
Fix ordering issue with vibration
When someone calls stopRinging, also cancel the pending completablefuture that's supported to start vibration. Prior to this change, if a user picked up a call really quickly before the haptics lookup had a chance to complete, stopRinging would get called before the vibration even started. Then, when the haptics lookup completes, it'll trigger the vibration to start. With nothing to stop it, the vibration will continue until the user reboots the device or receives another call. Fixes: 134833743 Test: unit, manual Change-Id: I6968a1ed0693e0eb839b3d9be032d5bed9525f77
Diffstat (limited to 'src')
-rw-r--r--src/com/android/server/telecom/Ringer.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index b5ff31dc..2909b726 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -146,6 +146,8 @@ public class Ringer {
*/
private CompletableFuture<Void> mBlockOnRingingFuture = null;
+ private CompletableFuture<Void> mVibrateFuture = CompletableFuture.completedFuture(null);
+
private InCallTonePlayer mCallWaitingPlayer;
private RingtoneFactory mRingtoneFactory;
@@ -324,8 +326,7 @@ public class Ringer {
}
if (hapticsFuture != null) {
- CompletableFuture<Void> vibrateFuture =
- hapticsFuture.thenAccept(isUsingAudioCoupledHaptics -> {
+ mVibrateFuture = hapticsFuture.thenAccept(isUsingAudioCoupledHaptics -> {
if (!isUsingAudioCoupledHaptics || !mIsHapticPlaybackSupportedByDevice) {
Log.i(this, "startRinging: fileHasHaptics=%b, hapticsSupported=%b",
isUsingAudioCoupledHaptics, mIsHapticPlaybackSupportedByDevice);
@@ -337,10 +338,7 @@ public class Ringer {
}
});
if (mBlockOnRingingFuture != null) {
- vibrateFuture.thenCompose( v -> {
- mBlockOnRingingFuture.complete(null);
- return null;
- });
+ mVibrateFuture.whenComplete((v, e) -> mBlockOnRingingFuture.complete(null));
}
} else {
if (mBlockOnRingingFuture != null) {
@@ -438,6 +436,12 @@ public class Ringer {
mRingtonePlayer.stop();
+ // If we haven't started vibrating because we were waiting for the haptics info, cancel
+ // it and don't vibrate at all.
+ if (mVibrateFuture != null) {
+ mVibrateFuture.cancel(true);
+ }
+
if (mIsVibrating) {
Log.addEvent(mVibratingCall, LogUtils.Events.STOP_VIBRATOR);
mVibrator.cancel();