summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothPbapClient.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@google.com>2021-04-23 19:38:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-04-23 19:38:54 +0000
commit995557650f13f2ee98a4bdeaa8096c78658ef1b1 (patch)
tree0bca20468489fa6064bd73e4a720cc013c4fa12a /framework/java/android/bluetooth/BluetoothPbapClient.java
parent26a3a23d4c105c5ccd1b98ce0f83b21ee3b1ffe4 (diff)
parentf9e176c3dcafb82f251a123751578539e3484deb (diff)
Merge changes from topic "btapiattribution" into sc-dev
* changes: More AttributionSource plumbing. Pass attribution source to BT APIs.
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothPbapClient.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothPbapClient.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/framework/java/android/bluetooth/BluetoothPbapClient.java b/framework/java/android/bluetooth/BluetoothPbapClient.java
index 7f4863891e..d9c69f0fcc 100644
--- a/framework/java/android/bluetooth/BluetoothPbapClient.java
+++ b/framework/java/android/bluetooth/BluetoothPbapClient.java
@@ -23,6 +23,7 @@ import android.annotation.SdkConstant;
import android.annotation.SuppressLint;
import android.annotation.SdkConstant.SdkConstantType;
import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
+import android.content.AttributionSource;
import android.content.Context;
import android.os.Binder;
import android.os.IBinder;
@@ -57,7 +58,8 @@ public final class BluetoothPbapClient implements BluetoothProfile {
/** Connection canceled before completion. */
public static final int RESULT_CANCELED = 2;
- private BluetoothAdapter mAdapter;
+ private final BluetoothAdapter mAdapter;
+ private final AttributionSource mAttributionSource;
private final BluetoothProfileConnector<IBluetoothPbapClient> mProfileConnector =
new BluetoothProfileConnector(this, BluetoothProfile.PBAP_CLIENT,
"BluetoothPbapClient", IBluetoothPbapClient.class.getName()) {
@@ -70,11 +72,12 @@ public final class BluetoothPbapClient implements BluetoothProfile {
/**
* Create a BluetoothPbapClient proxy object.
*/
- BluetoothPbapClient(Context context, ServiceListener listener) {
+ BluetoothPbapClient(Context context, ServiceListener listener, BluetoothAdapter adapter) {
if (DBG) {
Log.d(TAG, "Create BluetoothPbapClient proxy object");
}
- mAdapter = BluetoothAdapter.getDefaultAdapter();
+ mAdapter = adapter;
+ mAttributionSource = adapter.getAttributionSource();
mProfileConnector.connect(context, listener);
}
@@ -176,7 +179,8 @@ public final class BluetoothPbapClient implements BluetoothProfile {
final IBluetoothPbapClient service = getService();
if (service != null && isEnabled()) {
try {
- return service.getConnectedDevices();
+ return BluetoothDevice.setAttributionSource(
+ service.getConnectedDevices(), mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
@@ -203,7 +207,8 @@ public final class BluetoothPbapClient implements BluetoothProfile {
final IBluetoothPbapClient service = getService();
if (service != null && isEnabled()) {
try {
- return service.getDevicesMatchingConnectionStates(states);
+ return BluetoothDevice.setAttributionSource(
+ service.getDevicesMatchingConnectionStates(states), mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
@@ -247,12 +252,7 @@ public final class BluetoothPbapClient implements BluetoothProfile {
}
private boolean isEnabled() {
- BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
- if (adapter != null && adapter.getState() == BluetoothAdapter.STATE_ON) {
- return true;
- }
- log("Bluetooth is Not enabled");
- return false;
+ return mAdapter.isEnabled();
}
private static boolean isValidDevice(BluetoothDevice device) {