Skip to content

Commit 5bb835a

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "MediaRouter bluetooth a2dp selection" into jb-dev
2 parents badf5a9 + dd0a192 commit 5bb835a

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

media/java/android/media/AudioService.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,9 +1660,6 @@ public boolean isBluetoothScoOn() {
16601660

16611661
/** @see AudioManager#setBluetoothA2dpOn() */
16621662
public void setBluetoothA2dpOn(boolean on) {
1663-
if (!checkAudioSettingsPermission("setBluetoothA2dpOn()")) {
1664-
return;
1665-
}
16661663
setBluetoothA2dpOnInt(on);
16671664
}
16681665

media/java/android/media/MediaRouter.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ public void dispatchAudioRoutesChanged(final AudioRoutesInfo newRoutes) {
8181
IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE);
8282
mAudioService = IAudioService.Stub.asInterface(b);
8383

84-
// XXX this doesn't deal with locale changes!
85-
mSystemCategory = new RouteCategory(mResources.getText(
86-
com.android.internal.R.string.default_audio_route_category_name),
84+
mSystemCategory = new RouteCategory(
85+
com.android.internal.R.string.default_audio_route_category_name,
8786
ROUTE_TYPE_LIVE_AUDIO, false);
8887
}
8988

@@ -130,6 +129,13 @@ void updateRoutes(AudioRoutesInfo newRoutes) {
130129
info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO;
131130
sStatic.mBluetoothA2dpRoute = info;
132131
addRoute(sStatic.mBluetoothA2dpRoute);
132+
try {
133+
if (mAudioService.isBluetoothA2dpOn()) {
134+
selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute);
135+
}
136+
} catch (RemoteException e) {
137+
Log.e(TAG, "Error selecting Bluetooth A2DP route", e);
138+
}
133139
} else {
134140
sStatic.mBluetoothA2dpRoute.mName = mCurRoutesInfo.mBluetoothName;
135141
dispatchRouteChanged(sStatic.mBluetoothA2dpRoute);
@@ -279,6 +285,16 @@ static void selectRouteStatic(int types, RouteInfo route) {
279285
return;
280286
}
281287

288+
final RouteInfo btRoute = sStatic.mBluetoothA2dpRoute;
289+
if (btRoute != null && (types & ROUTE_TYPE_LIVE_AUDIO) != 0 &&
290+
(route == btRoute || route == sStatic.mDefaultAudio)) {
291+
try {
292+
sStatic.mAudioService.setBluetoothA2dpOn(route == btRoute);
293+
} catch (RemoteException e) {
294+
Log.e(TAG, "Error changing Bluetooth A2DP state", e);
295+
}
296+
}
297+
282298
if (sStatic.mSelectedRoute != null) {
283299
// TODO filter types properly
284300
dispatchRouteUnselected(types & sStatic.mSelectedRoute.getSupportedTypes(),

0 commit comments

Comments
 (0)