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

Commit af7851ee authored by Jack He's avatar Jack He Committed by Gerrit Code Review
Browse files

Merge "Disable BASS based on the HW capabilities"

parents 09b0d119 1d5e9185
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -950,8 +950,7 @@ class AdapterProperties {

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

                    case AbstractionLayer.BT_PROPERTY_DYNAMIC_AUDIO_BUFFER:
+31 −12
Original line number Diff line number Diff line
@@ -745,22 +745,30 @@ public class AdapterService extends Service {
    }
     */

    void updateLeAudioProfileServiceState(boolean isCisCentralSupported) {
        if (isCisCentralSupported) {
            return;
    void updateLeAudioProfileServiceState() {
        HashSet<Class> nonSupportedProfiles = new HashSet<>();

        if (!isLeConnectedIsochronousStreamCentralSupported()) {
            nonSupportedProfiles.addAll(Config.geLeAudioUnicastProfiles());
        }

        if (!isLeAudioBroadcastAssistantSupported()) {
            nonSupportedProfiles.add(BassClientService.class);
        }

        // Remove the Le audio unicast profiles from the supported list
        if (!nonSupportedProfiles.isEmpty()) {
            // Remove non-supported profiles from the supported list
            // since the controller doesn't support
        Config.removeLeAudioUnicastProfilesFromSupportedList();
        HashSet<Class> leAudioUnicastProfiles = Config.geLeAudioUnicastProfiles();
            Config.removeProfileFromSupportedList(nonSupportedProfiles);

        for (Class profileService : leAudioUnicastProfiles) {
            // Disable the non-supported profiles service
            for (Class profileService : nonSupportedProfiles) {
                if (isStartedProfile(profileService.getSimpleName())) {
                    setProfileServiceState(profileService, BluetoothAdapter.STATE_OFF);
                }
            }
        }
    }

    void updateAdapterState(int prevState, int newState) {
        mAdapterProperties.setState(newState);
@@ -3418,7 +3426,10 @@ public class AdapterService extends Service {
                return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
            }

            if (service.isLeAudioBroadcastAssistantSupported()) {
            HashSet<Class> supportedProfileServices =
                    new HashSet<Class>(Arrays.asList(Config.getSupportedProfiles()));

            if (supportedProfileServices.contains(BassClientService.class)) {
                return BluetoothStatusCodes.FEATURE_SUPPORTED;
            }

@@ -4603,13 +4614,21 @@ public class AdapterService extends Service {
     * @return true, if the LE audio broadcast assistant is supported
     */
    public boolean isLeAudioBroadcastAssistantSupported() {
        //TODO: check the profile support status as well after we have the implementation
        return mAdapterProperties.isLePeriodicAdvertisingSupported()
            && mAdapterProperties.isLeExtendedAdvertisingSupported()
            && (mAdapterProperties.isLePeriodicAdvertisingSyncTransferSenderSupported()
                || mAdapterProperties.isLePeriodicAdvertisingSyncTransferRecipientSupported());
    }

    /**
     * Check if the LE audio CIS central feature is supported.
     *
     * @return true, if the LE audio CIS central is supported
     */
    public boolean isLeConnectedIsochronousStreamCentralSupported() {
        return mAdapterProperties.isLeConnectedIsochronousStreamCentralSupported();
    }

    public int getLeMaximumAdvertisingDataLength() {
        return mAdapterProperties.getLeMaximumAdvertisingDataLength();
    }
+3 −3
Original line number Diff line number Diff line
@@ -199,16 +199,16 @@ public class Config {
    }

    /**
     * Remove LE audio unicast related profiles from the supported list.
     * Remove the input profiles from the supported list.
     */
    static void removeLeAudioUnicastProfilesFromSupportedList() {
    static void removeProfileFromSupportedList(HashSet<Class> nonSupportedProfiles) {
        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)) {
            if (nonSupportedProfiles.contains(profileClass)) {
                iter.remove();
                Log.v(TAG, "Remove " + profileClass.getSimpleName() + " from supported list.");
            }