Preserve speaker on unhold
When the call audio is routed to speaker and the call is held, when the
call is unheld, ensure that the audio routing remains on speakerphone
unless the user had requested to switch it.
We can reuse the existing mWasOnSpeaker phone logic added to handle
preserving speaker on wired headset disconnects for this logic as well.
Bug: 406898224
Flag:com.android.server.telecom.flags.maybe_default_speaker_after_unhold
Test: Manual testing with call on speaker and holding/unholding the call
as well as verifying speaker does not persist when explicitly moving to
a different route while the call is still held.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:bbcc0b78839a6768c8395ffc616c1521485f92c0)
Merged-In: Ib3c16c068f26a48a2f6a78a61fd9319578a11a82
Change-Id: Ib3c16c068f26a48a2f6a78a61fd9319578a11a82
diff --git a/flags/telecom_callaudioroutestatemachine_flags.aconfig b/flags/telecom_callaudioroutestatemachine_flags.aconfig
index 76a7f74..c0edf7f 100644
--- a/flags/telecom_callaudioroutestatemachine_flags.aconfig
+++ b/flags/telecom_callaudioroutestatemachine_flags.aconfig
@@ -195,3 +195,14 @@
purpose: PURPOSE_BUGFIX
}
}
+
+# OWNER=pmadapurmath TARGET=25Q3
+flag {
+ name: "maybe_default_speaker_after_unhold"
+ namespace: "telecom"
+ description: "If the call audio route was on speaker and the call is held/unheld, ensure that we route back to speaker."
+ bug: "406898224"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/src/com/android/server/telecom/CallAudioRouteController.java b/src/com/android/server/telecom/CallAudioRouteController.java
index aa0976f..727b9ce 100644
--- a/src/com/android/server/telecom/CallAudioRouteController.java
+++ b/src/com/android/server/telecom/CallAudioRouteController.java
@@ -1399,11 +1399,14 @@
? mEarpieceWiredRoute
: mSpeakerDockRoute;
// Ensure that we default to speaker route if we're in a video call, but disregard it if
- // a wired headset is plugged in.
- if (skipEarpiece && defaultRoute != null
+ // a wired headset is plugged in. Also consider the case when we're holding/unholding a
+ // call. If the route was on speaker mode, ensure that we preserve the route selection.
+ boolean shouldDefaultSpeaker = mFeatureFlags.maybeDefaultSpeakerAfterUnhold()
+ && mWasOnSpeaker;
+ if ((skipEarpiece || shouldDefaultSpeaker) && defaultRoute != null
&& defaultRoute.getType() == AudioRoute.TYPE_EARPIECE) {
Log.i(this, "getPreferredAudioRouteFromDefault: Audio routing defaulting to "
- + "speaker route for video call.");
+ + "speaker route for (video) call.");
defaultRoute = mSpeakerDockRoute;
}
return defaultRoute;