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

Commit 3d0400f1 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

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

Change-Id: I3f476ceab5ecf16420e14a5341119f859e83844e
parents e1cb23d0 2d332406
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -931,6 +931,8 @@ class AdapterProperties {


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


                    case AbstractionLayer.BT_PROPERTY_DYNAMIC_AUDIO_BUFFER:
                    case AbstractionLayer.BT_PROPERTY_DYNAMIC_AUDIO_BUFFER:
+17 −0
Original line number Original line Diff line number Diff line
@@ -713,6 +713,23 @@ public class AdapterService extends Service {
        BluetoothAdapter.invalidateBluetoothGetStateCache();
        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) {
    void updateAdapterState(int prevState, int newState) {
        mAdapterProperties.setState(newState);
        mAdapterProperties.setState(newState);
        invalidateBluetoothGetStateCache();
        invalidateBluetoothGetStateCache();
+35 −0
Original line number Original line Diff line number Diff line
@@ -51,6 +51,9 @@ import com.android.bluetooth.sap.SapService;
import com.android.bluetooth.vc.VolumeControlService;
import com.android.bluetooth.vc.VolumeControlService;


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


public class Config {
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.
     * 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);
        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() {
    static Class[] getSupportedProfiles() {
        return sSupportedProfiles;
        return sSupportedProfiles;
    }
    }