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

Commit 685ffd2d authored by William Escande's avatar William Escande
Browse files

24Q4: Removal of leaudio_synchronize_start

Bug: 341385684
Fix: 341385684
Flag: com.android.bluetooth.flags.leaudio_synchronize_start
Test: m . | This is a startup sequence tested by any e2e test
Change-Id: I6626418a9747bf64f3dc95ed5433236ca85e50b3
parent 1f3cf67a
Loading
Loading
Loading
Loading
+39 −100
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import com.android.bluetooth.avrcpcontroller.AvrcpControllerService;
import com.android.bluetooth.bas.BatteryService;
import com.android.bluetooth.bass_client.BassClientService;
import com.android.bluetooth.csip.CsipSetCoordinatorService;
import com.android.bluetooth.flags.Flags;
import com.android.bluetooth.gatt.GattService;
import com.android.bluetooth.hap.HapClientService;
import com.android.bluetooth.hearingaid.HearingAidService;
@@ -86,11 +85,7 @@ public class Config {
    };

    /** List of profile services with the profile-supported resource flag and bit mask. */
    private static final ProfileConfig[] PROFILE_SERVICES_AND_FLAGS;

    static {
        if (Flags.leaudioSynchronizeStart()) {
            PROFILE_SERVICES_AND_FLAGS =
    private static final ProfileConfig[] PROFILE_SERVICES_AND_FLAGS =
            new ProfileConfig[] {
                // Prioritize GattService startup by making it the first Profile to
                // boot. This resolves dependency issues for some Profiles.
@@ -99,8 +94,7 @@ public class Config {
                new ProfileConfig(A2dpSinkService.isEnabled(), BluetoothProfile.A2DP_SINK),
                new ProfileConfig(AvrcpTargetService.isEnabled(), BluetoothProfile.AVRCP),
                new ProfileConfig(
                                AvrcpControllerService.isEnabled(),
                                BluetoothProfile.AVRCP_CONTROLLER),
                        AvrcpControllerService.isEnabled(), BluetoothProfile.AVRCP_CONTROLLER),
                new ProfileConfig(
                        BassClientService.isEnabled(),
                        BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT),
@@ -108,83 +102,28 @@ public class Config {
                new ProfileConfig(
                        CsipSetCoordinatorService.isEnabled(),
                        BluetoothProfile.CSIP_SET_COORDINATOR),
                        new ProfileConfig(
                                HapClientService.isEnabled(), BluetoothProfile.HAP_CLIENT),
                new ProfileConfig(HapClientService.isEnabled(), BluetoothProfile.HAP_CLIENT),
                new ProfileConfig(HeadsetService.isEnabled(), BluetoothProfile.HEADSET),
                new ProfileConfig(
                        HeadsetClientService.isEnabled(), BluetoothProfile.HEADSET_CLIENT),
                        new ProfileConfig(
                                HearingAidService.isEnabled(), BluetoothProfile.HEARING_AID),
                        new ProfileConfig(
                                HidDeviceService.isEnabled(), BluetoothProfile.HID_DEVICE),
                new ProfileConfig(HearingAidService.isEnabled(), BluetoothProfile.HEARING_AID),
                new ProfileConfig(HidDeviceService.isEnabled(), BluetoothProfile.HID_DEVICE),
                new ProfileConfig(HidHostService.isEnabled(), BluetoothProfile.HID_HOST),
                new ProfileConfig(TbsService.isEnabled(), BluetoothProfile.LE_CALL_CONTROL),
                new ProfileConfig(BluetoothMapService.isEnabled(), BluetoothProfile.MAP),
                        new ProfileConfig(
                                MapClientService.isEnabled(), BluetoothProfile.MAP_CLIENT),
                new ProfileConfig(MapClientService.isEnabled(), BluetoothProfile.MAP_CLIENT),
                new ProfileConfig(McpService.isEnabled(), BluetoothProfile.MCP_SERVER),
                new ProfileConfig(BluetoothOppService.isEnabled(), BluetoothProfile.OPP),
                new ProfileConfig(PanService.isEnabled(), BluetoothProfile.PAN),
                new ProfileConfig(BluetoothPbapService.isEnabled(), BluetoothProfile.PBAP),
                        new ProfileConfig(
                                PbapClientService.isEnabled(), BluetoothProfile.PBAP_CLIENT),
                new ProfileConfig(PbapClientService.isEnabled(), BluetoothProfile.PBAP_CLIENT),
                new ProfileConfig(SapService.isEnabled(), BluetoothProfile.SAP),
                new ProfileConfig(
                        VolumeControlService.isEnabled(), BluetoothProfile.VOLUME_CONTROL),
                new ProfileConfig(LeAudioService.isEnabled(), BluetoothProfile.LE_AUDIO),
                new ProfileConfig(
                                LeAudioService.isBroadcastEnabled(),
                                BluetoothProfile.LE_AUDIO_BROADCAST),
                    };
        } else {
            PROFILE_SERVICES_AND_FLAGS =
                    new ProfileConfig[] {
                        // Prioritize GattService startup by making it the first Profile to
                        // boot. This resolves dependency issues for some Profiles.
                        new ProfileConfig(GattService.isEnabled(), BluetoothProfile.GATT),
                        new ProfileConfig(A2dpService.isEnabled(), BluetoothProfile.A2DP),
                        new ProfileConfig(A2dpSinkService.isEnabled(), BluetoothProfile.A2DP_SINK),
                        new ProfileConfig(AvrcpTargetService.isEnabled(), BluetoothProfile.AVRCP),
                        new ProfileConfig(
                                AvrcpControllerService.isEnabled(),
                                BluetoothProfile.AVRCP_CONTROLLER),
                        new ProfileConfig(
                                BassClientService.isEnabled(),
                                BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT),
                        new ProfileConfig(BatteryService.isEnabled(), BluetoothProfile.BATTERY),
                        new ProfileConfig(
                                CsipSetCoordinatorService.isEnabled(),
                                BluetoothProfile.CSIP_SET_COORDINATOR),
                        new ProfileConfig(
                                HapClientService.isEnabled(), BluetoothProfile.HAP_CLIENT),
                        new ProfileConfig(HeadsetService.isEnabled(), BluetoothProfile.HEADSET),
                        new ProfileConfig(
                                HeadsetClientService.isEnabled(), BluetoothProfile.HEADSET_CLIENT),
                        new ProfileConfig(
                                HearingAidService.isEnabled(), BluetoothProfile.HEARING_AID),
                        new ProfileConfig(
                                HidDeviceService.isEnabled(), BluetoothProfile.HID_DEVICE),
                        new ProfileConfig(HidHostService.isEnabled(), BluetoothProfile.HID_HOST),
                        new ProfileConfig(LeAudioService.isEnabled(), BluetoothProfile.LE_AUDIO),
                        new ProfileConfig(
                                LeAudioService.isBroadcastEnabled(),
                                BluetoothProfile.LE_AUDIO_BROADCAST),
                        new ProfileConfig(TbsService.isEnabled(), BluetoothProfile.LE_CALL_CONTROL),
                        new ProfileConfig(BluetoothMapService.isEnabled(), BluetoothProfile.MAP),
                        new ProfileConfig(
                                MapClientService.isEnabled(), BluetoothProfile.MAP_CLIENT),
                        new ProfileConfig(McpService.isEnabled(), BluetoothProfile.MCP_SERVER),
                        new ProfileConfig(BluetoothOppService.isEnabled(), BluetoothProfile.OPP),
                        new ProfileConfig(PanService.isEnabled(), BluetoothProfile.PAN),
                        new ProfileConfig(BluetoothPbapService.isEnabled(), BluetoothProfile.PBAP),
                        new ProfileConfig(
                                PbapClientService.isEnabled(), BluetoothProfile.PBAP_CLIENT),
                        new ProfileConfig(SapService.isEnabled(), BluetoothProfile.SAP),
                        new ProfileConfig(
                                VolumeControlService.isEnabled(), BluetoothProfile.VOLUME_CONTROL),
                        LeAudioService.isBroadcastEnabled(), BluetoothProfile.LE_AUDIO_BROADCAST),
            };
        }
    }

    /** A test function to allow for dynamic enabled */
    @VisibleForTesting
