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

Commit 0f307203 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Jakub Pawłowski
Browse files

Reorder LE Audio related services start.

Native code for LE Audio service initialization is triggering the
re-connections. It must be last service that starts, otherwise device
that quickly establishes connection might find some GATT services not
ready.

1. Start LE Audio service after MCS and GTBS service.
2. Post native initialization, to ensure tasks posted in GTBS and MCS
   finish before LE native init is executed.

Test: quickly reconnect LE Audio device, ensure GTBS and MCS service is
      properly discovered and connected.
Bug: 209606901
Bug: 150670922
Change-Id: I34549ec7fbf4dabba2f342b9676b7dbda636e957
parent 6d109fc1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -117,8 +117,6 @@ public class Config {
                    (1 << BluetoothProfile.OPP)),
            new ProfileConfig(BluetoothPbapService.class, R.bool.profile_supported_pbap,
                    (1 << BluetoothProfile.PBAP)),
            new ProfileConfig(LeAudioService.class, R.bool.profile_supported_le_audio,
                    (1 << BluetoothProfile.LE_AUDIO)),
            new ProfileConfig(VolumeControlService.class, R.bool.profile_supported_vc,
                    (1 << BluetoothProfile.VOLUME_CONTROL)),
            new ProfileConfig(McpService.class, R.bool.profile_supported_mcp_server,
@@ -126,6 +124,8 @@ public class Config {
            new ProfileConfig(HearingAidService.class,
                    com.android.internal.R.bool.config_hearing_aid_profile_supported,
                    (1 << BluetoothProfile.HEARING_AID)),
            new ProfileConfig(LeAudioService.class, R.bool.profile_supported_le_audio,
                    (1 << BluetoothProfile.LE_AUDIO)),
            new ProfileConfig(CsipSetCoordinatorService.class,
                    R.bool.profile_supported_csip_set_coordinator,
                    (1 << BluetoothProfile.CSIP_SET_COORDINATOR)),
+7 −6
Original line number Diff line number Diff line
@@ -27,20 +27,17 @@ import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothUuid;
import android.bluetooth.IBluetoothLeAudio;
import android.bluetooth.IBluetoothVolumeControl;
import android.content.AttributionSource;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.media.AudioManager;
import android.media.BtProfileConnectionInfo;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.util.Log;

import com.android.bluetooth.Utils;
@@ -133,6 +130,7 @@ public class LeAudioService extends ProfileService {

    private BroadcastReceiver mBondStateChangedReceiver;
    private BroadcastReceiver mConnectionStateChangedReceiver;
    private Handler mHandler = new Handler(Looper.getMainLooper());

    @Override
    protected IProfileServiceBinder initBinder() {
@@ -186,7 +184,10 @@ public class LeAudioService extends ProfileService {
        // Setup codec config
        mLeAudioCodecConfig = new LeAudioCodecConfig(this);

        mLeAudioNativeInterface.init(mLeAudioCodecConfig.getCodecConfigOffloading());
        // Delay the call to init by posting it. This ensures TBS and MCS are fully initialized
        // before we start accepting connections
        mHandler.post(() ->
                mLeAudioNativeInterface.init(mLeAudioCodecConfig.getCodecConfigOffloading()));

        return true;
    }