summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/IActivityManager.aidl6
-rw-r--r--core/java/android/app/PendingIntent.java52
2 files changed, 51 insertions, 7 deletions
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index 0019fd1908b3..e73636fe7fd0 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -51,6 +51,7 @@ import android.content.pm.ConfigurationInfo;
import android.content.pm.IPackageDataObserver;
import android.content.pm.ParceledListSlice;
import android.content.pm.ProviderInfo;
+import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.content.LocusId;
@@ -704,4 +705,9 @@ interface IActivityManager {
* @throws IllegalArgumentException if the user is not a profile.
*/
boolean stopProfile(int userId);
+
+ /** Called by PendingIntent.queryIntentComponents() */
+ List<ResolveInfo> queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags);
+
+ boolean isIntentSenderAService(in IIntentSender sender);
}
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index 269ccb169774..3ce6488904cc 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -16,9 +16,13 @@
package android.app;
+import android.Manifest.permission;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
+import android.annotation.SystemApi;
+import android.annotation.SystemApi.Client;
import android.annotation.TestApi;
import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
@@ -29,6 +33,8 @@ import android.content.IIntentReceiver;
import android.content.IIntentSender;
import android.content.Intent;
import android.content.IntentSender;
+import android.content.pm.PackageManager.ResolveInfoFlags;
+import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -46,6 +52,7 @@ import com.android.internal.os.IResultReceiver;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.List;
/**
* A description of an Intent and target action to perform with it. Instances
@@ -1168,10 +1175,9 @@ public final class PendingIntent implements Parcelable {
}
/**
- * @hide
- * Check whether this PendingIntent will launch an Activity.
+ * @return TRUE if this {@link PendingIntent} was created with
+ * {@link #getActivity} or {@link #getActivities}.
*/
- @UnsupportedAppUsage
public boolean isActivity() {
try {
return ActivityManager.getService()
@@ -1182,8 +1188,7 @@ public final class PendingIntent implements Parcelable {
}
/**
- * @hide
- * Check whether this PendingIntent will launch a foreground service
+ * @return TRUE if this {@link PendingIntent} was created with {@link #getForegroundService}.
*/
public boolean isForegroundService() {
try {
@@ -1195,8 +1200,19 @@ public final class PendingIntent implements Parcelable {
}
/**
- * @hide
- * Check whether this PendingIntent will launch an Activity.
+ * @return TRUE if this {@link PendingIntent} was created with {@link #getService}.
+ */
+ public boolean isService() {
+ try {
+ return ActivityManager.getService()
+ .isIntentSenderAService(mTarget);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * @return TRUE if this {@link PendingIntent} was created with {@link #getBroadcast}.
*/
public boolean isBroadcast() {
try {
@@ -1236,6 +1252,28 @@ public final class PendingIntent implements Parcelable {
}
/**
+ * Resolve the intent set in this {@link PendingIntent}. Note if the pending intent is
+ * generated for another user, the resulting component may not exist on the calling user.
+ * Use {@link android.content.pm.ApplicationInfo#uid} of the resulting
+ * {@link android.content.pm.ComponentInfo} with
+ * {@link android.os.UserHandle#getUserHandleForUid(int)} to see which user will receive
+ * the intent.
+ *
+ * @param flags MATCH_* flags from {@link android.content.pm.PackageManager}.
+ * @hide
+ */
+ @RequiresPermission(permission.GET_INTENT_SENDER_INTENT)
+ @SystemApi(client = Client.MODULE_LIBRARIES)
+ public @Nullable List<ResolveInfo> queryIntentComponents(@ResolveInfoFlags int flags) {
+ try {
+ return ActivityManager.getService()
+ .queryIntentComponentsForIntentSender(mTarget, flags);
+ } 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},