summaryrefslogtreecommitdiff
path: root/core/java/android/bluetooth/BluetoothDevice.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
commitefe1110be8712d497edc39f7559e31d83abc8e6a (patch)
tree65164f0a8de377915ac722b3a74073b1d0b57903 /core/java/android/bluetooth/BluetoothDevice.java
parent52f8d4c9c3e4df1acc3db2b85314ae4a1a9ec6b9 (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 'core/java/android/bluetooth/BluetoothDevice.java')
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 5eca947931dc..c700a10f3a03 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -24,7 +24,6 @@ import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
-import android.app.ActivityThread;
import android.app.PropertyInvalidatedCache;
import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
import android.bluetooth.annotations.RequiresBluetoothLocationPermission;
@@ -48,6 +47,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.List;
import java.util.UUID;
/**
@@ -1167,13 +1167,29 @@ public final class BluetoothDevice implements Parcelable {
mAddress = address;
mAddressType = ADDRESS_TYPE_PUBLIC;
- mAttributionSource = ActivityThread.currentAttributionSource();
+ mAttributionSource = BluetoothManager.resolveAttributionSource(null);
}
void setAttributionSource(AttributionSource attributionSource) {
mAttributionSource = attributionSource;
}
+ static BluetoothDevice setAttributionSource(BluetoothDevice device,
+ AttributionSource attributionSource) {
+ device.setAttributionSource(attributionSource);
+ return device;
+ }
+
+ static List<BluetoothDevice> setAttributionSource(List<BluetoothDevice> devices,
+ AttributionSource attributionSource) {
+ if (devices != null) {
+ for (BluetoothDevice device : devices) {
+ device.setAttributionSource(attributionSource);
+ }
+ }
+ return devices;
+ }
+
@Override
public boolean equals(@Nullable Object o) {
if (o instanceof BluetoothDevice) {