audio policy: use call screen mode
Enable playback over Call Tx path also when audio mode is CALL_SCREEN.
Was previously only possilbe when IN_CALL or IN_COMMUNICATION.
Also generalize use of isStateInCall() method instead of
a mix of isStateInCall() and is_state_in_call().
Bug: 140384450
Test: manual call screen test
Change-Id: Ifda4ee2f26a30ed8dbe43b172d86b18d906029cf
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index dc34cc7..741c351 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -682,8 +682,8 @@
* Switching to or from incall state or switching between telephony and VoIP lead to force
* routing command.
*/
- bool force = ((is_state_in_call(oldState) != is_state_in_call(state))
- || (is_state_in_call(state) && (state != oldState)));
+ bool force = ((isStateInCall(oldState) != isStateInCall(state))
+ || (isStateInCall(state) && (state != oldState)));
// check for device and output changes triggered by new phone state
checkForDeviceAndOutputChanges();
@@ -1015,7 +1015,7 @@
if (outputDevices.onlyContainsDevicesWithType(AUDIO_DEVICE_OUT_TELEPHONY_TX) &&
(*stream == AUDIO_STREAM_MUSIC || resultAttr->usage == AUDIO_USAGE_VOICE_COMMUNICATION) &&
audio_is_linear_pcm(config->format) &&
- isInCall()) {
+ isCallAudioAccessible()) {
if (requestedPortId != AUDIO_PORT_HANDLE_NONE) {
*flags = (audio_output_flags_t)AUDIO_OUTPUT_FLAG_INCALL_MUSIC;
*isRequestedDeviceForExclusiveUse = true;
@@ -6068,6 +6068,14 @@
return is_state_in_call(state);
}
+bool AudioPolicyManager::isCallAudioAccessible()
+{
+ audio_mode_t mode = mEngine->getPhoneState();
+ return (mode == AUDIO_MODE_IN_CALL)
+ || (mode == AUDIO_MODE_IN_COMMUNICATION)
+ || (mode == AUDIO_MODE_CALL_SCREEN);
+}
+
void AudioPolicyManager::cleanUpForDevice(const sp<DeviceDescriptor>& deviceDesc)
{
for (ssize_t i = (ssize_t)mAudioSources.size() - 1; i >= 0; i--) {