summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothGattServer.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2021-04-22 16:01:29 -0600
committerJeff Sharkey <jsharkey@android.com>2021-04-23 08:51:49 -0600
commitf9e176c3dcafb82f251a123751578539e3484deb (patch)
tree7bb1a868a15ea41eb01da5ae0d75752d4a945fb7 /framework/java/android/bluetooth/BluetoothGattServer.java
parent4dabcb764f1948823dcd74eefb3440afcab07db2 (diff)
More AttributionSource plumbing.
To prepare for future work which will plumb AttributionSource values through all remaining AIDLs, we need profiles to interact directly with the specific BluetoothAdapter they were created from. This is how we'll ensure that the relevant AttributionSource can be chained down from the original Context they're obtained from. This change also marks getDefaultAdapter() as deprecated to clearly communicate that BluetoothManager.getAdapter() is the best-practice path to obtaining a correctly scoped BluetoothAdapter instance. Bug: 183626112 Test: atest BluetoothInstrumentationTests Change-Id: I1e15170d7679019bbb6e396279d6e633e3dad4d6
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothGattServer.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothGattServer.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/framework/java/android/bluetooth/BluetoothGattServer.java b/framework/java/android/bluetooth/BluetoothGattServer.java
index e28006aac3..3e799defa5 100644
--- a/framework/java/android/bluetooth/BluetoothGattServer.java
+++ b/framework/java/android/bluetooth/BluetoothGattServer.java
@@ -46,11 +46,12 @@ public final class BluetoothGattServer implements BluetoothProfile {
private static final boolean DBG = true;
private static final boolean VDBG = false;
- private BluetoothAdapter mAdapter;
- private IBluetoothGatt mService;
- private BluetoothGattServerCallback mCallback;
+ private final IBluetoothGatt mService;
+ private final BluetoothAdapter mAdapter;
private final AttributionSource mAttributionSource;
+ private BluetoothGattServerCallback mCallback;
+
private Object mServerIfLock = new Object();
private int mServerIf;
private int mTransport;
@@ -384,15 +385,15 @@ public final class BluetoothGattServer implements BluetoothProfile {
/**
* Create a BluetoothGattServer proxy object.
*/
- /*package*/ BluetoothGattServer(
- IBluetoothGatt iGatt, int transport, AttributionSource attributionSource) {
+ /* package */ BluetoothGattServer(IBluetoothGatt iGatt, int transport,
+ BluetoothAdapter adapter) {
mService = iGatt;
- mAdapter = BluetoothAdapter.getDefaultAdapter();
+ mAdapter = adapter;
+ mAttributionSource = adapter.getAttributionSource();
mCallback = null;
mServerIf = 0;
mTransport = transport;
mServices = new ArrayList<BluetoothGattService>();
- mAttributionSource = attributionSource;
}
/**