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

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

Playback resume after call

Under normal circumstances music is paused automatically when placing a
call, when there are multiple phones involved it is sometimes necessary
to pause the music on phones not making a call.  When audio is resumed
there needs to be sufficient time for all devices to register that the
call has ended before music can resume.

Bug: 73133707
Test: runtest bluetooth -p com.android.bluetooth.hfpclient and manual
testing

(cherry picked from commit 13405d11e19b9d636ea7613121b041d33638c6c0)

Change-Id: I93c5eb9786664b1251dc7c4d2d846d33eb58e72c
parent 6bc6e6c5
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public class A2dpSinkStreamHandler extends Handler {

    // Configuration Variables
    private static final int DEFAULT_DUCK_PERCENT = 25;
    private static final int SETTLE_TIMEOUT = 1000;

    // Incoming events.
    public static final int SRC_STR_START = 0; // Audio stream from remote device started
@@ -67,6 +68,7 @@ public class A2dpSinkStreamHandler extends Handler {
    public static final int DISCONNECT = 6; // Remote device was disconnected
    public static final int AUDIO_FOCUS_CHANGE = 7; // Audio focus callback with associated change
    public static final int REQUEST_FOCUS = 8; // Request focus when the media service is active
    public static final int DELAYED_RESUME = 9; // If a call just ended allow stack time to settle

    // Used to indicate focus lost
    private static final int STATE_FOCUS_LOST = 0;
@@ -180,8 +182,7 @@ public class A2dpSinkStreamHandler extends Handler {
                        startAvrcpUpdates();
                        startFluorideStreaming();
                        if (mSentPause) {
                            sendAvrcpPlay();
                            mSentPause = false;
                            sendMessageDelayed(obtainMessage(DELAYED_RESUME), SETTLE_TIMEOUT);
                        }
                        break;

@@ -219,6 +220,13 @@ public class A2dpSinkStreamHandler extends Handler {
                }
                break;

            case DELAYED_RESUME:
                // Resume playback after source and sink states settle.
                sendAvrcpPlay();
                mSentPause = false;
                break;


            default:
                Log.w(TAG, "Received unexpected event: " + message.what);
        }