diff options
| author | 2021-01-28 16:00:56 +0000 | |
|---|---|---|
| committer | 2021-01-28 16:00:56 +0000 | |
| commit | 6ac99deae2afc3c479248f32b4537fafe87bf5ca (patch) | |
| tree | c19e1ee7af729e320bd3479ce7fb2144c0215cf1 | |
| parent | df3efebc7f95431b11198b2ed0883943ffa14042 (diff) | |
| parent | 896cf5eb7f063a51742c7a99610a03bf14680fe2 (diff) | |
Merge "Provide API to access Intent that triggered StrictMode violation" into sc-dev am: f47f057530 am: 896cf5eb7f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13423029
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Ie16ead94d06e033a490cb09d7ed34c722098d55b
| -rw-r--r-- | core/api/current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/os/strictmode/UnsafeIntentLaunchViolation.java | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index ba93c129d4fb..c454666d52d9 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -31896,6 +31896,8 @@ package android.os.strictmode { } public final class UnsafeIntentLaunchViolation extends android.os.strictmode.Violation { + ctor public UnsafeIntentLaunchViolation(@NonNull android.content.Intent); + method @Nullable public android.content.Intent getIntent(); } public final class UntaggedSocketViolation extends android.os.strictmode.Violation { diff --git a/core/java/android/os/strictmode/UnsafeIntentLaunchViolation.java b/core/java/android/os/strictmode/UnsafeIntentLaunchViolation.java index 891fb59326df..f0f3cef656f0 100644 --- a/core/java/android/os/strictmode/UnsafeIntentLaunchViolation.java +++ b/core/java/android/os/strictmode/UnsafeIntentLaunchViolation.java @@ -17,10 +17,13 @@ package android.os.strictmode; import android.annotation.NonNull; +import android.annotation.Nullable; import android.app.PendingIntent; import android.content.Intent; import android.net.Uri; +import java.util.Objects; + /** * Violation raised when your app launches an {@link Intent} which originated * from outside your app. @@ -46,8 +49,20 @@ import android.net.Uri; * not protected, your app is likely vulnerable to malicious apps. */ public final class UnsafeIntentLaunchViolation extends Violation { - /** @hide */ + private transient Intent mIntent; + public UnsafeIntentLaunchViolation(@NonNull Intent intent) { super("Launch of unsafe intent: " + intent); + mIntent = Objects.requireNonNull(intent); + } + + /** + * Return the {@link Intent} which caused this violation to be raised. Note + * that this value is not available if this violation has been serialized + * since intents cannot be serialized. + */ + @SuppressWarnings("IntentBuilderName") + public @Nullable Intent getIntent() { + return mIntent; } } |