summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java')
-rw-r--r--framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java b/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java
index 26978e3980..47f47bb8e3 100644
--- a/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java
+++ b/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java
@@ -25,6 +25,7 @@ import android.bluetooth.IBluetoothManager;
import android.bluetooth.annotations.RequiresBluetoothLocationPermission;
import android.bluetooth.annotations.RequiresBluetoothScanPermission;
import android.bluetooth.annotations.RequiresLegacyBluetoothAdminPermission;
+import android.content.AttributionSource;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
@@ -32,6 +33,7 @@ import android.util.Log;
import java.util.IdentityHashMap;
import java.util.Map;
+import java.util.Objects;
/**
* This class provides methods to perform periodic advertising related
@@ -54,8 +56,9 @@ public final class PeriodicAdvertisingManager {
private static final int SYNC_STARTING = -1;
+ private final BluetoothAdapter mBluetoothAdapter;
private final IBluetoothManager mBluetoothManager;
- private BluetoothAdapter mBluetoothAdapter;
+ private final AttributionSource mAttributionSource;
/* maps callback, to callback wrapper and sync handle */
Map<PeriodicAdvertisingCallback,
@@ -67,9 +70,10 @@ public final class PeriodicAdvertisingManager {
* @param bluetoothManager BluetoothManager that conducts overall Bluetooth Management.
* @hide
*/
- public PeriodicAdvertisingManager(IBluetoothManager bluetoothManager) {
- mBluetoothManager = bluetoothManager;
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ public PeriodicAdvertisingManager(BluetoothAdapter bluetoothAdapter) {
+ mBluetoothAdapter = Objects.requireNonNull(bluetoothAdapter);
+ mBluetoothManager = mBluetoothAdapter.getBluetoothManager();
+ mAttributionSource = mBluetoothAdapter.getAttributionSource();
mCallbackWrappers = new IdentityHashMap<>();
}
@@ -166,7 +170,8 @@ public final class PeriodicAdvertisingManager {
mCallbackWrappers.put(callback, wrapped);
try {
- gatt.registerSync(scanResult, skip, timeout, wrapped);
+ gatt.registerSync(
+ scanResult, skip, timeout, wrapped, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, "Failed to register sync - ", e);
return;
@@ -202,7 +207,7 @@ public final class PeriodicAdvertisingManager {
}
try {
- gatt.unregisterSync(wrapper);
+ gatt.unregisterSync(wrapper, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, "Failed to cancel sync creation - ", e);
return;