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

Commit 816ddee4 authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

Activate connected a2dp devices via AudioRoutingManager

Both AudioRoutingManager and A2dpService try to activate the connected
a2dp devices. This CL remove the logic in A2dpService so that
AudioROutingManager would be the centralized module for handling device
activations.

Bug: 299023147
Test: atest BluetoothInstrumentationTests
Change-Id: Ic0c6914cbf1f1da4b06b7d567e7bf37c65cc9035
parent ae1799cc
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -17,10 +17,12 @@
package com.android.bluetooth.a2dp;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import static com.android.bluetooth.Utils.checkCallerTargetSdk;
import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.bluetooth.Utils.enforceCdmAssociation;
import static com.android.bluetooth.Utils.hasBluetoothPrivilegedPermission;

import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
@@ -57,6 +59,7 @@ import android.util.Log;

import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.Flags;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.MetricsLogger;
@@ -1341,11 +1344,13 @@ public class A2dpService extends ProfileService {
        if (toState == BluetoothProfile.STATE_CONNECTED) {
            MetricsLogger.logProfileConnectionEvent(BluetoothMetricsProto.ProfileId.A2DP);
        }
        if (!Flags.audioRoutingCentralization()) {
            // Set the active device if only one connected device is supported and it was connected
            if (toState == BluetoothProfile.STATE_CONNECTED && (mMaxConnectedAudioDevices == 1)) {
                setActiveDevice(device);
            }
            // When disconnected, ActiveDeviceManager will call setActiveDevice(null)
        }

        // Check if the device is disconnected - if unbond, remove the state machine
        if (toState == BluetoothProfile.STATE_DISCONNECTED) {