diff options
author | Adam Powell <adamp@google.com> | 2012-07-16 17:33:40 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-07-16 17:33:40 -0700 |
commit | c36b8acd1e850619de0bbf678b9573d4d761d836 (patch) | |
tree | 9740e49086f10fee2a50a3cf71c81ec5d36b1458 /media/java | |
parent | 4fbbea09ffbb0c294cfe608d0eb5e830809c95be (diff) | |
parent | 388953942b536b5eebd942ef78ae5b7499bc2078 (diff) | |
download | frameworks_base-c36b8acd1e850619de0bbf678b9573d4d761d836.zip frameworks_base-c36b8acd1e850619de0bbf678b9573d4d761d836.tar.gz frameworks_base-c36b8acd1e850619de0bbf678b9573d4d761d836.tar.bz2 |
am 38895394: Merge "Properly switch MediaRouter to wired audio over a2dp." into jb-dev
* commit '388953942b536b5eebd942ef78ae5b7499bc2078':
Properly switch MediaRouter to wired audio over a2dp.
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/MediaRouter.java | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java index 357bf4e..a256079 100644 --- a/media/java/android/media/MediaRouter.java +++ b/media/java/android/media/MediaRouter.java @@ -126,6 +126,15 @@ public class MediaRouter { sStatic.mDefaultAudio.mNameResId = name; dispatchRouteChanged(sStatic.mDefaultAudio); } + + boolean a2dpEnabled; + try { + a2dpEnabled = mAudioService.isBluetoothA2dpOn(); + } catch (RemoteException e) { + Log.e(TAG, "Error querying Bluetooth A2DP state", e); + a2dpEnabled = false; + } + if (!TextUtils.equals(newRoutes.mBluetoothName, mCurRoutesInfo.mBluetoothName)) { mCurRoutesInfo.mBluetoothName = newRoutes.mBluetoothName; if (mCurRoutesInfo.mBluetoothName != null) { @@ -135,13 +144,6 @@ public class MediaRouter { info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO; sStatic.mBluetoothA2dpRoute = info; addRoute(sStatic.mBluetoothA2dpRoute); - try { - if (mAudioService.isBluetoothA2dpOn()) { - selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute); - } - } catch (RemoteException e) { - Log.e(TAG, "Error selecting Bluetooth A2DP route", e); - } } else { sStatic.mBluetoothA2dpRoute.mName = mCurRoutesInfo.mBluetoothName; dispatchRouteChanged(sStatic.mBluetoothA2dpRoute); @@ -151,6 +153,16 @@ public class MediaRouter { sStatic.mBluetoothA2dpRoute = null; } } + + if (mBluetoothA2dpRoute != null) { + if (mCurRoutesInfo.mMainType != AudioRoutesInfo.MAIN_SPEAKER && + mSelectedRoute == mBluetoothA2dpRoute) { + selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mDefaultAudio); + } else if (mCurRoutesInfo.mMainType == AudioRoutesInfo.MAIN_SPEAKER && + mSelectedRoute == mDefaultAudio && a2dpEnabled) { + selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute); + } + } } } |