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

Commit 02d8e527 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I3423fcf6,If595d89f,I586b6c06

* changes:
  Fixes for HFP & AVRCP
  Support Rewind and FF transport controls
   AVRCP CT: Add support to send stop command
parents ba2dd408 f9ce056b
Loading
Loading
Loading
Loading
+34 −15
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ public class A2dpMediaBrowserService extends MediaBrowserService {
    // Message sent when folder list is fetched.
    private static final int MSG_FOLDER_LIST = 9;

    // Custom actions for PTS testing.
    private String CUSTOM_ACTION_VOL_UP = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_UP";
    private String CUSTOM_ACTION_VOL_DN = "com.android.bluetooth.a2dpsink.mbs.CUSTOM_ACTION_VOL_DN";

    private MediaSession mSession;
    private MediaMetadata mA2dpMetadata;

@@ -248,30 +252,28 @@ public class A2dpMediaBrowserService extends MediaBrowserService {
            // TRACK_EVENT should be fired eventually and the UI should be hence updated.
        }

        // These are not yet supported.
        @Override
        public void onStop() {
            Log.d(TAG, "onStop");
            mAvrcpCommandQueue.obtainMessage(
                    MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_STOP)
                    .sendToTarget();
        }

        @Override
        public void onCustomAction(String action, Bundle extras) {
            Log.d(TAG, "onCustomAction action=" + action + " extras=" + extras);
        }

        @Override
        public void onPlayFromSearch(String query, Bundle extras) {
            Log.d(TAG, "playFromSearch not supported in AVRCP");
        }

        @Override
        public void onCommand(String command, Bundle args, ResultReceiver cb) {
            Log.d(TAG, "onCommand command=" + command + " args=" + args);
        public void onRewind() {
            Log.d(TAG, "onRewind");
            mAvrcpCommandQueue.obtainMessage(
                MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_REWIND).sendToTarget();
            // TRACK_EVENT should be fired eventually and the UI should be hence updated.
        }

        @Override
        public void onSkipToQueueItem(long queueId) {
            Log.d(TAG, "onSkipToQueueItem");
        public void onFastForward() {
            Log.d(TAG, "onFastForward");
            mAvrcpCommandQueue.obtainMessage(
                MSG_AVRCP_PASSTHRU, AvrcpControllerService.PASS_THRU_CMD_ID_FF).sendToTarget();
            // TRACK_EVENT should be fired eventually and the UI should be hence updated.
        }

        @Override
@@ -286,6 +288,23 @@ public class A2dpMediaBrowserService extends MediaBrowserService {

            // TRACK_EVENT should be fired eventually and the UI should be hence updated.
        }

        // Support VOL UP and VOL DOWN events for PTS testing.
        @Override
        public void onCustomAction(String action, Bundle extras) {
            Log.d(TAG, "onCustomAction " + action);
            if (CUSTOM_ACTION_VOL_UP.equals(action)) {
                mAvrcpCommandQueue.obtainMessage(
                    MSG_AVRCP_PASSTHRU,
                    AvrcpControllerService.PASS_THRU_CMD_ID_VOL_UP).sendToTarget();
            } else if (CUSTOM_ACTION_VOL_DN.equals(action)) {
                mAvrcpCommandQueue.obtainMessage(
                    MSG_AVRCP_PASSTHRU,
                    AvrcpControllerService.PASS_THRU_CMD_ID_VOL_DOWN).sendToTarget();
            } else {
                Log.w(TAG, "Custom action " + action + " not supported.");
            }
        }
    };

    private BroadcastReceiver mBtReceiver = new BroadcastReceiver() {
+9 −14
Original line number Diff line number Diff line
@@ -424,15 +424,21 @@ final class HeadsetClientStateMachine extends StateMachine {
                callRetainedIds.add(hfOriginatedAssoc);
            } else if (SystemClock.elapsedRealtime() - cCreationElapsed > OUTGOING_TIMEOUT_MILLI) {
                Log.w(TAG, "Outgoing call did not see a response, clear the calls and send CHUP");
                // We send a terminate because we are in a bad state and trying to
                // recover.
                terminateCall();

                // Clean out the state.
                // Clean out the state for outgoing call.
                for (Integer idx : mCalls.keySet()) {
                    BluetoothHeadsetClientCall c1 = mCalls.get(idx);
                    c1.setState(BluetoothHeadsetClientCall.CALL_STATE_TERMINATED);
                    sendCallChangedIntent(c);
                    sendCallChangedIntent(c1);
                }
                mCalls.clear();

                // We return here, if there's any update to the phone we should get a
                // follow up by getting some call indicators and hence update the calls.
                return;
            }
        }

@@ -491,18 +497,7 @@ final class HeadsetClientStateMachine extends StateMachine {
        if (DBG) {
            Log.d(TAG, "loopQueryCalls, starting call query loop");
        }
        if (mCalls.size() > 0) {
            return true;
        }

        // Workaround for Windows Phone 7.8 not sending callsetup=0 after
        // rejecting incoming call in 3WC use case (when no active calls present).
        // Fixes both, AG and HF rejecting the call.
        BluetoothHeadsetClientCall c = getCall(BluetoothHeadsetClientCall.CALL_STATE_INCOMING);
        if (c != null && mIndicatorCallSetup == HeadsetClientHalConstants.CALLSETUP_NONE)
            return true;

        return false;
        return (mCalls.size() > 0);
    }

    private void acceptCall(int flag, boolean retry) {