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

Commit 0c48cf95 authored by Chung Tang's avatar Chung Tang
Browse files

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

[OutputSwitcher] Fix routes will show selectable when LE Audio broadcasting feature is not supported

Existing codes do not check if broadcasting features are supported (e.g. for older pixel devices or override in developer options).

Bug: 428082818
Test: Manual
Flag: EXEMPT bug fix

Change-Id: I558fee2aacd5e67b79503273cc197cff1b9770bb
parent 580acc26
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();
    }