summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2012-07-12 14:40:52 -0700
committerAdam Powell <adamp@google.com>2012-07-12 16:53:04 -0700
commitbcf21e913af7252fb1994e07b6cf179321ecd049 (patch)
tree4bab79dca70bab966a560ea67029c77beeaf1dba
parentc03f0a15578223208b48c1d946872d22a233ede4 (diff)
downloadframeworks_base-bcf21e913af7252fb1994e07b6cf179321ecd049.zip
frameworks_base-bcf21e913af7252fb1994e07b6cf179321ecd049.tar.gz
frameworks_base-bcf21e913af7252fb1994e07b6cf179321ecd049.tar.bz2
Properly switch MediaRouter to wired audio over a2dp.
The system gives priority to physically connected headphones/speakers/docks/etc. Reflect this in MediaRouter and associated UI. Bug 6777592 Change-Id: Ibabf3d7512207117e892c99f004443490c3d0612
-rw-r--r--media/java/android/media/MediaRouter.java26
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);
+ }
+ }
}
}