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

Commit db1382b6 authored by chelseahao's avatar chelseahao Committed by Chelsea Hao
Browse files

Enable audio sharing hysteresis mode fix when preview is on.

Test: atest
Bug: 368401233
Flag: com.android.settingslib.flags.audio_sharing_developer_option
Change-Id: I994075e6caf10d175bd47bc1672519a0805f8d2c
parent 6d23239e
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -741,13 +741,15 @@ public class BluetoothUtils {
    @WorkerThread
    public static boolean hasConnectedBroadcastSourceForBtDevice(
            @Nullable BluetoothDevice device, @Nullable LocalBluetoothManager localBtManager) {
        if (Flags.audioSharingHysteresisModeFix()) {
        if (localBtManager == null) {
            Log.d(TAG, "Skip check hasConnectedBroadcastSourceForBtDevice due to arg is null");
            return false;
        }
        if (isAudioSharingHysteresisModeFixAvailable(localBtManager.getContext())) {
            return hasActiveLocalBroadcastSourceForBtDevice(device, localBtManager);
        }
        LocalBluetoothLeBroadcastAssistant assistant =
                localBtManager == null
                        ? null
                        : localBtManager.getProfileManager().getLeAudioBroadcastAssistantProfile();
                localBtManager.getProfileManager().getLeAudioBroadcastAssistantProfile();
        if (device == null || assistant == null) {
            Log.d(TAG, "Skip check hasConnectedBroadcastSourceForBtDevice due to arg is null");
            return false;
+3 −3
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.android.settingslib.R;
import com.android.settingslib.flags.Flags;

import com.google.common.collect.ImmutableList;

@@ -1152,7 +1151,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
        int targetGroupId = BluetoothCsipSetCoordinator.GROUP_ID_INVALID;
        int fallbackActiveGroupId = BluetoothUtils.getPrimaryGroupIdForBroadcast(
                mContext.getContentResolver());
        if (Flags.audioSharingHysteresisModeFix()) {
        if (BluetoothUtils.isAudioSharingHysteresisModeFixAvailable(mContext)) {
            int userPreferredPrimaryGroupId = getUserPreferredPrimaryGroupId();
            if (userPreferredPrimaryGroupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID
                    && deviceGroupsInBroadcast.containsKey(userPreferredPrimaryGroupId)) {
@@ -1193,7 +1192,8 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {

    @NonNull
    private Map<Integer, List<BluetoothDevice>> getDeviceGroupsInBroadcast() {
        boolean hysteresisModeFixEnabled = Flags.audioSharingHysteresisModeFix();
        boolean hysteresisModeFixEnabled =
                BluetoothUtils.isAudioSharingHysteresisModeFixAvailable(mContext);
        List<BluetoothDevice> connectedDevices = mServiceBroadcastAssistant.getConnectedDevices();
        return connectedDevices.stream()
                .filter(