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

Commit d38c7580 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

Change-Id: Iaffd3f91e63a243e35c68e553fcb8dff65a701a0
(cherry picked from commit dfb8c660310054983b12784a91edb2099798e656)
parent 9cd49760
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -56,6 +56,7 @@ public class A2dpSinkStreamHandler extends Handler {


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


    // Incoming events.
    // Incoming events.
    public static final int SRC_STR_START = 0; // Audio stream from remote device started
    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 DISCONNECT = 6; // Remote device was disconnected
    public static final int AUDIO_FOCUS_CHANGE = 7; // Audio focus callback with associated change
    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 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
    // Used to indicate focus lost
    private static final int STATE_FOCUS_LOST = 0;
    private static final int STATE_FOCUS_LOST = 0;
@@ -180,8 +182,7 @@ public class A2dpSinkStreamHandler extends Handler {
                        startAvrcpUpdates();
                        startAvrcpUpdates();
                        startFluorideStreaming();
                        startFluorideStreaming();
                        if (mSentPause) {
                        if (mSentPause) {
                            sendAvrcpPlay();
                            sendMessageDelayed(obtainMessage(DELAYED_RESUME), SETTLE_TIMEOUT);
                            mSentPause = false;
                        }
                        }
                        break;
                        break;


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


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


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