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

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

Merge "Resolve fallback audio routing for SCO disconnect" into main

parents ff2fc427 efa615f9
Loading
Loading
Loading
Loading
+2 −15
Original line number Diff line number Diff line
@@ -533,14 +533,6 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                mIsScoAudioConnected);
        mIsActive = active;
        mPendingAudioRoute.evaluatePendingState();
        postTimeoutMessage();
    }

    private void postTimeoutMessage() {
        // reset timeout handler
        mHandler.removeMessages(PENDING_ROUTE_TIMEOUT);
        mHandler.postDelayed(() -> mHandler.sendMessage(
                Message.obtain(mHandler, PENDING_ROUTE_TIMEOUT)), TIMEOUT_LIMIT);
    }

    private void handleWiredHeadsetConnected() {
@@ -657,9 +649,6 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                mPendingAudioRoute.onMessageReceived(new Pair<>(BT_AUDIO_CONNECTED,
                        bluetoothDevice.getAddress()), null);
            }
        } else {
            // ignore, not triggered by telecom
            Log.i(this, "handleBtAudioActive: ignoring handling bt audio active.");
        }
    }

@@ -679,9 +668,6 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                mPendingAudioRoute.onMessageReceived(new Pair<>(BT_AUDIO_DISCONNECTED,
                        bluetoothDevice.getAddress()), null);
            }
        } else {
            // ignore, not triggered by telecom
            Log.i(this, "handleBtAudioInactive: ignoring handling bt audio inactive.");
        }
    }

@@ -1227,7 +1213,8 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {

    public AudioRoute getBaseRoute(boolean includeBluetooth, String btAddressToExclude) {
        AudioRoute destRoute = getPreferredAudioRouteFromStrategy();
        if (destRoute == null || (destRoute.getBluetoothAddress() != null && !includeBluetooth)) {
        if (destRoute == null || (destRoute.getBluetoothAddress() != null && (!includeBluetooth
                || destRoute.getBluetoothAddress().equals(btAddressToExclude)))) {
            destRoute = getPreferredAudioRouteFromDefault(includeBluetooth, btAddressToExclude);
        }
        if (destRoute != null && !getCallSupportedRoutes().contains(destRoute)) {
+15 −2
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import static com.android.server.telecom.CallAudioRouteAdapter.BT_AUDIO_DISCONNE
import static com.android.server.telecom.CallAudioRouteAdapter.BT_DEVICE_ADDED;
import static com.android.server.telecom.CallAudioRouteAdapter.BT_DEVICE_REMOVED;
import static com.android.server.telecom.CallAudioRouteAdapter.PENDING_ROUTE_FAILED;
import static com.android.server.telecom.CallAudioRouteAdapter.SWITCH_BASELINE_ROUTE;
import static com.android.server.telecom.CallAudioRouteController.INCLUDE_BLUETOOTH_IN_BASELINE;
import static com.android.server.telecom.bluetooth.BluetoothRouteManager.BT_AUDIO_IS_ON;
import static com.android.server.telecom.bluetooth.BluetoothRouteManager.BT_AUDIO_LOST;

@@ -153,8 +155,19 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
                    CallAudioRouteController audioRouteController =
                            (CallAudioRouteController) mCallAudioRouteAdapter;
                    audioRouteController.setIsScoAudioConnected(false);
                    if (audioRouteController.isPending()) {
                        mCallAudioRouteAdapter.sendMessageWithSessionInfo(BT_AUDIO_DISCONNECTED, 0,
                                device);
                    } else {
                        // Handle case where BT stack signals SCO disconnected but Telecom isn't
                        // processing any pending routes. This explicitly addresses cf instances
                        // where a remote device disconnects SCO. Telecom should ensure that audio
                        // is properly routed in the UI.
                        audioRouteController.getPendingAudioRoute()
                                .setCommunicationDeviceType(AudioRoute.TYPE_INVALID);
                        mCallAudioRouteAdapter.sendMessageWithSessionInfo(SWITCH_BASELINE_ROUTE,
                                INCLUDE_BLUETOOTH_IN_BASELINE, device.getAddress());
                    }
                }  else {
                    mBluetoothRouteManager.sendMessage(BT_AUDIO_LOST, args);
                }