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

Commit 2977b43a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/30942393'] into 25Q1-release.

Change-Id: I040d4bb1ddd92468c5c811c3c4cf1357adb08498
parents 009fd3b6 38b952f2
Loading
Loading
Loading
Loading
+37 −27
Original line number Diff line number Diff line
@@ -978,13 +978,17 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
     * @return {@link AudioRoute} of the BT device.
     */
    private AudioRoute getArbitraryBluetoothDevice() {
        synchronized (mLock) {
            if (mActiveBluetoothDevice != null) {
            return getBluetoothRoute(mActiveBluetoothDevice.first, mActiveBluetoothDevice.second);
                return getBluetoothRoute(
                    mActiveBluetoothDevice.first, mActiveBluetoothDevice.second);
            } else if (!mBluetoothRoutes.isEmpty()) {
            return mBluetoothRoutes.keySet().stream().toList().get(mBluetoothRoutes.size() - 1);
                return mBluetoothRoutes.keySet().stream().toList()
                    .get(mBluetoothRoutes.size() - 1);
            }
            return null;
        }
    }

    private void handleSwitchHeadset() {
        AudioRoute headsetRoute = mTypeRoutes.get(AudioRoute.TYPE_WIRED);
@@ -1450,8 +1454,11 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                continue;
            }
            // Check if the most recently active device is a watch device.
            boolean isActiveDevice = mActiveBluetoothDevice != null
            boolean isActiveDevice;
            synchronized (mLock) {
                isActiveDevice = mActiveBluetoothDevice != null
                    && device.getAddress().equals(mActiveBluetoothDevice.second);
            }
            if (i == (bluetoothRoutes.size() - 1) && mBluetoothRouteManager.isWatch(device)
                    && (device.equals(mCallAudioState.getActiveBluetoothDevice())
                    || isActiveDevice)) {
@@ -1565,16 +1572,18 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
     *                           address of the device.
     */
    public void updateActiveBluetoothDevice(Pair<Integer, String> device) {
        synchronized (mLock) {
            mActiveDeviceCache.put(device.first, device.second);
        // Update most recently active device if address isn't null (meaning some device is active).
            // Update most recently active device if address isn't null (meaning
            // some device is active).
            if (device.second != null) {
                mActiveBluetoothDevice = device;
            } else {
            // If a device was removed, check to ensure that no other device is still considered
            // active.
                // If a device was removed, check to ensure that no other device is
                //still considered active.
                boolean hasActiveDevice = false;
            List<Map.Entry<Integer, String>> activeBtDevices = new ArrayList<>(
                    mActiveDeviceCache.entrySet());
                List<Map.Entry<Integer, String>> activeBtDevices =
                        new ArrayList<>(mActiveDeviceCache.entrySet());
                for (Map.Entry<Integer, String> activeDevice : activeBtDevices) {
                    Integer btAudioType = activeDevice.getKey();
                    String address = activeDevice.getValue();
@@ -1591,6 +1600,7 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                }
            }
        }
    }

    private void updateAvailableRoutes(AudioRoute route, boolean includeRoute) {
        if (includeRoute) {