Merge "[Audiosharing] Update media devices section." into main

This commit is contained in:
Yiyi Shen
2023-12-06 12:03:06 +00:00
committed by Android (Google) Code Review
4 changed files with 320 additions and 86 deletions

View File

@@ -29,6 +29,7 @@ import com.android.settings.flags.Flags;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.utils.ThreadUtils;
@@ -298,4 +299,20 @@ public class AudioSharingUtils {
targetDevice.setActive();
}
}
/** Returns if the broadcast is on-going. */
public static boolean isBroadcasting(LocalBluetoothManager manager) {
if (manager == null) return false;
LocalBluetoothLeBroadcast broadcast =
manager.getProfileManager().getLeAudioBroadcastProfile();
return broadcast != null && broadcast.isEnabled(null);
}
/** Stops the latest broadcast. */
public static void stopBroadcasting(LocalBluetoothManager manager) {
if (manager == null) return;
LocalBluetoothLeBroadcast broadcast =
manager.getProfileManager().getLeAudioBroadcastProfile();
broadcast.stopBroadcast(broadcast.getLatestBroadcastId());
}
}