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

Commit cebb4d7d authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Automerger Merge Worker
Browse files

LeAudioTestApp: Do not try initializing unsupported profiles am: e91f5f48 am: f1b92d33

parents d63291e6 f1b92d33
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -705,6 +705,7 @@ public class BluetoothProxy {
    }

    private void initCsisProxy() {
        if (!isCoordinatedSetProfileSupported()) return;
        if (bluetoothCsis == null) {
            bluetoothAdapter.getProfileProxy(this.application, profileListener,
                    BluetoothProfile.CSIP_SET_COORDINATOR);
@@ -712,12 +713,14 @@ public class BluetoothProxy {
    }

    private void cleanupCsisProxy() {
        if (!isCoordinatedSetProfileSupported()) return;
        if (bluetoothCsis != null) {
            bluetoothAdapter.closeProfileProxy(BluetoothProfile.LE_AUDIO, bluetoothCsis);
        }
    }

    private void initLeAudioProxy() {
        if (!isLeAudioUnicastSupported()) return;
        if (bluetoothLeAudio == null) {
            bluetoothAdapter.getProfileProxy(this.application, profileListener,
                    BluetoothProfile.LE_AUDIO);
@@ -729,6 +732,7 @@ public class BluetoothProxy {
    }

    private void cleanupLeAudioProxy() {
        if (!isLeAudioUnicastSupported()) return;
        if (bluetoothLeAudio != null) {
            bluetoothAdapter.closeProfileProxy(BluetoothProfile.LE_AUDIO, bluetoothLeAudio);
            application.unregisterReceiver(leAudioIntentReceiver);
@@ -736,6 +740,7 @@ public class BluetoothProxy {
    }

    private void initVolumeControlProxy() {
        if (!isVolumeControlClientSupported()) return;
        bluetoothAdapter.getProfileProxy(this.application, profileListener,
                BluetoothProfile.VOLUME_CONTROL);

@@ -745,6 +750,7 @@ public class BluetoothProxy {
    }

    private void cleanupVolumeControlProxy() {
        if (!isVolumeControlClientSupported()) return;
        if (bluetoothVolumeControl != null) {
            bluetoothAdapter.closeProfileProxy(BluetoothProfile.VOLUME_CONTROL,
                    bluetoothVolumeControl);
@@ -753,6 +759,7 @@ public class BluetoothProxy {
    }

    private void initHapProxy() {
        if (!isLeAudioHearingAccessClientSupported()) return;
        bluetoothAdapter.getProfileProxy(this.application, profileListener,
                BluetoothProfile.HAP_CLIENT);

@@ -763,6 +770,7 @@ public class BluetoothProxy {
    }

    private void cleanupHapProxy() {
        if (!isLeAudioHearingAccessClientSupported()) return;
        if (bluetoothHapClient != null) {
            bluetoothHapClient.unregisterCallback(hapCallback);
            bluetoothAdapter.closeProfileProxy(BluetoothProfile.HAP_CLIENT, bluetoothHapClient);
@@ -771,11 +779,13 @@ public class BluetoothProxy {
    }

    private void initBassProxy() {
        if (!isLeAudioBroadcastScanAssistanSupported()) return;
        bluetoothAdapter.getProfileProxy(this.application, profileListener,
                BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT);
    }

    private void cleanupBassProxy() {
        if (!isLeAudioBroadcastScanAssistanSupported()) return;
        if (mBluetoothLeBroadcastAssistant != null) {
            mBluetoothLeBroadcastAssistant.unregisterCallback(mBroadcastAssistantCallback);
            bluetoothAdapter.closeProfileProxy(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT,
@@ -978,6 +988,8 @@ public class BluetoothProxy {
    }

    public void groupSetLock(Integer group_id, boolean lock) {
        if (bluetoothCsis == null) return;

        Log.d("Lock", "lock: " + lock);
        if (lock) {
            if (mGroupLocks.containsKey(group_id)) return;
@@ -1361,11 +1373,33 @@ public class BluetoothProxy {
        return mBluetoothLeBroadcast.isPlaying(broadcastId);
    }

    boolean isLeAudioUnicastSupported() {
        return (bluetoothAdapter
                .isLeAudioSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
    }

    boolean isCoordinatedSetProfileSupported() {
        return isLeAudioUnicastSupported();
    }

    boolean isVolumeControlClientSupported() {
        return isLeAudioUnicastSupported();
    }

    boolean isLeAudioHearingAccessClientSupported() {
        return isLeAudioUnicastSupported();
    }

    public boolean isLeAudioBroadcastSourceSupported() {
        return (bluetoothAdapter
                .isLeAudioBroadcastSourceSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
    }

    public boolean isLeAudioBroadcastScanAssistanSupported() {
        return (bluetoothAdapter
                .isLeAudioBroadcastAssistantSupported() == BluetoothStatusCodes.FEATURE_SUPPORTED);
    }

    public void setOnBassEventListener(OnBassEventListener listener) {
        mBassEventListener = listener;
    }