[Nearby]Fix sometimes can't stop the previous advertising
Change-Id: I5d9e77ebc837d33ac07f9fc408afe6cacefb6547
This commit is contained in:
parent
8231494aaa
commit
7354a4aa55
1 changed files with 8 additions and 0 deletions
|
|
@ -89,6 +89,9 @@ public class BleBroadcastProvider extends AdvertiseCallback {
|
|||
break;
|
||||
case BroadcastRequest.PRESENCE_VERSION_V1:
|
||||
if (adapter.isLeExtendedAdvertisingSupported()) {
|
||||
if (mAdvertisingSetCallback == null) {
|
||||
mAdvertisingSetCallback = getAdvertisingSetCallback();
|
||||
}
|
||||
bluetoothLeAdvertiser.startAdvertisingSet(
|
||||
getAdvertisingSetParameters(),
|
||||
advertiseData,
|
||||
|
|
@ -133,6 +136,11 @@ public class BleBroadcastProvider extends AdvertiseCallback {
|
|||
}
|
||||
mBroadcastListener = null;
|
||||
mIsAdvertising = false;
|
||||
// If called startAdvertisingSet() but onAdvertisingSetStopped() is not invoked yet,
|
||||
// using the same mAdvertisingSetCallback will cause new advertising cann't be stopped.
|
||||
// Therefore, release the old mAdvertisingSetCallback and
|
||||
// create a new mAdvertisingSetCallback when calling startAdvertisingSet.
|
||||
mAdvertisingSetCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue