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

Commit 2c111229 authored by Yiyi Shen's avatar Yiyi Shen Committed by Android (Google) Code Review
Browse files

Merge "[Audiosharing] Fix hysteresis mode" into main

parents 791cbe1c 578118bf
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.settingslib.bluetooth;

import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;

import static com.android.settingslib.Utils.isAudioModeOngoingCall;

import static java.util.stream.Collectors.toList;

import android.annotation.CallbackExecutor;
@@ -302,6 +304,7 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
                                        + ", sourceId = "
                                        + sourceId);
                    }
                    updateFallbackActiveDeviceIfNeeded();
                }

                @Override
@@ -389,9 +392,6 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
                                        + ", state = "
                                        + state);
                    }
                    if (BluetoothUtils.isConnected(state)) {
                        updateFallbackActiveDeviceIfNeeded();
                    }
                }
            };

@@ -1129,18 +1129,8 @@ public class LocalBluetoothLeBroadcast implements LocalBluetoothProfile {
            Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded for work profile.");
            return;
        }
        if (mServiceBroadcast == null) {
            Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded due to broadcast profile is null");
            return;
        }
        List<BluetoothLeBroadcastMetadata> sources = mServiceBroadcast.getAllBroadcastMetadata();
        if (sources.stream()
                .noneMatch(source -> mServiceBroadcast.isPlaying(source.getBroadcastId()))) {
            Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded due to no broadcast ongoing");
            return;
        }
        if (mServiceBroadcastAssistant == null) {
            Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded due to assistant profile is null");
        if (isAudioModeOngoingCall(mContext)) {
            Log.d(TAG, "Skip updateFallbackActiveDeviceIfNeeded due to ongoing call");
            return;
        }
        Map<Integer, List<BluetoothDevice>> deviceGroupsInBroadcast = getDeviceGroupsInBroadcast();
+4 −6
Original line number Diff line number Diff line
@@ -35,11 +35,7 @@ val LocalBluetoothLeBroadcastAssistant.onSourceConnectedOrRemoved: Flow<Unit>
                    sink: BluetoothDevice,
                    sourceId: Int,
                    state: BluetoothLeBroadcastReceiveState
                ) {
                    if (BluetoothUtils.isConnected(state)) {
                        launch { send(Unit) }
                    }
                }
                ) {}

                override fun onSourceRemoved(sink: BluetoothDevice, sourceId: Int, reason: Int) {
                    launch { send(Unit) }
@@ -55,7 +51,9 @@ val LocalBluetoothLeBroadcastAssistant.onSourceConnectedOrRemoved: Flow<Unit>

                override fun onSourceFound(source: BluetoothLeBroadcastMetadata) {}

                override fun onSourceAdded(sink: BluetoothDevice, sourceId: Int, reason: Int) {}
                override fun onSourceAdded(sink: BluetoothDevice, sourceId: Int, reason: Int) {
                    launch { send(Unit) }
                }

                override fun onSourceAddFailed(
                    sink: BluetoothDevice,