summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothMap.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2021-04-23 14:13:57 -0600
committerJeff Sharkey <jsharkey@android.com>2021-04-24 08:31:43 -0600
commit43ee69eed974cd7ebc4784416a6e1e251464cc36 (patch)
tree8bea2d1eff66be08849c3ce5f147d3d99b749e80 /framework/java/android/bluetooth/BluetoothMap.java
parentf9e176c3dcafb82f251a123751578539e3484deb (diff)
Long-tail of AttributionSource plumbing.
Wires up AttributionSource across the remaining long-tail of Bluetooth AIDL interfaces, ensuring that developers can accurately make calls chained back to a specific Context. Moves "for data delivery" permission checks to happen in a single location on each interface to ensure they're performed consistently with the new AttributionSource arguments. Note that "for data delivery" isn't the best name; it's designed to represent that the requested action was performed and should result in the relevant appop being noted for the caller. This change has the positive side effect of ensuring that all interfaces are consistently enforcing the BLUETOOTH_CONNECT permission, even in the case where BLUETOOTH_PRIVILEGED is also required; this is what ensures that revoking the "Nearby devices" permission takes effect for all callers. Additionally, standardizing on enforcing permissions closer to the AIDL entry point reduces the need for @RequiresPermission annotations to be carried around inside the Bluetooth stack. Bug: 183626112 Test: atest BluetoothInstrumentationTests Change-Id: I8023dda654e325b8bfa2f0cdb994ad63a2b429d4
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothMap.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothMap.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/framework/java/android/bluetooth/BluetoothMap.java b/framework/java/android/bluetooth/BluetoothMap.java
index 68bb60a854..88505b51f8 100644
--- a/framework/java/android/bluetooth/BluetoothMap.java
+++ b/framework/java/android/bluetooth/BluetoothMap.java
@@ -144,7 +144,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
final IBluetoothMap service = getService();
if (service != null) {
try {
- return service.getState();
+ return service.getState(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -170,7 +170,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
final IBluetoothMap service = getService();
if (service != null) {
try {
- return service.getClient();
+ return service.getClient(mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -195,7 +195,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
final IBluetoothMap service = getService();
if (service != null) {
try {
- return service.isConnected(device);
+ return service.isConnected(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -234,7 +234,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
final IBluetoothMap service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.disconnect(device);
+ return service.disconnect(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return false;
@@ -286,7 +286,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
if (service != null && isEnabled()) {
try {
return BluetoothDevice.setAttributionSource(
- service.getConnectedDevices(), mAttributionSource);
+ service.getConnectedDevices(mAttributionSource), mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
@@ -311,7 +311,8 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
if (service != null && isEnabled()) {
try {
return BluetoothDevice.setAttributionSource(
- service.getDevicesMatchingConnectionStates(states), mAttributionSource);
+ service.getDevicesMatchingConnectionStates(states, mAttributionSource),
+ mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return new ArrayList<BluetoothDevice>();
@@ -335,7 +336,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
final IBluetoothMap service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.getConnectionState(device);
+ return service.getConnectionState(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return BluetoothProfile.STATE_DISCONNECTED;
@@ -394,7 +395,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
return false;
}
try {
- return service.setConnectionPolicy(device, connectionPolicy);
+ return service.setConnectionPolicy(device, connectionPolicy, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return false;
@@ -446,7 +447,7 @@ public final class BluetoothMap implements BluetoothProfile, AutoCloseable {
final IBluetoothMap service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
try {
- return service.getConnectionPolicy(device);
+ return service.getConnectionPolicy(device, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, Log.getStackTraceString(new Throwable()));
return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;