@@ -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