diff options
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/app/IActivityManager.aidl | 1 | ||||
| -rw-r--r-- | core/java/android/app/PendingIntent.java | 12 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 9 |
5 files changed, 24 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 9ff7cc255bf4..65f3370c0399 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6138,6 +6138,7 @@ package android.app { method public android.content.IntentSender getIntentSender(); method public static android.app.PendingIntent getService(android.content.Context, int, @NonNull android.content.Intent, int); method @Deprecated public String getTargetPackage(); + method public boolean isImmutable(); method @Nullable public static android.app.PendingIntent readPendingIntentOrNullFromParcel(@NonNull android.os.Parcel); method public void send() throws android.app.PendingIntent.CanceledException; method public void send(int) throws android.app.PendingIntent.CanceledException; diff --git a/core/api/current.txt b/core/api/current.txt index 16a5f5e82f21..083dd038e462 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -6138,6 +6138,7 @@ package android.app { method public android.content.IntentSender getIntentSender(); method public static android.app.PendingIntent getService(android.content.Context, int, @NonNull android.content.Intent, int); method @Deprecated public String getTargetPackage(); + method public boolean isImmutable(); method @Nullable public static android.app.PendingIntent readPendingIntentOrNullFromParcel(@NonNull android.os.Parcel); method public void send() throws android.app.PendingIntent.CanceledException; method public void send(int) throws android.app.PendingIntent.CanceledException; diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index 879d4373f964..560b5be264d6 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -342,6 +342,7 @@ interface IActivityManager { @UnsupportedAppUsage void unregisterProcessObserver(in IProcessObserver observer); boolean isIntentSenderTargetedToPackage(in IIntentSender sender); + boolean isIntentSenderImmutable(in IIntentSender sender); @UnsupportedAppUsage void updatePersistentConfiguration(in Configuration values); void updatePersistentConfigurationWithAttribution(in Configuration values, diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java index 21dfbbd6f15d..f76a75749480 100644 --- a/core/java/android/app/PendingIntent.java +++ b/core/java/android/app/PendingIntent.java @@ -1145,6 +1145,18 @@ public final class PendingIntent implements Parcelable { } /** + * Check if this PendingIntent is marked with {@link #FLAG_IMMUTABLE}. + */ + public boolean isImmutable() { + try { + return ActivityManager.getService() + .isIntentSenderImmutable(mTarget); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * @hide * Check whether this PendingIntent will launch an Activity. */ diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 112814c69d9b..081493752e31 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -4890,6 +4890,15 @@ public class ActivityManagerService extends IActivityManager.Stub } @Override + public boolean isIntentSenderImmutable(IIntentSender pendingResult) { + if (pendingResult instanceof PendingIntentRecord) { + final PendingIntentRecord res = (PendingIntentRecord) pendingResult; + return (res.key.flags & PendingIntent.FLAG_IMMUTABLE) != 0; + } + return false; + } + + @Override public boolean isIntentSenderAnActivity(IIntentSender pendingResult) { if (!(pendingResult instanceof PendingIntentRecord)) { return false; |