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

Commit 52e00bae authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-c924aaac-f0a2-4215-8dc4-e314f22460d9-for-git_oc-mr1-release-43...

release-request-c924aaac-f0a2-4215-8dc4-e314f22460d9-for-git_oc-mr1-release-4301796 snap-temp-L23200000097143969

Change-Id: I9e9340c9b7eecea526f4943623b09beb1b08df3a
parents 82dfd2a5 db86aa5b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -408,7 +408,8 @@ public class CallAudioManager extends CallsManagerListenerBase {
                return;
            case CallAudioState.ROUTE_WIRED_OR_EARPIECE:
                mCallAudioRouteStateMachine.sendMessageWithSessionInfo(
                        CallAudioRouteStateMachine.USER_SWITCH_BASELINE_ROUTE);
                        CallAudioRouteStateMachine.USER_SWITCH_BASELINE_ROUTE,
                        CallAudioRouteStateMachine.NO_INCLUDE_BLUETOOTH_IN_BASELINE);
                return;
            default:
                Log.wtf(this, "Invalid route specified: %d", route);
+27 −12
Original line number Diff line number Diff line
@@ -116,6 +116,10 @@ public class CallAudioRouteStateMachine extends StateMachine {
    public static final int ACTIVE_FOCUS = 2;
    public static final int RINGING_FOCUS = 3;

    /** Valid values for the argument for SWITCH_BASELINE_ROUTE */
    public static final int NO_INCLUDE_BLUETOOTH_IN_BASELINE = 0;
    public static final int INCLUDE_BLUETOOTH_IN_BASELINE = 1;

    @VisibleForTesting
    public static final SparseArray<String> AUDIO_ROUTE_TO_LOG_EVENT = new SparseArray<String>() {{
        put(CallAudioState.ROUTE_BLUETOOTH, LogUtils.Events.AUDIO_ROUTE_BT);
@@ -232,10 +236,12 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    removedRoutes |= ROUTE_BLUETOOTH;
                    break;
                case SWITCH_BASELINE_ROUTE:
                    sendInternalMessage(calculateBaselineRouteMessage(false));
                    sendInternalMessage(calculateBaselineRouteMessage(false,
                            msg.arg1 == INCLUDE_BLUETOOTH_IN_BASELINE));
                    return HANDLED;
                case USER_SWITCH_BASELINE_ROUTE:
                    sendInternalMessage(calculateBaselineRouteMessage(true));
                    sendInternalMessage(calculateBaselineRouteMessage(true,
                            msg.arg1 == INCLUDE_BLUETOOTH_IN_BASELINE));
                    return HANDLED;
                case SWITCH_FOCUS:
                    mAudioFocusType = msg.arg1;
@@ -611,7 +617,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    if (mWasOnSpeaker) {
                        sendInternalMessage(SWITCH_SPEAKER);
                    } else {
                        sendInternalMessage(SWITCH_BASELINE_ROUTE);
                        sendInternalMessage(SWITCH_BASELINE_ROUTE, INCLUDE_BLUETOOTH_IN_BASELINE);
                    }
                    return HANDLED;
                case BT_AUDIO_DISCONNECT:
@@ -701,7 +707,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    }
                    return HANDLED;
                case BT_AUDIO_DISCONNECT:
                    sendInternalMessage(SWITCH_BASELINE_ROUTE);
                    sendInternalMessage(SWITCH_BASELINE_ROUTE, NO_INCLUDE_BLUETOOTH_IN_BASELINE);
                    return HANDLED;
                default:
                    return NOT_HANDLED;
@@ -782,7 +788,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    return HANDLED;
                case BT_AUDIO_DISCONNECT:
                    // BT SCO might be connected when in-band ringing is enabled
                    sendInternalMessage(SWITCH_BASELINE_ROUTE);
                    sendInternalMessage(SWITCH_BASELINE_ROUTE, NO_INCLUDE_BLUETOOTH_IN_BASELINE);
                    return HANDLED;
                default:
                    return NOT_HANDLED;
@@ -882,7 +888,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    // in the bluetooth route.
                    return HANDLED;
                case DISCONNECT_BLUETOOTH:
                    sendInternalMessage(SWITCH_BASELINE_ROUTE);
                    sendInternalMessage(SWITCH_BASELINE_ROUTE, NO_INCLUDE_BLUETOOTH_IN_BASELINE);
                    mWasOnSpeaker = false;
                    return HANDLED;
                case DISCONNECT_WIRED_HEADSET:
@@ -1091,7 +1097,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    // Nothing to do here
                    return HANDLED;
                case DISCONNECT_DOCK:
                    sendInternalMessage(SWITCH_BASELINE_ROUTE);
                    sendInternalMessage(SWITCH_BASELINE_ROUTE, INCLUDE_BLUETOOTH_IN_BASELINE);
                    return HANDLED;
               default:
                    return NOT_HANDLED;
@@ -1397,6 +1403,10 @@ public class CallAudioRouteStateMachine extends StateMachine {
    }

    private void sendInternalMessage(int messageCode) {
        sendInternalMessage(messageCode, 0);
    }

    private void sendInternalMessage(int messageCode, int arg1) {
        // Internal messages are messages which the state machine sends to itself in the
        // course of processing externally-sourced messages. We want to send these messages at
        // the front of the queue in order to make actions appear atomic to the user and to
@@ -1411,9 +1421,9 @@ public class CallAudioRouteStateMachine extends StateMachine {
        // 7. State machine handler processes SWITCH_HEADSET.
        Session subsession = Log.createSubsession();
        if(subsession != null) {
            sendMessageAtFrontOfQueue(messageCode, subsession);
            sendMessageAtFrontOfQueue(messageCode, arg1, 0, subsession);
        } else {
            sendMessageAtFrontOfQueue(messageCode);
            sendMessageAtFrontOfQueue(messageCode, arg1);
        }
    }

@@ -1466,7 +1476,8 @@ public class CallAudioRouteStateMachine extends StateMachine {
        return true;
    }

    private int calculateBaselineRouteMessage(boolean isExplicitUserRequest) {
    private int calculateBaselineRouteMessage(boolean isExplicitUserRequest,
            boolean includeBluetooth) {
        boolean isSkipEarpiece = false;
        if (!isExplicitUserRequest) {
            synchronized (mLock) {
@@ -1475,7 +1486,11 @@ public class CallAudioRouteStateMachine extends StateMachine {
                isSkipEarpiece = mCallsManager.hasVideoCall();
            }
        }
        if ((mAvailableRoutes & ROUTE_EARPIECE) != 0 && !isSkipEarpiece) {
        if ((mAvailableRoutes & ROUTE_BLUETOOTH) != 0
                && !mHasUserExplicitlyLeftBluetooth
                && includeBluetooth) {
            return isExplicitUserRequest ? USER_SWITCH_BLUETOOTH : SWITCH_BLUETOOTH;
        } else if ((mAvailableRoutes & ROUTE_EARPIECE) != 0 && !isSkipEarpiece) {
            return isExplicitUserRequest ? USER_SWITCH_EARPIECE : SWITCH_EARPIECE;
        } else if ((mAvailableRoutes & ROUTE_WIRED_HEADSET) != 0) {
            return isExplicitUserRequest ? USER_SWITCH_HEADSET : SWITCH_HEADSET;
@@ -1503,7 +1518,7 @@ public class CallAudioRouteStateMachine extends StateMachine {

        // Move to baseline route in the case the current route is no longer available.
        if ((mAvailableRoutes & currentState.getRoute()) == 0) {
            sendInternalMessage(calculateBaselineRouteMessage(false));
            sendInternalMessage(calculateBaselineRouteMessage(false, true));
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -460,7 +460,7 @@ public class CallAudioRouteStateMachineTest
                NONE, // speakerInteraction
                NONE, // bluetoothInteraction
                CallAudioRouteStateMachine.DISCONNECT_WIRED_HEADSET, // action
                CallAudioState.ROUTE_EARPIECE, // expectedRoute
                CallAudioState.ROUTE_BLUETOOTH, // expectedRoute
                CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH, // expectedAvailable
                true, // doesDeviceSupportEarpiece
                shouldRunWithFocus