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

Commit 9ccb9ff3 authored by Joseph Pirozzo's avatar Joseph Pirozzo
Browse files

DO NOT MERGE: Revert "AVRCP Controller transient loss while idle"

This revert is reapplied after a few CLs to match change order to AOSP.

Bug: 136092891


This reverts commit 1812aafd.
parent c4d9f202
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@ import android.media.AudioFocusRequest;
import android.media.AudioManager;
import android.media.AudioManager.OnAudioFocusChangeListener;
import android.media.MediaPlayer;
import android.media.session.PlaybackState;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
@@ -227,8 +225,7 @@ public class A2dpSinkStreamHandler extends Handler {
                break;

            case DELAYED_PAUSE:
                if (BluetoothMediaBrowserService.getPlaybackState()
                            == PlaybackState.STATE_PLAYING && !inCallFromStreamingDevice()) {
                if (mStreamAvailable && !inCallFromStreamingDevice()) {
                    sendAvrcpPause();
                    mSentPause = true;
                    mStreamAvailable = false;
+0 −14
Original line number Diff line number Diff line
@@ -176,20 +176,6 @@ public class BluetoothMediaBrowserService extends MediaBrowserService {
        }
    }

    /**
     * Get playback state
     */
    public static synchronized int getPlaybackState() {
        if (sBluetoothMediaBrowserService != null) {
            PlaybackState currentPlaybackState =
                    sBluetoothMediaBrowserService.mSession.getController().getPlaybackState();
            if (currentPlaybackState != null) {
                return currentPlaybackState.getState();
            }
        }
        return PlaybackState.STATE_ERROR;
    }

    /**
     * Get object for controlling playback
     */
+0 −18
Original line number Diff line number Diff line
@@ -194,24 +194,6 @@ public class A2dpSinkStreamHandlerTest {
        verify(mMockA2dpSink, times(1)).informAudioTrackGainNative(0);
    }

    @Test
    public void testFocusGainTransient() {
        // Focus was lost then regained.
        testSnkPlay();
        mStreamHandler.handleMessage(
                mStreamHandler.obtainMessage(A2dpSinkStreamHandler.AUDIO_FOCUS_CHANGE,
                        AudioManager.AUDIOFOCUS_LOSS_TRANSIENT));
        mStreamHandler.handleMessage(
                mStreamHandler.obtainMessage(A2dpSinkStreamHandler.DELAYED_PAUSE));
        mStreamHandler.handleMessage(
                mStreamHandler.obtainMessage(A2dpSinkStreamHandler.AUDIO_FOCUS_CHANGE,
                        AudioManager.AUDIOFOCUS_GAIN));
        verify(mMockAudioManager, times(0)).abandonAudioFocus(any());
        verify(mMockA2dpSink, times(0)).informAudioFocusStateNative(0);
        verify(mMockA2dpSink, times(1)).informAudioTrackGainNative(0);
        verify(mMockA2dpSink, times(2)).informAudioTrackGainNative(1.0f);
    }

    @Test
    public void testFocusLost() {
        // Focus was lost permanently, expect streaming to stop.