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

Commit cd685e56 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Issue: turning on bluetooth headset in call doesn't change route (1/2).

Forcing queryPhoneState to send CallState to connected bluetooth headset.
The method updateHeadsetWithCallState, which queryPhoneState calls, checks
to see if any state information has changed, and then updates the headset
with the new state information.  In HeadsetStateMachine, there are calls
to queryPhoneState made when the headset is connected.  In response to the
change in call state, the headset will automatically connect or not.
However, since updateHeadsetWithCallState was not detecting a change in
the call state, the update was never sent to HeadsetStateMachine, which
meant that it would never attempt to turn on the audio for the headset.

Bug: 17933664
Change-Id: I9270a20e2d227d90f5401e0f237a908b192fc174
parent d9bae25a
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ public final class BluetoothPhoneService extends Service {

                case MSG_QUERY_PHONE_STATE:
                    try {
                        updateHeadsetWithCallState();
                        updateHeadsetWithCallState(true /* force */);
                    } finally {
                        if (request != null) {
                            request.setResult(true);
@@ -317,28 +317,28 @@ public final class BluetoothPhoneService extends Service {
    private CallsManagerListener mCallsManagerListener = new CallsManagerListenerBase() {
        @Override
        public void onCallAdded(Call call) {
            updateHeadsetWithCallState();
            updateHeadsetWithCallState(false /* force */);
        }

        @Override
        public void onCallRemoved(Call call) {
            mClccIndexMap.remove(call);
            updateHeadsetWithCallState();
            updateHeadsetWithCallState(false /* force */);
        }

        @Override
        public void onCallStateChanged(Call call, int oldState, int newState) {
            updateHeadsetWithCallState();
            updateHeadsetWithCallState(false /* force */);
        }

        @Override
        public void onForegroundCallChanged(Call oldForegroundCall, Call newForegroundCall) {
            updateHeadsetWithCallState();
            updateHeadsetWithCallState(false /* force */);
        }

        @Override
        public void onIsConferencedChanged(Call call) {
            updateHeadsetWithCallState();
            updateHeadsetWithCallState(false /* force */);
        }
    };

@@ -412,7 +412,7 @@ public final class BluetoothPhoneService extends Service {
        registerReceiver(mBluetoothAdapterReceiver, intentFilter);

        CallsManager.getInstance().addListener(mCallsManagerListener);
        updateHeadsetWithCallState();
        updateHeadsetWithCallState(false /* force */);
    }

    @Override
@@ -609,7 +609,14 @@ public final class BluetoothPhoneService extends Service {
        return i;
    }

    private void updateHeadsetWithCallState() {
    /**
     * Sends an update of the current call state to the current Headset.
     *
     * @param force {@code true} if the headset state should be sent regardless if no changes to the
     *      state have occurred, {@code false} if the state should only be sent if the state has
     *      changed.
     */
    private void updateHeadsetWithCallState(boolean force) {
        CallsManager callsManager = getCallsManager();
        Call activeCall = callsManager.getActiveCall();
        Call ringingCall = callsManager.getRingingCall();
@@ -650,7 +657,8 @@ public final class BluetoothPhoneService extends Service {
                 numHeldCalls != mNumHeldCalls ||
                 bluetoothCallState != mBluetoothCallState ||
                 !TextUtils.equals(ringingAddress, mRingingAddress) ||
                 ringingAddressType != mRingingAddressType)) {
                 ringingAddressType != mRingingAddressType ||
                 force)) {

            // If the call is transitioning into the alerting state, send DIALING first.
            // Some devices expect to see a DIALING state prior to seeing an ALERTING state