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

Commit d6901a83 authored by Joseph Pirozzo's avatar Joseph Pirozzo
Browse files

AVRCP Controller Audio Focus gain behavior

When focus is lost (due to Transient loss) and music was playing we need
to pause the remote device such that we can resume audio at the same
place when focus is gained.  Only do this when we know the state should
be playing rather than just an incoming audio stream.

Bug: 67913930
Test: Play music, generate transient loss
Change-Id: I834fce6ad10d73f7836f4cb916633fd945c6c8b0
parent c284c5d0
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -111,7 +111,6 @@ public class A2dpSinkStreamHandler extends Handler {
        }
        switch (message.what) {
            case SRC_STR_START:
                mStreamAvailable = true;
                // Always request audio focus if on TV.
                if (isTvDevice()) {
                    if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) {
@@ -126,7 +125,6 @@ public class A2dpSinkStreamHandler extends Handler {

            case SRC_STR_STOP:
                // Audio stream has stopped, maintain focus but stop avrcp updates.
                mStreamAvailable = false;
                break;

            case SNK_PLAY:
@@ -137,10 +135,12 @@ public class A2dpSinkStreamHandler extends Handler {
                break;

            case SNK_PAUSE:
                mStreamAvailable = false;
                // Local pause command, maintain focus but stop avrcp updates.
                break;

            case SRC_PLAY:
                mStreamAvailable = true;
                // Remote play command.
                // If is an iot device gain focus and start avrcp updates.
                if (isIotDevice() || isTvDevice()) {
@@ -156,6 +156,7 @@ public class A2dpSinkStreamHandler extends Handler {
                break;

            case SRC_PAUSE:
                mStreamAvailable = false;
                // Remote pause command, stop avrcp updates.
                break;

@@ -202,6 +203,7 @@ public class A2dpSinkStreamHandler extends Handler {
                        if (mStreamAvailable) {
                            sendAvrcpPause();
                            mSentPause = true;
                            mStreamAvailable = false;
                        }
                        stopFluorideStreaming();
                        break;