Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bb835a9 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "MediaRouter bluetooth a2dp selection" into jb-dev

parents badf5a94 dd0a1926
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -1660,9 +1660,6 @@ public class AudioService extends IAudioService.Stub implements OnFinished {

    /** @see AudioManager#setBluetoothA2dpOn() */
    public void setBluetoothA2dpOn(boolean on) {
        if (!checkAudioSettingsPermission("setBluetoothA2dpOn()")) {
            return;
        }
        setBluetoothA2dpOnInt(on);
    }

+19 −3
Original line number Diff line number Diff line
@@ -81,9 +81,8 @@ public class MediaRouter {
            IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE);
            mAudioService = IAudioService.Stub.asInterface(b);

            // XXX this doesn't deal with locale changes!
            mSystemCategory = new RouteCategory(mResources.getText(
                    com.android.internal.R.string.default_audio_route_category_name),
            mSystemCategory = new RouteCategory(
                    com.android.internal.R.string.default_audio_route_category_name,
                    ROUTE_TYPE_LIVE_AUDIO, false);
        }

@@ -130,6 +129,13 @@ 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);
@@ -279,6 +285,16 @@ public class MediaRouter {
            return;
        }

        final RouteInfo btRoute = sStatic.mBluetoothA2dpRoute;
        if (btRoute != null && (types & ROUTE_TYPE_LIVE_AUDIO) != 0 &&
                (route == btRoute || route == sStatic.mDefaultAudio)) {
            try {
                sStatic.mAudioService.setBluetoothA2dpOn(route == btRoute);
            } catch (RemoteException e) {
                Log.e(TAG, "Error changing Bluetooth A2DP state", e);
            }
        }

        if (sStatic.mSelectedRoute != null) {
            // TODO filter types properly
            dispatchRouteUnselected(types & sStatic.mSelectedRoute.getSupportedTypes(),