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

Commit fe88e985 authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Prioritize focus switch messages

It was seen in one scenario that once the disconnect tone finishes
playing and causes the BT ICS to unbind that it took time for the
unfocus switch request to be processed by the audio routing
controller. BT stack notifies us that SCO audio is disconnected and it
causes a bunch of active device request switches between BT devices
since the connection requests will inevitably end up failing. Those
active device switches ended up being processed first over the switch
focus request even though they were queued up after. This small fix
ensures that the focus switch request is queued up to the front of the
message queue so that the message can be processed at a much earlier
time.

Bug: 411472311
Flag: EXEMPT bug fix
Test: Manual basic verification to verify no regression
Test: atest CallAudioRouteControllerTest
Change-Id: I8f259317ee908a439f924dd80fc1a76bd00a13d6
parent 2d16482b
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -585,14 +585,19 @@ public class CallAudioManager extends CallsManagerListenerBase {

    @VisibleForTesting
    public void setCallAudioRouteFocusState(int focusState) {
        if (focusState == CallAudioRouteController.NO_FOCUS) {
            mCallAudioRouteAdapter.sendMessageWithSessionInfoAtFront(
                    CallAudioRouteController.SWITCH_FOCUS, focusState, 0);
        } else {
            mCallAudioRouteAdapter.sendMessageWithSessionInfo(
                CallAudioRouteStateMachine.SWITCH_FOCUS, focusState, 0);
                    CallAudioRouteController.SWITCH_FOCUS, focusState, 0);
        }
    }

    public void setCallAudioRouteFocusStateForEndTone() {
        mCallAudioRouteAdapter.sendMessageWithSessionInfo(
                CallAudioRouteStateMachine.SWITCH_FOCUS,
                CallAudioRouteStateMachine.ACTIVE_FOCUS, 1);
        mCallAudioRouteAdapter.sendMessageWithSessionInfoAtFront(
                CallAudioRouteController.SWITCH_FOCUS,
                CallAudioRouteController.ACTIVE_FOCUS, 1);
    }

    public void notifyAudioOperationsComplete() {
+1 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ public interface CallAudioRouteAdapter {
    void sendMessageWithSessionInfo(int message, int arg);
    void sendMessageWithSessionInfo(int message, int arg, String data);
    void sendMessageWithSessionInfo(int message, int arg, int data);
    void sendMessageWithSessionInfoAtFront(int message, int arg, int data);
    void sendMessageWithSessionInfo(int message, int arg, BluetoothDevice bluetoothDevice);
    void sendMessage(int message, Runnable r);
    void setCallAudioManager(CallAudioManager callAudioManager);
+8 −0
Original line number Diff line number Diff line
@@ -546,6 +546,14 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
        sendMessage(message, arg, 0, args);
    }

    @Override
    public void sendMessageWithSessionInfoAtFront(int message, int arg, int data) {
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = Log.createSubsession();
        args.arg2 = data;
        mHandler.sendMessageAtFrontOfQueue(Message.obtain(mHandler, message, arg, 0, args));
    }

    @Override
    public void sendMessageWithSessionInfo(int message, int arg, BluetoothDevice bluetoothDevice) {
        SomeArgs args = SomeArgs.obtain();
+5 −0
Original line number Diff line number Diff line
@@ -1642,6 +1642,11 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
        // ignore, only used in CallAudioRouteController
    }

    @Override
    public void sendMessageWithSessionInfoAtFront(int message, int arg, int data) {
        // ignore, only used in CallAudioRouteController
    }

    public void sendMessageWithSessionInfo(int message, int arg, BluetoothDevice bluetoothDevice) {
        // ignore, only used in CallAudioRouteController
    }