+0 −28
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import android.bluetooth.IBluetoothLeBroadcastCallback;
import android.bluetooth.IBluetoothVolumeControl;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.IScannerCallback;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
@@ -604,30 +603,6 @@ public class LeAudioService extends ProfileService {

        // Setup codec config
        mLeAudioCodecConfig = new LeAudioCodecConfig(this);
        if (!Flags.leaudioSynchronizeStart()) {
            // Delay the call to init by posting it. This ensures TBS and MCS are fully initialized
            // before we start accepting connections
            mHandler.post(this::init);
            return;
        }
        mNativeInterface.init(mLeAudioCodecConfig.getCodecConfigOffloading());

        if (leaudioUseAudioModeListener()) {
            mAudioManager.addOnModeChangedListener(getMainExecutor(), mAudioModeChangeListener);
        }
    }

    // TODO: b/341385684 -- Delete the init method as it has been inlined in start
    private void init() {
        if (!isAvailable()) {
            Log.e(TAG, " Service disabled before init");
            return;
        }

        if (!mTmapStarted) {
            mTmapStarted = registerTmap();
        }

        mNativeInterface.init(mLeAudioCodecConfig.getCodecConfigOffloading());

        if (leaudioUseAudioModeListener()) {
@@ -656,9 +631,6 @@ public class LeAudioService extends ProfileService {

        clearCreateBroadcastTimeoutCallback();

        if (!Flags.leaudioSynchronizeStart()) {
            mHandler.removeCallbacks(this::init);
        }
        removeActiveDevice(false);

        if (mTmapGattServer == null) {
+1 −14
Original line number Diff line number Diff line
@@ -24,15 +24,12 @@ import android.bluetooth.BluetoothProfile;
import android.bluetooth.IBluetoothMcpServiceManager;
import android.content.AttributionSource;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.ParcelUuid;
import android.sysprop.BluetoothProperties;
import android.util.Log;

import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.flags.Flags;
import com.android.bluetooth.le_audio.LeAudioService;
import com.android.internal.annotations.VisibleForTesting;

@@ -48,7 +45,6 @@ public class McpService extends ProfileService {

    private final MediaControlProfile mGmcs;
    private final Map<BluetoothDevice, Integer> mDeviceAuthorizations = new HashMap<>();
    private final Handler mHandler = new Handler(Looper.getMainLooper());

    public McpService(Context ctx) {
        this(ctx, null);
@@ -102,16 +98,7 @@ public class McpService extends ProfileService {
        // Mark service as started
        setMcpService(this);

        if (Flags.leaudioSynchronizeStart()) {
        mGmcs.init();
            return;
        }
        mHandler.post(
                () -> {
                    if (isAvailable()) {
                        mGmcs.init();
                    }
                });
    }

    @Override
+0 −10
Original line number Diff line number Diff line
@@ -223,16 +223,6 @@ flag {
    }
}

flag {
    name: "leaudio_synchronize_start"
    namespace: "bluetooth"
    description: "Do not post on main looper when starting le_audio"
    bug: "341385684"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "headtracker_codec_capability"
    namespace: "bluetooth"