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

Commit bb06432e authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

AudioDeviceBroker: Fix not setting proper call volume for LE Headset

When switching from A2DP to SCO device for the IN_CALL mode, the new
device type stream volume gets applied. However in case of LE Audio
devices, the device stays the same, but when the mode changes to IN_CALL,
the LE Headset is not yet set as a communication device so we must do an
additional stream volume level alignment for the communication stream
when it gets activated.

When the call ends, the mode change handler will restore the previous
mode stream volume for the LE Headset device.

Bug: 278197636
Bug: 245638147
Test: tested manually
Change-Id: I08b0052c799a657b31d6e1a1db2ee88573ae5e83
Merged-In: I08b0052c799a657b31d6e1a1db2ee88573ae5e83
(cherry picked from commit 19a459b7)
parent 65ca1b57
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -389,6 +389,20 @@ import java.util.concurrent.atomic.AtomicBoolean;
            mBtHelper.stopBluetoothSco(eventSource);
        }

        // In BT classic for communication, the device changes from a2dp to sco device, but for
        // LE Audio it stays the same and we must trigger the proper stream volume alignment, if
        // LE Audio communication device is activated after the audio system has already switched to
        // MODE_IN_CALL mode.
        if (isBluetoothLeAudioRequested()) {
            final int streamType = mAudioService.getBluetoothContextualVolumeStream();
            final int leAudioVolIndex = getVssVolumeForDevice(streamType, device.getInternalType());
            final int leAudioMaxVolIndex = getMaxVssVolumeForStream(streamType);
            if (AudioService.DEBUG_COMM_RTE) {
                Log.v(TAG, "setCommunicationRouteForClient restoring LE Audio device volume lvl.");
            }
            postSetLeAudioVolumeIndex(leAudioVolIndex, leAudioMaxVolIndex, streamType);
        }

        sendLMsgNoDelay(MSG_L_UPDATE_COMMUNICATION_ROUTE, SENDMSG_QUEUE, eventSource);
    }

@@ -537,6 +551,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
        return isDeviceRequestedForCommunication(AudioDeviceInfo.TYPE_BLUETOOTH_SCO);
    }

    /**
     * Helper method on top of isDeviceRequestedForCommunication() indicating if
     * Bluetooth LE Audio communication device is currently requested or not.
     * @return true if Bluetooth LE Audio device is requested, false otherwise.
     */
    /*package*/ boolean isBluetoothLeAudioRequested() {
        return isDeviceRequestedForCommunication(AudioDeviceInfo.TYPE_BLE_HEADSET)
                || isDeviceRequestedForCommunication(AudioDeviceInfo.TYPE_BLE_SPEAKER);
    }

    /**
     * Indicates if preferred route selection for communication is Bluetooth SCO.
     * @return true if Bluetooth SCO is preferred , false otherwise.