Fix MediaRouter prioritization around a2dp devices
Most recently connected audio output gets priority. Wifi display will
dominate over everything.
Bug 7324334
Change-Id: I29b59570a2e9b5352be436dc5b7a0a6861dfae6b
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index 16ad74f..8e9384ee 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -152,6 +152,8 @@
dispatchRouteChanged(sStatic.mDefaultAudioVideo);
}
+ final int mainType = mCurAudioRoutesInfo.mMainType;
+
boolean a2dpEnabled;
try {
a2dpEnabled = mAudioService.isBluetoothA2dpOn();
@@ -180,11 +182,10 @@
}
if (mBluetoothA2dpRoute != null) {
- if (mCurAudioRoutesInfo.mMainType != AudioRoutesInfo.MAIN_SPEAKER &&
- mSelectedRoute == mBluetoothA2dpRoute) {
+ if (mainType != AudioRoutesInfo.MAIN_SPEAKER &&
+ mSelectedRoute == mBluetoothA2dpRoute && !a2dpEnabled) {
selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mDefaultAudioVideo);
- } else if (mCurAudioRoutesInfo.mMainType == AudioRoutesInfo.MAIN_SPEAKER &&
- (mSelectedRoute == mDefaultAudioVideo || mSelectedRoute == null) &&
+ } else if ((mSelectedRoute == mDefaultAudioVideo || mSelectedRoute == null) &&
a2dpEnabled) {
selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute);
}