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

Commit 933a7c02 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Disable le audio service if controller is not supported" am: 2d332406 am: 3d0400f1

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

Change-Id: I0d159d9e4436e647de05af5013884765a6a6bece
parents e372384b 3d0400f1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -931,6 +931,8 @@ class AdapterProperties {

                    case AbstractionLayer.BT_PROPERTY_LOCAL_LE_FEATURES:
                        updateFeatureSupport(val);
                        mService.updateLeAudioProfileServiceState(
                                mIsLeConnectedIsochronousStreamCentralSupported);
                        break;

                    case AbstractionLayer.BT_PROPERTY_DYNAMIC_AUDIO_BUFFER:
+17 −0
Original line number Diff line number Diff line
@@ -713,6 +713,23 @@ public class AdapterService extends Service {
        BluetoothAdapter.invalidateBluetoothGetStateCache();
    }

    void updateLeAudioProfileServiceState(boolean isCisCentralSupported) {
        if (isCisCentralSupported) {
            return;
        }

        // Remove the Le audio unicast profiles from the supported list
        // since the controller doesn't support
        Config.removeLeAudioUnicastProfilesFromSupportedList();
        HashSet<Class> leAudioUnicastProfiles = Config.geLeAudioUnicastProfiles();

        for (Class profileService : leAudioUnicastProfiles) {
            if (isStartedProfile(profileService.getSimpleName())){
                setProfileServiceState(profileService, BluetoothAdapter.STATE_OFF);
            }
        }
    }

    void updateAdapterState(int prevState, int newState) {
        mAdapterProperties.setState(newState);
        invalidateBluetoothGetStateCache();
+35 −0
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ import com.android.bluetooth.sap.SapService;
import com.android.bluetooth.vc.VolumeControlService;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

public class Config {
@@ -68,6 +71,15 @@ public class Config {
        }
    }

    /**
     * List of profile services related to LE audio
     */
    private static final HashSet<Class> mLeAudioUnicastProfiles = new HashSet<Class>(
            Arrays.asList(LeAudioService.class,
                        VolumeControlService.class,
                        McpService.class,
                        CsipSetCoordinatorService.class));

    /**
     * List of profile services with the profile-supported resource flag and bit mask.
     */
@@ -157,6 +169,29 @@ public class Config {
        sIsGdEnabledUptoScanningLayer = resources.getBoolean(R.bool.enable_gd_up_to_scanning_layer);
    }

    /**
     * Remove LE audio unicast related profiles from the supported list.
     */
    static void removeLeAudioUnicastProfilesFromSupportedList() {
        ArrayList<Class> profilesList = new ArrayList<Class>(Arrays.asList(sSupportedProfiles));
        Iterator<Class> iter = profilesList.iterator();

        while (iter.hasNext()) {
            Class profileClass = iter.next();

            if (mLeAudioUnicastProfiles.contains(profileClass)) {
                iter.remove();
                Log.v(TAG, "Remove " + profileClass.getSimpleName() + " from supported list.");
            }
        }

        sSupportedProfiles = profilesList.toArray(new Class[profilesList.size()]);
    }

    static HashSet<Class> geLeAudioUnicastProfiles() {
        return mLeAudioUnicastProfiles;
    }

    static Class[] getSupportedProfiles() {
        return sSupportedProfiles;
    }