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

Commit 604f9cc9 authored by Rahul Sabnis's avatar Rahul Sabnis Committed by Automerger Merge Worker
Browse files

Merge "Adjusts getPreferredAudioProfiles to check all devices in the CSIP...

Merge "Adjusts getPreferredAudioProfiles to check all devices in the CSIP group" am: 90b3c70e am: 67eb3ab7 am: ff2179b4 am: 39950ef8

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2530159



Change-Id: I68ba504be5f46c7fdd78f0709c3631cf7bc8eeae
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 56e250fc 39950ef8
Loading
Loading
Loading
Loading
+37 −22
Original line number Original line Diff line number Diff line
@@ -4811,23 +4811,38 @@ public class AdapterService extends Service {
                || !isDualModeAudioSinkDevice(device)) {
                || !isDualModeAudioSinkDevice(device)) {
            return Bundle.EMPTY;
            return Bundle.EMPTY;
        }
        }
        // Gets the lead device in the CSIP group to set the preference
        // Checks if the device is part of an LE Audio group
        BluetoothDevice groupLead = mLeAudioService.getLeadDevice(device);
        List<BluetoothDevice> groupDevices = mLeAudioService.getGroupDevices(device);
        if (groupLead == null) {
        if (groupDevices.isEmpty()) {
            return Bundle.EMPTY;
            return Bundle.EMPTY;
        }
        }


        // If there are no preferences stored, return the defaults
        // If there are no preferences stored, return the defaults
        Bundle storedBundle = mDatabaseManager.getPreferredAudioProfiles(groupLead);
        Bundle storedBundle = Bundle.EMPTY;
        for (BluetoothDevice groupDevice: groupDevices) {
            Bundle groupDevicePreferences = mDatabaseManager.getPreferredAudioProfiles(groupDevice);
            if (!groupDevicePreferences.isEmpty()) {
                storedBundle = groupDevicePreferences;
                break;
            }
        }

        if (storedBundle.isEmpty()) {
        if (storedBundle.isEmpty()) {
            Bundle defaultPreferencesBundle = new Bundle();
            boolean useDefaultPreferences = false;
            if (isOutputOnlyAudioSupported(groupDevices)) {
                // Gets the default output only audio profile or defaults to LE_AUDIO if not present
                // Gets the default output only audio profile or defaults to LE_AUDIO if not present
            int outputOnlyDefault = BluetoothProperties.getDefaultOutputOnlyAudioProfile().orElse(
                int outputOnlyDefault = BluetoothProperties.getDefaultOutputOnlyAudioProfile()
                    BluetoothProfile.LE_AUDIO);
                        .orElse(BluetoothProfile.LE_AUDIO);
                if (outputOnlyDefault != BluetoothProfile.A2DP
                if (outputOnlyDefault != BluetoothProfile.A2DP
                        && outputOnlyDefault != BluetoothProfile.LE_AUDIO) {
                        && outputOnlyDefault != BluetoothProfile.LE_AUDIO) {
                    outputOnlyDefault = BluetoothProfile.LE_AUDIO;
                    outputOnlyDefault = BluetoothProfile.LE_AUDIO;
                }
                }

                defaultPreferencesBundle.putInt(BluetoothAdapter.AUDIO_MODE_OUTPUT_ONLY,
                        outputOnlyDefault);
                useDefaultPreferences = true;
            }
            if (isDuplexAudioSupported(groupDevices)) {
                // Gets the default duplex audio profile or defaults to LE_AUDIO if not present
                // Gets the default duplex audio profile or defaults to LE_AUDIO if not present
                int duplexDefault = BluetoothProperties.getDefaultDuplexAudioProfile().orElse(
                int duplexDefault = BluetoothProperties.getDefaultDuplexAudioProfile().orElse(
                        BluetoothProfile.LE_AUDIO);
                        BluetoothProfile.LE_AUDIO);
@@ -4835,12 +4850,12 @@ public class AdapterService extends Service {
                        && duplexDefault != BluetoothProfile.LE_AUDIO) {
                        && duplexDefault != BluetoothProfile.LE_AUDIO) {
                    duplexDefault = BluetoothProfile.LE_AUDIO;
                    duplexDefault = BluetoothProfile.LE_AUDIO;
                }
                }

                defaultPreferencesBundle.putInt(BluetoothAdapter.AUDIO_MODE_DUPLEX, duplexDefault);
            if (isOutputOnlyAudioSupported(mLeAudioService.getGroupDevices(device))) {
                useDefaultPreferences = true;
                storedBundle.putInt(BluetoothAdapter.AUDIO_MODE_OUTPUT_ONLY, outputOnlyDefault);
            }
            }
            if (isDuplexAudioSupported(mLeAudioService.getGroupDevices(device))) {

                storedBundle.putInt(BluetoothAdapter.AUDIO_MODE_DUPLEX, duplexDefault);
            if (useDefaultPreferences) {
                return defaultPreferencesBundle;
            }
            }
        }
        }
        return storedBundle;
        return storedBundle;