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

Commit 2e459fb7 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Improve update active device

When updating out or in active device, we might return imidiatelly if
previous and new device does not support given direction.

Bug: 150670922
Sponsor: @jpawlowski
Test: atest BluetoothInstrumentationTests
Change-Id: I8d27d80523f114e2e717406fef91ef3c3e5b0a88
parent 7b325bb3
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -658,6 +658,14 @@ public class LeAudioService extends ProfileService {
        boolean newSupportedByDeviceInput = (newSupportedAudioDirections
                & AUDIO_DIRECTION_INPUT_BIT) != 0;

        /*
         * Do not update input if neither previous nor current device support input
         */
        if (!oldSupportedByDeviceInput && !newSupportedByDeviceInput) {
            Log.d(TAG, "updateActiveInDevice: Device does not support input.");
            return false;
        }

        if (device != null && mActiveAudioInDevice != null) {
            int previousGroupId = getGroupId(mActiveAudioInDevice);
            if (previousGroupId == groupId) {
@@ -673,14 +681,6 @@ public class LeAudioService extends ProfileService {

        BluetoothDevice previousInDevice = mActiveAudioInDevice;

        /*
         * Do not update input if neither previous nor current device support input
         */
        if (!oldSupportedByDeviceInput && !newSupportedByDeviceInput) {
            Log.d(TAG, "updateActiveInDevice: Device does not support input.");
            return false;
        }

        /*
         * Update input if:
         * - Device changed
@@ -717,6 +717,14 @@ public class LeAudioService extends ProfileService {
        boolean newSupportedByDeviceOutput = (newSupportedAudioDirections
                & AUDIO_DIRECTION_OUTPUT_BIT) != 0;

        /*
         * Do not update output if neither previous nor current device support output
         */
        if (!oldSupportedByDeviceOutput && !newSupportedByDeviceOutput) {
            Log.d(TAG, "updateActiveOutDevice: Device does not support output.");
            return false;
        }

        if (device != null && mActiveAudioOutDevice != null) {
            int previousGroupId = getGroupId(mActiveAudioOutDevice);
            if (previousGroupId == groupId) {
@@ -732,14 +740,6 @@ public class LeAudioService extends ProfileService {

        BluetoothDevice previousOutDevice = mActiveAudioOutDevice;

        /*
         * Do not update output if neither previous nor current device support output
         */
        if (!oldSupportedByDeviceOutput && !newSupportedByDeviceOutput) {
            Log.d(TAG, "updateActiveOutDevice: Device does not support output.");
            return false;
        }

        /*
         * Update output if:
         * - Device changed