audio policy: fix call audio switching from BT SCO to earpiece
commit c0697594 made that A2DP is unconditionally used for phone
strategy when connected. This creates a problem when disabling SCO
as the call is now routed to A2DP instead of earpiece by default which
changes from the expected route and does not work if the system suspends
A2DP audio when a call starts.
Restore previous policy by removing A2DP devices from eligible
devices for phone strategy when in call. This preserves the fix for
b/184771057 by still routing voice mails to A2DP when connected.
Bug: 188020987
Bug: 184771057
Test: manual call audio regression.
Change-Id: Ibab19c6150b84f8e8a46e4389b66f20cff205c10
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index f67ffc1..27a7ac4 100644
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -186,6 +186,12 @@
(primaryOutput->getPolicyAudioPort()->getModuleVersionMajor() < 3))) {
availableOutputDevices = availPrimaryOutputDevices;
}
+
+ // Do not use A2DP devices when in call but use them when not in call
+ // (e.g for voice mail playback)
+ availableOutputDevices.remove(availableOutputDevices.getDevicesFromTypes({
+ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES,
+ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, }));
}
} break;
case STRATEGY_ACCESSIBILITY: {