Set audio mode back to normal before we abandon the audio focus after
call.
Currently, we set the audio mode back to normal after we abandon the
audio focus when the call disconnected. This may cause audio playback
switching delay after the call.
Bug: b/281841785
Test: Manually test audio switching after call using Youtube music.
Change-Id: I5b2db68b4b4d2420be34295064413d8b70daac7e
diff --git a/flags/Android.bp b/flags/Android.bp
index 99e2dc5..450cb1b 100644
--- a/flags/Android.bp
+++ b/flags/Android.bp
@@ -29,6 +29,7 @@
"telecom_incallservice_flags.aconfig",
"telecom_default_phone_account_flags.aconfig",
"telecom_callaudioroutestatemachine_flags.aconfig",
+ "telecom_callaudiomodestatemachine_flags.aconfig",
"telecom_calllog_flags.aconfig",
"telecom_resolve_hidden_dependencies.aconfig"
],
diff --git a/flags/telecom_callaudiomodestatemachine_flags.aconfig b/flags/telecom_callaudiomodestatemachine_flags.aconfig
new file mode 100644
index 0000000..b263113
--- /dev/null
+++ b/flags/telecom_callaudiomodestatemachine_flags.aconfig
@@ -0,0 +1,8 @@
+package: "com.android.server.telecom.flags"
+
+flag {
+ name: "set_audio_mode_before_abandon_focus"
+ namespace: "telecom"
+ description: "Set audio mode to MODE_NORMAL before abandon the audio focus."
+ bug: "281841785"
+}
diff --git a/src/com/android/server/telecom/CallAudioModeStateMachine.java b/src/com/android/server/telecom/CallAudioModeStateMachine.java
index 6831770..90da8ed 100644
--- a/src/com/android/server/telecom/CallAudioModeStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioModeStateMachine.java
@@ -277,8 +277,15 @@
Log.i(LOG_TAG, "Audio focus entering UNFOCUSED state");
mLocalLog.log("Enter UNFOCUSED");
if (mIsInitialized) {
- mCallAudioManager.setCallAudioRouteFocusState(CallAudioRouteStateMachine.NO_FOCUS);
- mAudioManager.setMode(AudioManager.MODE_NORMAL);
+ if (mFeatureFlags.setAudioModeBeforeAbandonFocus()) {
+ mAudioManager.setMode(AudioManager.MODE_NORMAL);
+ mCallAudioManager.setCallAudioRouteFocusState(
+ CallAudioRouteStateMachine.NO_FOCUS);
+ } else {
+ mCallAudioManager.setCallAudioRouteFocusState(
+ CallAudioRouteStateMachine.NO_FOCUS);
+ mAudioManager.setMode(AudioManager.MODE_NORMAL);
+ }
mLocalLog.log("Mode MODE_NORMAL");
mMostRecentMode = AudioManager.MODE_NORMAL;
// Don't release focus here -- wait until we get a signal that any other audio