From 35b447ff1a57c2694c59d5b9206ca00465d422c1 Mon Sep 17 00:00:00 2001 From: SongFerngWang Date: Tue, 20 Jun 2023 18:58:59 +0800 Subject: [PATCH] [Broadcast] Stop the searching of broadcast - When the user leaves the page, stop the searching - After the buds are added into broadcast, then stop the searching Bug: 287136134 Test: build pass. manually testing Change-Id: I6b680fa4a2ca4b1df397bbbd1e5e129ec787912a --- .../LocalBluetoothLeBroadcastAssistant.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java index b0392be9d3361..bb103b8896fd3 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothLeBroadcastAssistant.java @@ -220,6 +220,27 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile return mService.isSearchInProgress(); } + /** + * Stops an ongoing search for nearby Broadcast Sources. + * + * On success, {@link BluetoothLeBroadcastAssistant.Callback#onSearchStopped(int)} will be + * called with reason code {@link BluetoothStatusCodes#REASON_LOCAL_APP_REQUEST}. + * On failure, {@link BluetoothLeBroadcastAssistant.Callback#onSearchStopFailed(int)} will be + * called with reason code + * + * @throws IllegalStateException if callback was not registered + */ + public void stopSearchingForSources() { + if (DEBUG) { + Log.d(TAG, "stopSearchingForSources()"); + } + if (mService == null) { + Log.d(TAG, "The BluetoothLeBroadcastAssistant is null"); + return; + } + mService.stopSearchingForSources(); + } + /** * Get information about all Broadcast Sources that a Broadcast Sink knows about. *