OSDN Git Service

Select a system audio route only when needed
authorSungsoo Lim <sungsoo@google.com>
Thu, 14 Sep 2017 01:12:10 +0000 (10:12 +0900)
committerSungsoo Lim <sungsoo@google.com>
Mon, 18 Sep 2017 04:50:56 +0000 (13:50 +0900)
When system audio routes are changd, updateAudioRoutes is called, and
it selects a system audio route even when a none system route was
seleted.
That makes the selected route be unselected and this CL fixes it.

Bug: 65403568
Test: manual tested that the issue is fixed
Change-Id: I5df9d3e5f68cfd40fdb625937f9a8e16f4308e16

media/java/android/media/MediaRouter.java

index 2894e89..b072f65 100644 (file)
@@ -202,7 +202,6 @@ public class MediaRouter {
                 audioRoutesChanged = true;
             }
 
-            final int mainType = mCurAudioRoutesInfo.mainType;
             if (!TextUtils.equals(newRoutes.bluetoothName, mCurAudioRoutesInfo.bluetoothName)) {
                 mCurAudioRoutesInfo.bluetoothName = newRoutes.bluetoothName;
                 if (mCurAudioRoutesInfo.bluetoothName != null) {
@@ -229,8 +228,11 @@ public class MediaRouter {
             }
 
             if (audioRoutesChanged) {
-                selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, getDefaultSystemAudioRoute(), false);
                 Log.v(TAG, "Audio routes updated: " + newRoutes + ", a2dp=" + isBluetoothA2dpOn());
+                if (mSelectedRoute == null || mSelectedRoute == mDefaultAudioVideo
+                        || mSelectedRoute == mBluetoothA2dpRoute) {
+                    selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, getDefaultSystemAudioRoute(), false);
+                }
             }
         }