Merge "Support pulled atoms for Telecom metrics" into main
diff --git a/src/com/android/server/telecom/AudioRoute.java b/src/com/android/server/telecom/AudioRoute.java
index f402099..d469a43 100644
--- a/src/com/android/server/telecom/AudioRoute.java
+++ b/src/com/android/server/telecom/AudioRoute.java
@@ -256,10 +256,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) {
@@ -323,10 +319,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 d07d554..ca9fe5b 100644
--- a/src/com/android/server/telecom/CallAudioRouteController.java
+++ b/src/com/android/server/telecom/CallAudioRouteController.java
@@ -360,18 +360,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.");
             }
         }
 
@@ -1138,25 +1139,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;