From 98f3044ce87c7ab9d2a0efbfb8ef6a16872262df Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 3 Jun 2021 09:26:53 -0600 Subject: 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 --- framework/java/android/bluetooth/BluetoothManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothManager.java') diff --git a/framework/java/android/bluetooth/BluetoothManager.java b/framework/java/android/bluetooth/BluetoothManager.java index b13ccaf7e5..c21362cd89 100644 --- a/framework/java/android/bluetooth/BluetoothManager.java +++ b/framework/java/android/bluetooth/BluetoothManager.java @@ -16,6 +16,8 @@ package android.bluetooth; +import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.RequiresFeature; import android.annotation.RequiresNoPermission; import android.annotation.RequiresPermission; @@ -24,6 +26,7 @@ import android.app.ActivityThread; import android.app.AppGlobals; import android.bluetooth.annotations.RequiresBluetoothConnectPermission; import android.bluetooth.annotations.RequiresLegacyBluetoothPermission; +import android.content.Attributable; import android.content.AttributionSource; import android.content.Context; import android.content.pm.PackageManager; @@ -71,7 +74,7 @@ public final class BluetoothManager { } /** {@hide} */ - public static AttributionSource resolveAttributionSource(Context context) { + public static @NonNull AttributionSource resolveAttributionSource(@Nullable Context context) { AttributionSource res = null; if (context != null) { res = context.getAttributionSource(); @@ -193,7 +196,7 @@ public final class BluetoothManager { IBluetoothManager managerService = mAdapter.getBluetoothManager(); IBluetoothGatt iGatt = managerService.getBluetoothGatt(); if (iGatt == null) return devices; - devices = BluetoothDevice.setAttributionSource( + devices = Attributable.setAttributionSource( iGatt.getDevicesMatchingConnectionStates(states, mAttributionSource), mAttributionSource); } catch (RemoteException e) { -- cgit v1.2.3