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

Commit 7e4fbc04 authored by Marie Janssen's avatar Marie Janssen Committed by android-build-merger
Browse files

Merge "AVRCP: don't remove inactive media controllers"

am: 067a7d83

Change-Id: I0bff2cab09993d3ff80857771574f129392fb4b2
parents 1d797773 067a7d83
Loading
Loading
Loading
Loading
+9 −23
Original line number Diff line number Diff line
@@ -946,23 +946,20 @@ public final class Avrcp {

    private void updateCurrentMediaState() {
        MediaAttributes currentAttributes = mMediaAttributes;
        PlaybackState newState = mCurrentPlayState;
        PlaybackState newState = null;
        if (mMediaController == null) {
            // Use A2DP state if we don't have a MediaControlller
            boolean isPlaying =
                    (mA2dpState == BluetoothA2dp.STATE_PLAYING) && mAudioManager.isMusicActive();
            if (isPlaying != isPlayingState(mCurrentPlayState)) {
                /* if a2dp is streaming, check to make sure music is active */
            PlaybackState.Builder builder = new PlaybackState.Builder();
            if (isPlaying) {
                    builder.setState(PlaybackState.STATE_PLAYING,
                            PlaybackState.PLAYBACK_POSITION_UNKNOWN, 1.0f);
                builder.setState(
                        PlaybackState.STATE_PLAYING, PlaybackState.PLAYBACK_POSITION_UNKNOWN, 1.0f);
            } else {
                    builder.setState(PlaybackState.STATE_PAUSED,
                            PlaybackState.PLAYBACK_POSITION_UNKNOWN, 0.0f);
                builder.setState(
                        PlaybackState.STATE_PAUSED, PlaybackState.PLAYBACK_POSITION_UNKNOWN, 0.0f);
            }
            newState = builder.build();
            }
            mMediaAttributes = new MediaAttributes(null);
        } else {
            newState = mMediaController.getPlaybackState();
@@ -1570,17 +1567,6 @@ public final class Avrcp {
                        playersChanged = true;
                    }

                    List<android.media.session.MediaController> currentControllers =
                            getMediaControllers();
                    for (android.media.session.MediaController controller : currentControllers) {
                        if (!newControllers.contains(controller)) {
                            if (DEBUG)
                                Log.v(TAG, "Removing gone controller for "
                                                + controller.getPackageName());
                            removeMediaController(controller);
                        }
                    }

                    if (playersChanged) {
                        mHandler.sendEmptyMessage(MSG_AVAILABLE_PLAYERS_CHANGED_RSP);
                        if (newControllers.size() > 0 && getAddressedPlayerInfo() == null) {