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

Commit 1c131a9c authored by Chung Tang's avatar Chung Tang Committed by Android (Google) Code Review
Browse files

Merge "[OutputSwitcher] Fix routes will show selectable when LE Audio...

Merge "[OutputSwitcher] Fix routes will show selectable when LE Audio broadcasting feature is not supported" into main
parents b706f2d2 0c48cf95
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -813,14 +813,15 @@ import java.util.concurrent.CopyOnWriteArrayList;

    /**
     * Checks if a given route should be displayed as selectable route. This function checks: 1) if
     * max devices for broadcast reached 2) the selected route(s) is a broadcast supported route 3)
     * the target route is a broadcast supported route.
     * LE Audio broadcast is support for the device, 2) if the current selected route is a BLE
     * headset and 3) the target route is a BLE headset.
     *
     * @param targetRoute the route for checking
     * @return true if the target route should be displayed as a selectable route
     */
    private synchronized boolean isRouteSelectable(MediaRoute2Info targetRoute) {
        return getSelectedRoutes().getFirst().getType() == MediaRoute2Info.TYPE_BLE_HEADSET
        return mBluetoothRouteController.isLEAudioBroadcastSupported()
                && getSelectedRoutes().getFirst().getType() == MediaRoute2Info.TYPE_BLE_HEADSET
                && targetRoute.getType() == MediaRoute2Info.TYPE_BLE_HEADSET;
    }

+9 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHearingAid;
import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothStatusCodes;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -327,6 +328,14 @@ import java.util.stream.Collectors;
                .toList();
    }

    /** Returns whether LE Audio broadcast is supported. */
    public boolean isLEAudioBroadcastSupported() {
        return mBluetoothAdapter.isLeAudioBroadcastAssistantSupported()
                == BluetoothStatusCodes.FEATURE_SUPPORTED
                && mBluetoothAdapter.isLeAudioBroadcastSourceSupported()
                == BluetoothStatusCodes.FEATURE_SUPPORTED;
    }

    private void notifyBluetoothRoutesUpdated() {
        mListener.onBluetoothRoutesUpdated();
    }