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: I305a9c6ba8cca1bd5c3c0e1d78ad4a84f9a155b7
This commit is contained in:
SongFerngWang
2023-06-20 19:19:16 +08:00
committed by SongFerng Wang
parent ca2d241193
commit dbe58e96dc

View File

@@ -125,6 +125,10 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment
Log.w(TAG, "onSourceAdded: mSelectedPreference == null!"); Log.w(TAG, "onSourceAdded: mSelectedPreference == null!");
return; return;
} }
if (mLeBroadcastAssistant != null
&& mLeBroadcastAssistant.isSearchInProgress()) {
mLeBroadcastAssistant.stopSearchingForSources();
}
getActivity().runOnUiThread(() -> updateListCategoryFromBroadcastMetadata( getActivity().runOnUiThread(() -> updateListCategoryFromBroadcastMetadata(
mSelectedPreference.getBluetoothLeBroadcastMetadata(), true)); mSelectedPreference.getBluetoothLeBroadcastMetadata(), true));
} }
@@ -232,6 +236,9 @@ public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment
public void onStop() { public void onStop() {
super.onStop(); super.onStop();
if (mLeBroadcastAssistant != null) { if (mLeBroadcastAssistant != null) {
if (mLeBroadcastAssistant.isSearchInProgress()) {
mLeBroadcastAssistant.stopSearchingForSources();
}
mLeBroadcastAssistant.unregisterServiceCallBack(mBroadcastAssistantCallback); mLeBroadcastAssistant.unregisterServiceCallBack(mBroadcastAssistantCallback);
} }
} }