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

Commit 7b08a352 authored by Pranav Madapurmath's avatar Pranav Madapurmath Committed by Android (Google) Code Review
Browse files

Merge "Resolve call audio refactor test failures" into main

parents 0195ba52 f82b5bef
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -576,9 +576,26 @@ public class CallAudioManager extends CallsManagerListenerBase {

    @VisibleForTesting
    public void setCallAudioRouteFocusState(int focusState) {
        if (mFeatureFlags.useRefactoredAudioRouteSwitching()) {
            mCallAudioRouteAdapter.sendMessageWithSessionInfo(
                    CallAudioRouteStateMachine.SWITCH_FOCUS, focusState, 0);
        } else {
            mCallAudioRouteAdapter.sendMessageWithSessionInfo(
                    CallAudioRouteStateMachine.SWITCH_FOCUS, focusState);
        }
    }

    public void setCallAudioRouteFocusStateForEndTone() {
        if (mFeatureFlags.useRefactoredAudioRouteSwitching()) {
            mCallAudioRouteAdapter.sendMessageWithSessionInfo(
                    CallAudioRouteStateMachine.SWITCH_FOCUS,
                    CallAudioRouteStateMachine.ACTIVE_FOCUS, 1);
        } else {
            mCallAudioRouteAdapter.sendMessageWithSessionInfo(
                    CallAudioRouteStateMachine.SWITCH_FOCUS,
                    CallAudioRouteStateMachine.ACTIVE_FOCUS);
        }
    }

    public void notifyAudioOperationsComplete() {
        mCallAudioModeStateMachine.sendMessageWithArgs(
+1 −1
Original line number Diff line number Diff line
@@ -824,7 +824,7 @@ public class CallAudioModeStateMachine extends StateMachine {
            }
            mAudioManager.setMode(mMostRecentMode);
            mLocalLog.log("Mode " + mMostRecentMode);
            mCallAudioManager.setCallAudioRouteFocusState(CallAudioRouteStateMachine.ACTIVE_FOCUS);
            mCallAudioManager.setCallAudioRouteFocusStateForEndTone();
        }

        @Override
+1 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ public interface CallAudioRouteAdapter {
    void sendMessageWithSessionInfo(int message);
    void sendMessageWithSessionInfo(int message, int arg);
    void sendMessageWithSessionInfo(int message, int arg, String data);
    void sendMessageWithSessionInfo(int message, int arg, int data);
    void sendMessageWithSessionInfo(int message, int arg, BluetoothDevice bluetoothDevice);
    void sendMessage(int message, Runnable r);
    void setCallAudioManager(CallAudioManager callAudioManager);
+24 −4
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                    String address;
                    BluetoothDevice bluetoothDevice;
                    int focus;
                    int handleEndTone;
                    @AudioRoute.AudioRouteType int type;
                    switch (msg.what) {
                        case CONNECT_WIRED_HEADSET:
@@ -305,11 +306,18 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                            break;
                        case SWITCH_FOCUS:
                            focus = msg.arg1;
                            handleSwitchFocus(focus);
                            handleEndTone = (int) ((SomeArgs) msg.obj).arg2;
                            handleSwitchFocus(focus, handleEndTone);
                            break;
                        case EXIT_PENDING_ROUTE:
                            handleExitPendingRoute();
                            break;
                        case UPDATE_SYSTEM_AUDIO_ROUTE:
                            updateCallAudioState(new CallAudioState(mIsMute,
                                    mCallAudioState.getRoute(),
                                    mCallAudioState.getSupportedRouteMask(),
                                    mCallAudioState.getActiveBluetoothDevice(),
                                    mCallAudioState.getSupportedBluetoothDevices()));
                        default:
                            break;
                    }
@@ -397,6 +405,14 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
        sendMessage(message, arg, 0, args);
    }

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

    @Override
    public void sendMessageWithSessionInfo(int message, int arg, BluetoothDevice bluetoothDevice) {
        SomeArgs args = SomeArgs.obtain();
@@ -766,7 +782,7 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
        onMuteStateChanged(mIsMute);
    }

    private void handleSwitchFocus(int focus) {
    private void handleSwitchFocus(int focus, int handleEndTone) {
        Log.i(this, "handleSwitchFocus: focus (%s)", focus);
        mFocusType = focus;
        switch (focus) {
@@ -782,9 +798,13 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
            }
            case ACTIVE_FOCUS -> {
                // Route to active baseline route (we may need to change audio route in the case
                // when a video call is put on hold).
                // when a video call is put on hold). Ignore route changes if we're handling playing
                // the end tone. Otherwise, it's possible that we'll override the route a client has
                // previously requested.
                if (handleEndTone == 0) {
                    routeTo(true, getBaseRoute(true, null));
                }
            }
            case RINGING_FOCUS -> {
                if (!mIsActive) {
                    AudioRoute route = getBaseRoute(true, null);
+4 −0
Original line number Diff line number Diff line
@@ -1685,6 +1685,10 @@ public class CallAudioRouteStateMachine extends StateMachine implements CallAudi
        sendMessage(message, arg, 0, args);
    }

    public void sendMessageWithSessionInfo(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
    }
Loading