summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothHidDevice.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2021-06-03 09:26:53 -0600
committerJeff Sharkey <jsharkey@android.com>2021-06-03 12:14:17 -0600
commit98f3044ce87c7ab9d2a0efbfb8ef6a16872262df (patch)
tree2f734517e7538b0509c34657c49522518d51f4a1 /framework/java/android/bluetooth/BluetoothHidDevice.java
parent0cc9fe2cb3763a0f76e3d6078724edc73c3a9a40 (diff)
More Binder call AttributionSource assignment.
Since developers can use a BluetoothDevice object can make remote calls, it needs to have an accurate AttributionSource. Previous CLs had updated many places where these BluetoothDevice instances were passed across Binder interfaces, but this change updates several remaining locations which had been missed. Introduces new "Attributable" marker interface to offer consistent tooling when applying AttributionSource updates. Bug: 187097694 Test: atest BluetoothInstrumentationTests Change-Id: Icad3b9726591f0fbad58a493cefa5a0af7648280
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHidDevice.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothHidDevice.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHidDevice.java b/framework/java/android/bluetooth/BluetoothHidDevice.java
index 11e5711eff..c2744b89aa 100644
--- a/framework/java/android/bluetooth/BluetoothHidDevice.java
+++ b/framework/java/android/bluetooth/BluetoothHidDevice.java
@@ -20,11 +20,11 @@ import android.Manifest;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
-import android.annotation.SuppressLint;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.SystemApi;
import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
import android.bluetooth.annotations.RequiresLegacyBluetoothPermission;
-import android.annotation.SystemApi;
+import android.content.Attributable;
import android.content.AttributionSource;
import android.content.Context;
import android.os.Binder;
@@ -339,14 +339,17 @@ public final class BluetoothHidDevice implements BluetoothProfile {
private final Executor mExecutor;
private final Callback mCallback;
+ private final AttributionSource mAttributionSource;
- CallbackWrapper(Executor executor, Callback callback) {
+ CallbackWrapper(Executor executor, Callback callback, AttributionSource attributionSource) {
mExecutor = executor;
mCallback = callback;
+ mAttributionSource = attributionSource;
}
@Override
public void onAppStatusChanged(BluetoothDevice pluggedDevice, boolean registered) {
+ Attributable.setAttributionSource(pluggedDevice, mAttributionSource);
final long token = clearCallingIdentity();
try {
mExecutor.execute(() -> mCallback.onAppStatusChanged(pluggedDevice, registered));
@@ -357,6 +360,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
@Override
public void onConnectionStateChanged(BluetoothDevice device, int state) {
+ Attributable.setAttributionSource(device, mAttributionSource);
final long token = clearCallingIdentity();
try {
mExecutor.execute(() -> mCallback.onConnectionStateChanged(device, state));
@@ -367,6 +371,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
@Override
public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) {
+ Attributable.setAttributionSource(device, mAttributionSource);
final long token = clearCallingIdentity();
try {
mExecutor.execute(() -> mCallback.onGetReport(device, type, id, bufferSize));
@@ -377,6 +382,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
@Override
public void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data) {
+ Attributable.setAttributionSource(device, mAttributionSource);
final long token = clearCallingIdentity();
try {
mExecutor.execute(() -> mCallback.onSetReport(device, type, id, data));
@@ -387,6 +393,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
@Override
public void onSetProtocol(BluetoothDevice device, byte protocol) {
+ Attributable.setAttributionSource(device, mAttributionSource);
final long token = clearCallingIdentity();
try {
mExecutor.execute(() -> mCallback.onSetProtocol(device, protocol));
@@ -397,6 +404,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
@Override
public void onInterruptData(BluetoothDevice device, byte reportId, byte[] data) {
+ Attributable.setAttributionSource(device, mAttributionSource);
final long token = clearCallingIdentity();
try {
mExecutor.execute(() -> mCallback.onInterruptData(device, reportId, data));
@@ -407,6 +415,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
@Override
public void onVirtualCableUnplug(BluetoothDevice device) {
+ Attributable.setAttributionSource(device, mAttributionSource);
final long token = clearCallingIdentity();
try {
mExecutor.execute(() -> mCallback.onVirtualCableUnplug(device));
@@ -449,7 +458,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
final IBluetoothHidDevice service = getService();
if (service != null) {
try {
- return BluetoothDevice.setAttributionSource(
+ return Attributable.setAttributionSource(
service.getConnectedDevices(mAttributionSource), mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
@@ -469,7 +478,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
final IBluetoothHidDevice service = getService();
if (service != null) {
try {
- return BluetoothDevice.setAttributionSource(
+ return Attributable.setAttributionSource(
service.getDevicesMatchingConnectionStates(states, mAttributionSource),
mAttributionSource);
} catch (RemoteException e) {
@@ -549,7 +558,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
final IBluetoothHidDevice service = getService();
if (service != null) {
try {
- CallbackWrapper cbw = new CallbackWrapper(executor, callback);
+ CallbackWrapper cbw = new CallbackWrapper(executor, callback, mAttributionSource);
result = service.registerApp(sdp, inQos, outQos, cbw, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString());