diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2021-05-07 10:28:59 -0600 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2021-05-15 09:48:14 -0600 |
| commit | dd6dd3b1fbd512193c00da71c925b3e1003fd572 (patch) | |
| tree | c4d787b7d7f0cf4d9f27a6ecaf40aca805942bc2 /core/java/android/content/Intent.java | |
| parent | 3bf189f78b09fcd1be04146945d81c52c5c30e87 (diff) | |
Apply AttributionSource during Intent delivery.
There are some Parcelables which offer to perform Binder calls, and
when these are delivered via Intent extras they fallback to
ActivityThread.currentAttributionSource(), instead of being tagged
based on the relevant app component.
This change begins using Intent.prepareToEnterProcess() as a hook to
fix-up AttributionSource when those extras finally land in the
destination process. It uses the relevant AttributionSource based
on the Activity or Service the Intent is delivered to, which
developers have control over via AppComponentFactory.
In the case of <receiver> manifest elements, this change applies the
first android:attributionTags value to the Context used for that
BroadcastReceiver.
Bug: 187097694
Test: atest AttributionTest
Change-Id: I8f5197db7e8d7277d34f0ef2bb90bfdf1871186a
Diffstat (limited to 'core/java/android/content/Intent.java')
| -rw-r--r-- | core/java/android/content/Intent.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index bbb49fb2b8ed..bacb773a4746 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; @@ -11439,7 +11440,7 @@ public class Intent implements Parcelable, Cloneable { /** * @hide */ - public void prepareToEnterProcess(boolean fromProtectedComponent) { + public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) { // We just entered destination process, so we should be able to read all // parcelables inside. setDefusable(true); @@ -11447,10 +11448,10 @@ public class Intent implements Parcelable, Cloneable { if (mSelector != null) { // We can't recursively claim that this data is from a protected // component, since it may have been filled in by a malicious app - mSelector.prepareToEnterProcess(false); + mSelector.prepareToEnterProcess(false, source); } if (mClipData != null) { - mClipData.prepareToEnterProcess(); + mClipData.prepareToEnterProcess(source); } if (mContentUserHint != UserHandle.USER_CURRENT) { @@ -11463,6 +11464,14 @@ 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); + device.prepareToEnterProcess(source); + } } /** @hide */ |
