From b83cc19fc0b6ec3a4c506c159eb94d927fa3790e Mon Sep 17 00:00:00 2001 From: Thomas Stuart Date: Wed, 6 Jul 2022 10:59:41 -0700 Subject: [PATCH] prohibit toggling setAudioModeIsVoip(false) for SM connection For context, there was a report of a VoIP app experiencing audio issues in call when switching between a self-managed and PSTN call. The root cause was from calling setAudioModeIsVoip(false) on a self-managed connection. To prevent misuse of the API, prevent toggling of setAudioModeIsVoIP(false) on a self-managed connection. Additionally, 2 CTS tests and 1 CtsVerifier test are put in place to assert there isnt manipulation of this API. Test: 2 cts, 1 CtsVerifier called "Telecom Call Audio test" bug: 236018173 Change-Id: I9161f9369f7bb37c1c2e3f9342e63693cb4f10cc --- telecomm/java/android/telecom/Connection.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 49ad58550db8f..7c736e38897d1 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -2763,6 +2763,12 @@ public abstract class Connection extends Conferenceable { * @param isVoip True if the audio mode is VOIP. */ public final void setAudioModeIsVoip(boolean isVoip) { + if (!isVoip && (mConnectionProperties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) { + Log.i(this, + "setAudioModeIsVoip: Ignored request to set a self-managed connection's" + + " audioModeIsVoip to false. Doing so can cause unwanted behavior."); + return; + } checkImmutable(); mAudioModeIsVoip = isVoip; for (Listener l : mListeners) {