diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-10-26 16:39:19 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-26 16:39:19 +0000 |
| commit | bbd05d765e4bd5bc22baf74c5c087048d4b2ca8b (patch) | |
| tree | ffd9df67690b5d617228e81dcea620988586b511 /core/java/android | |
| parent | cff20397e7e257b8bc493b795b3e717b9563a4fd (diff) | |
| parent | 92bf843da4699256bb062182c1d08b41b09397b1 (diff) | |
Merge "Revert "Removed BluetoothDevice#prepareToEnterProcess"" am: 168b5655a4 am: a3b55d5079 am: 170597987c am: fddbf6e930 am: 92bf843da4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1869964
Change-Id: Ib926a6c45bead4e50de93a371b97bfadad2a9fb0
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothDevice.java | 5 | ||||
| -rw-r--r-- | core/java/android/bluetooth/BluetoothManager.java | 13 | ||||
| -rw-r--r-- | core/java/android/content/Intent.java | 11 |
3 files changed, 21 insertions, 8 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index e968052ff5cf..6e918bd6243d 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 6446b44153ec..e838d93c6cdc 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -32,6 +32,7 @@ import android.annotation.SystemApi; import android.annotation.TestApi; import android.app.ActivityThread; import android.app.AppGlobals; +import android.bluetooth.BluetoothDevice; import android.compat.annotation.UnsupportedAppUsage; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; @@ -11688,6 +11689,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 */ |
