summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorPaul Hu <paulhu@google.com>2021-03-09 10:55:00 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-03-09 10:55:00 +0000
commit687da317add67d40a8ae6a027d5a538d1fb09395 (patch)
treeb7295a75980425216087dc8978d2507761504559 /core/java
parent456069019eb4da612ddf5c32a927797750e2847e (diff)
parent514881581d1a73b1dce83dbe38fe3a6c5d54b42b (diff)
Merge "New API for comparing two intents of PendingIntent object."
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/PendingIntent.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index 41cac75cbd75..c89b53e2c415 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -19,6 +19,9 @@ package android.app;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
+import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.IIntentReceiver;
@@ -1171,6 +1174,30 @@ public final class PendingIntent implements Parcelable {
}
/**
+ * Comparison operator on two PendingIntent objects, such that true is returned when they
+ * represent {@link Intent}s that are equal as per {@link Intent#filterEquals}.
+ *
+ * @param other The other PendingIntent to compare against.
+ * @return True if action, data, type, class, and categories on two intents are the same.
+ *
+ * @hide
+ */
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
+ @TestApi
+ @RequiresPermission(android.Manifest.permission.GET_INTENT_SENDER_INTENT)
+ public boolean intentFilterEquals(@Nullable PendingIntent other) {
+ if (other == null) {
+ return false;
+ }
+ try {
+ return ActivityManager.getService().getIntentForIntentSender(other.mTarget)
+ .filterEquals(getIntent());
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Comparison operator on two PendingIntent objects, such that true
* is returned then they both represent the same operation from the
* same package. This allows you to use {@link #getActivity},