summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-10-26 15:32:33 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-10-26 15:32:33 +0000
commit168b5655a4216d40787789f0035a682a701be17a (patch)
tree4d0331e125823956aa33580efc1b12b934d7966f
parent56e85bb8c0066f7de467ebb25bd3cfc93d4dbcb5 (diff)
parent255c70fbbcf9f4521cbc8dad7f8a7f16c7c0e305 (diff)
Merge "Revert "Removed BluetoothDevice#prepareToEnterProcess""
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java5
-rw-r--r--core/java/android/bluetooth/BluetoothManager.java13
-rw-r--r--core/java/android/content/Intent.java11
3 files changed, 21 insertions, 8 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 9caeb297ace3..c71fcc637cb9 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -1186,6 +1186,11 @@ public final class BluetoothDevice implements Parcelable, Attributable {
mAttributionSource = attributionSource;
}
+ /** {@hide} */
+ public void prepareToEnterProcess(@NonNull AttributionSource attributionSource) {
+ setAttributionSource(attributionSource);
+ }
+
@Override
public boolean equals(@Nullable Object o) {
if (o instanceof BluetoothDevice) {
diff --git a/core/java/android/bluetooth/BluetoothManager.java b/core/java/android/bluetooth/BluetoothManager.java
index b5df4db2460d..20152f3d2471 100644
--- a/core/java/android/bluetooth/BluetoothManager.java
+++ b/core/java/android/bluetooth/BluetoothManager.java
@@ -62,15 +62,15 @@ public final class BluetoothManager {
private static final String TAG = "BluetoothManager";
private static final boolean DBG = false;
- private static AttributionSource sAttributionSource = null;
+ private final AttributionSource mAttributionSource;
private final BluetoothAdapter mAdapter;
/**
* @hide
*/
public BluetoothManager(Context context) {
- sAttributionSource = resolveAttributionSource(context);
- mAdapter = BluetoothAdapter.createAdapter(sAttributionSource);
+ mAttributionSource = resolveAttributionSource(context);
+ mAdapter = BluetoothAdapter.createAdapter(mAttributionSource);
}
/** {@hide} */
@@ -79,9 +79,6 @@ public final class BluetoothManager {
if (context != null) {
res = context.getAttributionSource();
}
- else if (sAttributionSource != null) {
- return sAttributionSource;
- }
if (res == null) {
res = ActivityThread.currentAttributionSource();
}
@@ -201,8 +198,8 @@ public final class BluetoothManager {
IBluetoothGatt iGatt = managerService.getBluetoothGatt();
if (iGatt == null) return devices;
devices = Attributable.setAttributionSource(
- iGatt.getDevicesMatchingConnectionStates(states, sAttributionSource),
- sAttributionSource);
+ iGatt.getDevicesMatchingConnectionStates(states, mAttributionSource),
+ mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, "", e);
}
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 2fd437db14a7..d811040b6bb2 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -31,6 +31,7 @@ import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.AppGlobals;
+import android.bluetooth.BluetoothDevice;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
@@ -11461,6 +11462,16 @@ public class Intent implements Parcelable, Cloneable {
if (fromProtectedComponent) {
mLocalFlags |= LOCAL_FLAG_FROM_PROTECTED_COMPONENT;
}
+
+ // Special attribution fix-up logic for any BluetoothDevice extras
+ // passed via Bluetooth intents
+ if (mAction != null && mAction.startsWith("android.bluetooth.")
+ && hasExtra(BluetoothDevice.EXTRA_DEVICE)) {
+ final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ if (device != null) {
+ device.prepareToEnterProcess(source);
+ }
+ }
}
/** @hide */