Support communication device APIs for TYPE_BUS
Audio fwk team has agreed to allow list TYPE_BUS as a valid
communication device. Modify the existing code so that TYPE_BUS uses the
set/clear communication device logic and ensure that retrieval of the
audio route is done via AudioManager#getAvailableCommunicationDevices.
Bug: 365612739
Bug: 367798741
Test: atest CallAudioRouteControllerTest
Test: atest ExtendedInCallServiceTest#testSwitchCallEndpoint
Flag: com.android.server.telecom.flags.use_refactored_audio_route_switching
Change-Id: I920c45e9e22b4489c6cae5d88ff39689be0ab75f
diff --git a/src/com/android/server/telecom/AudioRoute.java b/src/com/android/server/telecom/AudioRoute.java
index 4f563a1..12af811 100644
--- a/src/com/android/server/telecom/AudioRoute.java
+++ b/src/com/android/server/telecom/AudioRoute.java
@@ -251,10 +251,6 @@
BluetoothRouteManager bluetoothRouteManager, boolean isScoAudioConnected) {
Log.i(this, "onDestRouteAsPendingRoute: active (%b), type (%s)", active,
DEVICE_TYPE_STRINGS.get(mAudioRouteType));
- if (mAudioRouteType == TYPE_BUS) {
- Log.i(this, "onDestRouteAsPendingRoute: Ignore processing dest route for TYPE_BUS");
- return;
- }
if (pendingAudioRoute.isActive() && !active) {
clearCommunicationDevice(pendingAudioRoute, bluetoothRouteManager, audioManager);
} else if (active) {
@@ -316,10 +312,6 @@
void onOrigRouteAsPendingRoute(boolean active, PendingAudioRoute pendingAudioRoute,
AudioManager audioManager, BluetoothRouteManager bluetoothRouteManager) {
Log.i(this, "onOrigRouteAsPendingRoute: active (%b), type (%d)", active, mAudioRouteType);
- if (mAudioRouteType == TYPE_BUS) {
- Log.i(this, "onOrigRouteAsPendingRoute: Ignore processing dest route for TYPE_BUS");
- return;
- }
if (active) {
if (mAudioRouteType == TYPE_SPEAKER) {
pendingAudioRoute.addMessage(SPEAKER_OFF, null);
diff --git a/src/com/android/server/telecom/CallAudioRouteController.java b/src/com/android/server/telecom/CallAudioRouteController.java
index 0ed4308..6b2c5fa 100644
--- a/src/com/android/server/telecom/CallAudioRouteController.java
+++ b/src/com/android/server/telecom/CallAudioRouteController.java
@@ -357,18 +357,19 @@
// Create speaker routes
mSpeakerDockRoute = mAudioRouteFactory.create(AudioRoute.TYPE_SPEAKER, null,
mAudioManager);
- // Todo(b/364562758): Represent TYPE_BUS as CallAudioState.ROUTE_SPEAKER (moving
- // forward, we may rework this if audio fwk team decides to allow list this as a
- // valid communication device.
- if (mSpeakerDockRoute != null || hasBusAudioDevice()) {
- if (mSpeakerDockRoute == null){
- mSpeakerDockRoute = new AudioRoute(AudioRoute.TYPE_BUS, null, null);
- audioRouteType = AudioRoute.TYPE_BUS;
- }
+ if (mSpeakerDockRoute == null){
+ Log.i(this, "Can't find available audio device info for route TYPE_SPEAKER, trying"
+ + " for TYPE_BUS");
+ mSpeakerDockRoute = mAudioRouteFactory.create(AudioRoute.TYPE_BUS, null,
+ mAudioManager);
+ audioRouteType = AudioRoute.TYPE_BUS;
+ }
+ if (mSpeakerDockRoute != null) {
mTypeRoutes.put(audioRouteType, mSpeakerDockRoute);
updateAvailableRoutes(mSpeakerDockRoute, true);
} else {
- Log.w(this, "Can't find available audio device info for route TYPE_SPEAKER");
+ Log.w(this, "Can't find available audio device info for route TYPE_SPEAKER "
+ + "or TYPE_BUS.");
}
}
@@ -1129,25 +1130,6 @@
return mAudioManager.getPreferredDeviceForStrategy(strategy);
}
- /**
- * For auto, there is no earpiece or speakerphone routes available. The audio is routed to the
- * bus but because this isn't a valid communication device,
- * {@link AudioManager#getCommunicationDevice()} will not provide this device even if audio fwk
- * reports it as the active communication device (refer to
- * AudioDeviceBroker#getCommunicationDeviceInt()}. Check if the device is the preferred device
- * for strategy instead.
- */
- private boolean hasBusAudioDevice() {
- AudioDeviceAttributes deviceAttr = getPreferredDeviceForStrategy();
- if (deviceAttr == null) {
- return false;
- }
- // Get corresponding audio route mapping
- @AudioRoute.AudioRouteType int type = AudioRoute.DEVICE_INFO_TYPE_TO_AUDIO_ROUTE_TYPE.get(
- deviceAttr.getType());
- return type == AudioRoute.TYPE_BUS;
- }
-
private AudioRoute getPreferredAudioRouteFromDefault(boolean includeBluetooth,
String btAddressToExclude) {
boolean skipEarpiece;