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

Commit b9ef22e4 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Make use of new flag leaudio_unicast_inactivate_device_based_on_context

Bug: 313054788
Bug: 295546903
Test: atest LeAudioServiceTest
Tag: #feature
Change-Id: Ie441f6a15c7c740331139a8296c1cf8d7e7d2b7b
parent 797755b2
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class LeAudioService extends ProfileService {
    private BluetoothDevice mExposedActiveDevice;
    private LeAudioCodecConfig mLeAudioCodecConfig;
    private final Object mGroupLock = new Object();
    private final FeatureFlags mFeatureFlags = new FeatureFlagsImpl();
    private FeatureFlags mFeatureFlags = new FeatureFlagsImpl();
    ServiceFactory mServiceFactory = new ServiceFactory();

    LeAudioNativeInterface mLeAudioNativeInterface;
@@ -502,6 +502,11 @@ public class LeAudioService extends ProfileService {
        sLeAudioService = instance;
    }

    @VisibleForTesting
    void setFeatureFlags(FeatureFlags featureFlags) {
        mFeatureFlags = featureFlags;
    }

    VolumeControlService getVolumeControlService() {
        if (mVolumeControlService == null) {
            mVolumeControlService = mServiceFactory.getVolumeControlService();
@@ -1843,12 +1848,18 @@ public class LeAudioService extends ProfileService {
                                1);
                break;
            case LeAudioStackEvent.HEALTH_RECOMMENDATION_ACTION_INACTIVATE_GROUP:
                if (mFeatureFlags.leaudioUnicastInactivateDeviceBasedOnContext()) {
                    LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(groupId);
                    if (groupDescriptor != null && groupDescriptor.mIsActive) {
                    Log.i(TAG, "Group " + groupId + " is inactivated due to blocked media context");
                        Log.i(
                                TAG,
                                "Group "
                                        + groupId
                                        + " is inactivated due to blocked media context");
                        groupDescriptor.mInactivatedDueToContextType = true;
                        setActiveGroupWithDevice(null, true);
                    }
                }
            default:
                break;
        }
+9 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ServiceFactory;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.csip.CsipSetCoordinatorService;
import com.android.bluetooth.flags.FakeFeatureFlagsImpl;
import com.android.bluetooth.flags.Flags;
import com.android.bluetooth.hap.HapClientService;
import com.android.bluetooth.hfp.HeadsetService;
import com.android.bluetooth.mcp.McpService;
@@ -109,6 +111,7 @@ public class LeAudioServiceTest {
    private boolean onGroupStatusCallbackCalled = false;
    private boolean onGroupCodecConfChangedCallbackCalled = false;
    private BluetoothLeAudioCodecStatus testCodecStatus = null;
    private FakeFeatureFlagsImpl mFakeFlagsImpl;

    private BroadcastReceiver mLeAudioIntentReceiver;

@@ -1538,6 +1541,12 @@ public class LeAudioServiceTest {

    @Test
    public void testMediaContextUnavailableForAWhile() {

        mFakeFlagsImpl = new FakeFeatureFlagsImpl();
        mFakeFlagsImpl.setFlag(Flags.FLAG_LEAUDIO_UNICAST_INACTIVATE_DEVICE_BASED_ON_CONTEXT, true);
        mFakeFlagsImpl.setFlag(Flags.FLAG_AUDIO_ROUTING_CENTRALIZATION, true);
        mService.setFeatureFlags(mFakeFlagsImpl);

        doReturn(true).when(mNativeInterface).connectLeAudio(any(BluetoothDevice.class));
        connectTestDevice(mSingleDevice, testGroupId);