summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Soonil Nagarkar <sooniln@google.com> 2020-10-27 10:46:51 -0700
committer Soonil Nagarkar <sooniln@google.com> 2020-10-30 13:02:33 -0700
commit0773220f066f748d86c83babc67508bff43f299c (patch)
tree4887d72fae6d8bce60a9e3395ac2abffa543e695
parentb41548eb6b1bd6a48d5a542d6a22b8d603a816b7 (diff)
Add API for immutable PendingIntents
So PendingIntent users can determine if a PI is immutable or not. Bug: 171803518 Test: atest PendingIntentTest Change-Id: Ie45ef8b327c0bdf1232ca3ae28c7744cb6d3e83f
-rw-r--r--api/current.txt1
-rw-r--r--core/api/current.txt1
-rw-r--r--core/java/android/app/IActivityManager.aidl1
-rw-r--r--core/java/android/app/PendingIntent.java12
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java9
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;