Loading core/java/android/app/ActivityManager.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; package android.app; parcelable ActivityManager.MemoryInfo; parcelable ActivityManager.MemoryInfo; parcelable ActivityManager.PendingIntentInfo; parcelable ActivityManager.ProcessErrorStateInfo; parcelable ActivityManager.ProcessErrorStateInfo; parcelable ActivityManager.RecentTaskInfo; parcelable ActivityManager.RecentTaskInfo; parcelable ActivityManager.TaskDescription; parcelable ActivityManager.TaskDescription; Loading core/java/android/app/ActivityManager.java +67 −0 Original line number Original line Diff line number Diff line Loading @@ -4776,4 +4776,71 @@ public class ActivityManager { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } } /** * A subset of immutable pending intent information suitable for caching on the client side. * * @hide */ public static final class PendingIntentInfo implements Parcelable { private final String mCreatorPackage; private final int mCreatorUid; private final boolean mImmutable; private final int mIntentSenderType; public PendingIntentInfo(String creatorPackage, int creatorUid, boolean immutable, int intentSenderType) { mCreatorPackage = creatorPackage; mCreatorUid = creatorUid; mImmutable = immutable; mIntentSenderType = intentSenderType; } public String getCreatorPackage() { return mCreatorPackage; } public int getCreatorUid() { return mCreatorUid; } public boolean isImmutable() { return mImmutable; } public int getIntentSenderType() { return mIntentSenderType; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(@NonNull Parcel parcel, int flags) { parcel.writeString(mCreatorPackage); parcel.writeInt(mCreatorUid); parcel.writeBoolean(mImmutable); parcel.writeInt(mIntentSenderType); } public static final @NonNull Creator<PendingIntentInfo> CREATOR = new Creator<PendingIntentInfo>() { @Override public PendingIntentInfo createFromParcel(Parcel in) { return new PendingIntentInfo( /* creatorPackage= */ in.readString(), /* creatorUid= */ in.readInt(), /* immutable= */ in.readBoolean(), /* intentSenderType= */ in.readInt()); } @Override public PendingIntentInfo[] newArray(int size) { return new PendingIntentInfo[size]; } }; } } } core/java/android/app/IActivityManager.aidl +2 −7 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; package android.app; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityManager.PendingIntentInfo; import android.app.ActivityTaskManager; import android.app.ActivityTaskManager; import android.app.ApplicationErrorReport; import android.app.ApplicationErrorReport; import android.app.ApplicationExitInfo; import android.app.ApplicationExitInfo; Loading Loading @@ -248,7 +249,7 @@ interface IActivityManager { in IBinder token, in String resultWho, int requestCode, in Intent[] intents, in IBinder token, in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes, int flags, in Bundle options, int userId); in String[] resolvedTypes, int flags, in Bundle options, int userId); void cancelIntentSender(in IIntentSender sender); void cancelIntentSender(in IIntentSender sender); String getPackageForIntentSender(in IIntentSender sender); ActivityManager.PendingIntentInfo getInfoForIntentSender(in IIntentSender sender); void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void enterSafeMode(); void enterSafeMode(); Loading Loading @@ -293,7 +294,6 @@ interface IActivityManager { int operationType); int operationType); void backupAgentCreated(in String packageName, in IBinder agent, int userId); void backupAgentCreated(in String packageName, in IBinder agent, int userId); void unbindBackupAgent(in ApplicationInfo appInfo); void unbindBackupAgent(in ApplicationInfo appInfo); int getUidForIntentSender(in IIntentSender sender); int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, boolean requireFull, in String name, in String callerPackage); boolean requireFull, in String name, in String callerPackage); void addPackageDependency(in String packageName); void addPackageDependency(in String packageName); Loading Loading @@ -345,7 +345,6 @@ interface IActivityManager { @UnsupportedAppUsage @UnsupportedAppUsage void unregisterProcessObserver(in IProcessObserver observer); void unregisterProcessObserver(in IProcessObserver observer); boolean isIntentSenderTargetedToPackage(in IIntentSender sender); boolean isIntentSenderTargetedToPackage(in IIntentSender sender); boolean isIntentSenderImmutable(in IIntentSender sender); @UnsupportedAppUsage @UnsupportedAppUsage void updatePersistentConfiguration(in Configuration values); void updatePersistentConfiguration(in Configuration values); void updatePersistentConfigurationWithAttribution(in Configuration values, void updatePersistentConfigurationWithAttribution(in Configuration values, Loading Loading @@ -375,8 +374,6 @@ interface IActivityManager { void unstableProviderDied(in IBinder connection); void unstableProviderDied(in IBinder connection); @UnsupportedAppUsage @UnsupportedAppUsage boolean isIntentSenderAnActivity(in IIntentSender sender); boolean isIntentSenderAnActivity(in IIntentSender sender); boolean isIntentSenderAForegroundService(in IIntentSender sender); boolean isIntentSenderABroadcast(in IIntentSender sender); /** @deprecated Use {@link startActivityAsUserWithFeature} instead */ /** @deprecated Use {@link startActivityAsUserWithFeature} instead */ @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@code android.content.Context#createContextAsUser(android.os.UserHandle, int)} and {@link android.content.Context#startActivity(android.content.Intent)} instead") @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@code android.content.Context#createContextAsUser(android.os.UserHandle, int)} and {@link android.content.Context#startActivity(android.content.Intent)} instead") int startActivityAsUser(in IApplicationThread caller, in String callingPackage, int startActivityAsUser(in IApplicationThread caller, in String callingPackage, Loading Loading @@ -710,6 +707,4 @@ interface IActivityManager { /** Called by PendingIntent.queryIntentComponents() */ /** Called by PendingIntent.queryIntentComponents() */ List<ResolveInfo> queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags); List<ResolveInfo> queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags); boolean isIntentSenderAService(in IIntentSender sender); } } core/java/android/app/PendingIntent.java +36 −60 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,11 @@ package android.app; package android.app; import static android.app.ActivityManager.INTENT_SENDER_ACTIVITY; import static android.app.ActivityManager.INTENT_SENDER_BROADCAST; import static android.app.ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE; import static android.app.ActivityManager.INTENT_SENDER_SERVICE; import android.Manifest.permission; import android.Manifest.permission; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; Loading @@ -25,6 +30,7 @@ import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemApi; import android.annotation.SystemApi.Client; import android.annotation.SystemApi.Client; import android.annotation.TestApi; import android.annotation.TestApi; import android.app.ActivityManager.PendingIntentInfo; import android.compat.Compatibility; import android.compat.Compatibility; import android.compat.annotation.ChangeId; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledAfter; import android.compat.annotation.EnabledAfter; Loading Loading @@ -122,6 +128,9 @@ public final class PendingIntent implements Parcelable { private IBinder mWhitelistToken; private IBinder mWhitelistToken; private ArraySet<CancelListener> mCancelListeners; private ArraySet<CancelListener> mCancelListeners; // cached pending intent information private @Nullable PendingIntentInfo mCachedInfo; /** /** * It is now required to specify either {@link #FLAG_IMMUTABLE} * It is now required to specify either {@link #FLAG_IMMUTABLE} * or {@link #FLAG_MUTABLE} when creating a PendingIntent. * or {@link #FLAG_MUTABLE} when creating a PendingIntent. Loading Loading @@ -463,7 +472,7 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); intent.prepareToLeaveProcess(context); IIntentSender target = IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.INTENT_SENDER_ACTIVITY, packageName, INTENT_SENDER_ACTIVITY, packageName, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, resolvedType != null ? new String[] { resolvedType } : null, flags, options, user.getIdentifier()); flags, options, user.getIdentifier()); Loading Loading @@ -596,7 +605,7 @@ public final class PendingIntent implements Parcelable { try { try { IIntentSender target = IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.INTENT_SENDER_ACTIVITY, packageName, INTENT_SENDER_ACTIVITY, packageName, context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes, context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes, flags, options, user.getIdentifier()); flags, options, user.getIdentifier()); return target != null ? new PendingIntent(target) : null; return target != null ? new PendingIntent(target) : null; Loading Loading @@ -650,7 +659,7 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); intent.prepareToLeaveProcess(context); IIntentSender target = IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.INTENT_SENDER_BROADCAST, packageName, INTENT_SENDER_BROADCAST, packageName, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, resolvedType != null ? new String[] { resolvedType } : null, flags, null, userHandle.getIdentifier()); flags, null, userHandle.getIdentifier()); Loading Loading @@ -687,7 +696,7 @@ public final class PendingIntent implements Parcelable { public static PendingIntent getService(Context context, int requestCode, public static PendingIntent getService(Context context, int requestCode, @NonNull Intent intent, @Flags int flags) { @NonNull Intent intent, @Flags int flags) { return buildServicePendingIntent(context, requestCode, intent, flags, return buildServicePendingIntent(context, requestCode, intent, flags, ActivityManager.INTENT_SENDER_SERVICE); INTENT_SENDER_SERVICE); } } /** /** Loading Loading @@ -717,7 +726,7 @@ public final class PendingIntent implements Parcelable { public static PendingIntent getForegroundService(Context context, int requestCode, public static PendingIntent getForegroundService(Context context, int requestCode, @NonNull Intent intent, @Flags int flags) { @NonNull Intent intent, @Flags int flags) { return buildServicePendingIntent(context, requestCode, intent, flags, return buildServicePendingIntent(context, requestCode, intent, flags, ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE); INTENT_SENDER_FOREGROUND_SERVICE); } } private static PendingIntent buildServicePendingIntent(Context context, int requestCode, private static PendingIntent buildServicePendingIntent(Context context, int requestCode, Loading Loading @@ -1001,12 +1010,7 @@ public final class PendingIntent implements Parcelable { */ */ @Deprecated @Deprecated public String getTargetPackage() { public String getTargetPackage() { try { return getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1029,12 +1033,7 @@ public final class PendingIntent implements Parcelable { */ */ @Nullable @Nullable public String getCreatorPackage() { public String getCreatorPackage() { try { return getCachedInfo().getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1056,12 +1055,7 @@ public final class PendingIntent implements Parcelable { * none associated with it. * none associated with it. */ */ public int getCreatorUid() { public int getCreatorUid() { try { return getCachedInfo().getCreatorUid(); return ActivityManager.getService() .getUidForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading Loading @@ -1154,13 +1148,8 @@ public final class PendingIntent implements Parcelable { */ */ @Nullable @Nullable public UserHandle getCreatorUserHandle() { public UserHandle getCreatorUserHandle() { try { int uid = getCachedInfo().getCreatorUid(); int uid = ActivityManager.getService() .getUidForIntentSender(mTarget); return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1180,12 +1169,7 @@ public final class PendingIntent implements Parcelable { * Check if this PendingIntent is marked with {@link #FLAG_IMMUTABLE}. * Check if this PendingIntent is marked with {@link #FLAG_IMMUTABLE}. */ */ public boolean isImmutable() { public boolean isImmutable() { try { return getCachedInfo().isImmutable(); return ActivityManager.getService() .isIntentSenderImmutable(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1193,48 +1177,28 @@ public final class PendingIntent implements Parcelable { * {@link #getActivity} or {@link #getActivities}. * {@link #getActivity} or {@link #getActivities}. */ */ public boolean isActivity() { public boolean isActivity() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_ACTIVITY; return ActivityManager.getService() .isIntentSenderAnActivity(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** * @return TRUE if this {@link PendingIntent} was created with {@link #getForegroundService}. * @return TRUE if this {@link PendingIntent} was created with {@link #getForegroundService}. */ */ public boolean isForegroundService() { public boolean isForegroundService() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_FOREGROUND_SERVICE; return ActivityManager.getService() .isIntentSenderAForegroundService(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** * @return TRUE if this {@link PendingIntent} was created with {@link #getService}. * @return TRUE if this {@link PendingIntent} was created with {@link #getService}. */ */ public boolean isService() { public boolean isService() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_SERVICE; return ActivityManager.getService() .isIntentSenderAService(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** * @return TRUE if this {@link PendingIntent} was created with {@link #getBroadcast}. * @return TRUE if this {@link PendingIntent} was created with {@link #getBroadcast}. */ */ public boolean isBroadcast() { public boolean isBroadcast() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_BROADCAST; return ActivityManager.getService() .isIntentSenderABroadcast(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading Loading @@ -1433,4 +1397,16 @@ public final class PendingIntent implements Parcelable { */ */ void onCancelled(PendingIntent intent); void onCancelled(PendingIntent intent); } } private PendingIntentInfo getCachedInfo() { if (mCachedInfo == null) { try { mCachedInfo = ActivityManager.getService().getInfoForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return mCachedInfo; } } } core/java/android/content/IntentSender.java +21 −29 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.content; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityManager.PendingIntentInfo; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Handler; Loading Loading @@ -60,6 +61,9 @@ public class IntentSender implements Parcelable { private final IIntentSender mTarget; private final IIntentSender mTarget; IBinder mWhitelistToken; IBinder mWhitelistToken; // cached pending intent information private @Nullable PendingIntentInfo mCachedInfo; /** /** * Exception thrown when trying to send through a PendingIntent that * Exception thrown when trying to send through a PendingIntent that * has been canceled or is otherwise no longer able to execute the request. * has been canceled or is otherwise no longer able to execute the request. Loading Loading @@ -209,13 +213,7 @@ public class IntentSender implements Parcelable { */ */ @Deprecated @Deprecated public String getTargetPackage() { public String getTargetPackage() { try { return getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { // Should never happen. return null; } } } /** /** Loading @@ -228,13 +226,7 @@ public class IntentSender implements Parcelable { * none associated with it. * none associated with it. */ */ public String getCreatorPackage() { public String getCreatorPackage() { try { return getCachedInfo().getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { // Should never happen. return null; } } } /** /** Loading @@ -247,13 +239,7 @@ public class IntentSender implements Parcelable { * none associated with it. * none associated with it. */ */ public int getCreatorUid() { public int getCreatorUid() { try { return getCachedInfo().getCreatorUid(); return ActivityManager.getService() .getUidForIntentSender(mTarget); } catch (RemoteException e) { // Should never happen. return -1; } } } /** /** Loading @@ -268,14 +254,8 @@ public class IntentSender implements Parcelable { * none associated with it. * none associated with it. */ */ public UserHandle getCreatorUserHandle() { public UserHandle getCreatorUserHandle() { try { int uid = getCachedInfo().getCreatorUid(); int uid = ActivityManager.getService() .getUidForIntentSender(mTarget); return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; } catch (RemoteException e) { // Should never happen. return null; } } } /** /** Loading Loading @@ -384,4 +364,16 @@ public class IntentSender implements Parcelable { public IntentSender(IBinder target) { public IntentSender(IBinder target) { mTarget = IIntentSender.Stub.asInterface(target); mTarget = IIntentSender.Stub.asInterface(target); } } private PendingIntentInfo getCachedInfo() { if (mCachedInfo == null) { try { mCachedInfo = ActivityManager.getService().getInfoForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return mCachedInfo; } } } Loading
core/java/android/app/ActivityManager.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; package android.app; parcelable ActivityManager.MemoryInfo; parcelable ActivityManager.MemoryInfo; parcelable ActivityManager.PendingIntentInfo; parcelable ActivityManager.ProcessErrorStateInfo; parcelable ActivityManager.ProcessErrorStateInfo; parcelable ActivityManager.RecentTaskInfo; parcelable ActivityManager.RecentTaskInfo; parcelable ActivityManager.TaskDescription; parcelable ActivityManager.TaskDescription; Loading
core/java/android/app/ActivityManager.java +67 −0 Original line number Original line Diff line number Diff line Loading @@ -4776,4 +4776,71 @@ public class ActivityManager { throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer(); } } } } /** * A subset of immutable pending intent information suitable for caching on the client side. * * @hide */ public static final class PendingIntentInfo implements Parcelable { private final String mCreatorPackage; private final int mCreatorUid; private final boolean mImmutable; private final int mIntentSenderType; public PendingIntentInfo(String creatorPackage, int creatorUid, boolean immutable, int intentSenderType) { mCreatorPackage = creatorPackage; mCreatorUid = creatorUid; mImmutable = immutable; mIntentSenderType = intentSenderType; } public String getCreatorPackage() { return mCreatorPackage; } public int getCreatorUid() { return mCreatorUid; } public boolean isImmutable() { return mImmutable; } public int getIntentSenderType() { return mIntentSenderType; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(@NonNull Parcel parcel, int flags) { parcel.writeString(mCreatorPackage); parcel.writeInt(mCreatorUid); parcel.writeBoolean(mImmutable); parcel.writeInt(mIntentSenderType); } public static final @NonNull Creator<PendingIntentInfo> CREATOR = new Creator<PendingIntentInfo>() { @Override public PendingIntentInfo createFromParcel(Parcel in) { return new PendingIntentInfo( /* creatorPackage= */ in.readString(), /* creatorUid= */ in.readInt(), /* immutable= */ in.readBoolean(), /* intentSenderType= */ in.readInt()); } @Override public PendingIntentInfo[] newArray(int size) { return new PendingIntentInfo[size]; } }; } } }
core/java/android/app/IActivityManager.aidl +2 −7 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.app; package android.app; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityManager.PendingIntentInfo; import android.app.ActivityTaskManager; import android.app.ActivityTaskManager; import android.app.ApplicationErrorReport; import android.app.ApplicationErrorReport; import android.app.ApplicationExitInfo; import android.app.ApplicationExitInfo; Loading Loading @@ -248,7 +249,7 @@ interface IActivityManager { in IBinder token, in String resultWho, int requestCode, in Intent[] intents, in IBinder token, in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes, int flags, in Bundle options, int userId); in String[] resolvedTypes, int flags, in Bundle options, int userId); void cancelIntentSender(in IIntentSender sender); void cancelIntentSender(in IIntentSender sender); String getPackageForIntentSender(in IIntentSender sender); ActivityManager.PendingIntentInfo getInfoForIntentSender(in IIntentSender sender); void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver); void enterSafeMode(); void enterSafeMode(); Loading Loading @@ -293,7 +294,6 @@ interface IActivityManager { int operationType); int operationType); void backupAgentCreated(in String packageName, in IBinder agent, int userId); void backupAgentCreated(in String packageName, in IBinder agent, int userId); void unbindBackupAgent(in ApplicationInfo appInfo); void unbindBackupAgent(in ApplicationInfo appInfo); int getUidForIntentSender(in IIntentSender sender); int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, boolean requireFull, in String name, in String callerPackage); boolean requireFull, in String name, in String callerPackage); void addPackageDependency(in String packageName); void addPackageDependency(in String packageName); Loading Loading @@ -345,7 +345,6 @@ interface IActivityManager { @UnsupportedAppUsage @UnsupportedAppUsage void unregisterProcessObserver(in IProcessObserver observer); void unregisterProcessObserver(in IProcessObserver observer); boolean isIntentSenderTargetedToPackage(in IIntentSender sender); boolean isIntentSenderTargetedToPackage(in IIntentSender sender); boolean isIntentSenderImmutable(in IIntentSender sender); @UnsupportedAppUsage @UnsupportedAppUsage void updatePersistentConfiguration(in Configuration values); void updatePersistentConfiguration(in Configuration values); void updatePersistentConfigurationWithAttribution(in Configuration values, void updatePersistentConfigurationWithAttribution(in Configuration values, Loading Loading @@ -375,8 +374,6 @@ interface IActivityManager { void unstableProviderDied(in IBinder connection); void unstableProviderDied(in IBinder connection); @UnsupportedAppUsage @UnsupportedAppUsage boolean isIntentSenderAnActivity(in IIntentSender sender); boolean isIntentSenderAnActivity(in IIntentSender sender); boolean isIntentSenderAForegroundService(in IIntentSender sender); boolean isIntentSenderABroadcast(in IIntentSender sender); /** @deprecated Use {@link startActivityAsUserWithFeature} instead */ /** @deprecated Use {@link startActivityAsUserWithFeature} instead */ @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@code android.content.Context#createContextAsUser(android.os.UserHandle, int)} and {@link android.content.Context#startActivity(android.content.Intent)} instead") @UnsupportedAppUsage(maxTargetSdk=29, publicAlternatives="Use {@code android.content.Context#createContextAsUser(android.os.UserHandle, int)} and {@link android.content.Context#startActivity(android.content.Intent)} instead") int startActivityAsUser(in IApplicationThread caller, in String callingPackage, int startActivityAsUser(in IApplicationThread caller, in String callingPackage, Loading Loading @@ -710,6 +707,4 @@ interface IActivityManager { /** Called by PendingIntent.queryIntentComponents() */ /** Called by PendingIntent.queryIntentComponents() */ List<ResolveInfo> queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags); List<ResolveInfo> queryIntentComponentsForIntentSender(in IIntentSender sender, int matchFlags); boolean isIntentSenderAService(in IIntentSender sender); } }
core/java/android/app/PendingIntent.java +36 −60 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,11 @@ package android.app; package android.app; import static android.app.ActivityManager.INTENT_SENDER_ACTIVITY; import static android.app.ActivityManager.INTENT_SENDER_BROADCAST; import static android.app.ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE; import static android.app.ActivityManager.INTENT_SENDER_SERVICE; import android.Manifest.permission; import android.Manifest.permission; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; Loading @@ -25,6 +30,7 @@ import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemApi; import android.annotation.SystemApi.Client; import android.annotation.SystemApi.Client; import android.annotation.TestApi; import android.annotation.TestApi; import android.app.ActivityManager.PendingIntentInfo; import android.compat.Compatibility; import android.compat.Compatibility; import android.compat.annotation.ChangeId; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledAfter; import android.compat.annotation.EnabledAfter; Loading Loading @@ -122,6 +128,9 @@ public final class PendingIntent implements Parcelable { private IBinder mWhitelistToken; private IBinder mWhitelistToken; private ArraySet<CancelListener> mCancelListeners; private ArraySet<CancelListener> mCancelListeners; // cached pending intent information private @Nullable PendingIntentInfo mCachedInfo; /** /** * It is now required to specify either {@link #FLAG_IMMUTABLE} * It is now required to specify either {@link #FLAG_IMMUTABLE} * or {@link #FLAG_MUTABLE} when creating a PendingIntent. * or {@link #FLAG_MUTABLE} when creating a PendingIntent. Loading Loading @@ -463,7 +472,7 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); intent.prepareToLeaveProcess(context); IIntentSender target = IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.INTENT_SENDER_ACTIVITY, packageName, INTENT_SENDER_ACTIVITY, packageName, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, resolvedType != null ? new String[] { resolvedType } : null, flags, options, user.getIdentifier()); flags, options, user.getIdentifier()); Loading Loading @@ -596,7 +605,7 @@ public final class PendingIntent implements Parcelable { try { try { IIntentSender target = IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.INTENT_SENDER_ACTIVITY, packageName, INTENT_SENDER_ACTIVITY, packageName, context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes, context.getAttributionTag(), null, null, requestCode, intents, resolvedTypes, flags, options, user.getIdentifier()); flags, options, user.getIdentifier()); return target != null ? new PendingIntent(target) : null; return target != null ? new PendingIntent(target) : null; Loading Loading @@ -650,7 +659,7 @@ public final class PendingIntent implements Parcelable { intent.prepareToLeaveProcess(context); intent.prepareToLeaveProcess(context); IIntentSender target = IIntentSender target = ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.getService().getIntentSenderWithFeature( ActivityManager.INTENT_SENDER_BROADCAST, packageName, INTENT_SENDER_BROADCAST, packageName, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, context.getAttributionTag(), null, null, requestCode, new Intent[] { intent }, resolvedType != null ? new String[] { resolvedType } : null, resolvedType != null ? new String[] { resolvedType } : null, flags, null, userHandle.getIdentifier()); flags, null, userHandle.getIdentifier()); Loading Loading @@ -687,7 +696,7 @@ public final class PendingIntent implements Parcelable { public static PendingIntent getService(Context context, int requestCode, public static PendingIntent getService(Context context, int requestCode, @NonNull Intent intent, @Flags int flags) { @NonNull Intent intent, @Flags int flags) { return buildServicePendingIntent(context, requestCode, intent, flags, return buildServicePendingIntent(context, requestCode, intent, flags, ActivityManager.INTENT_SENDER_SERVICE); INTENT_SENDER_SERVICE); } } /** /** Loading Loading @@ -717,7 +726,7 @@ public final class PendingIntent implements Parcelable { public static PendingIntent getForegroundService(Context context, int requestCode, public static PendingIntent getForegroundService(Context context, int requestCode, @NonNull Intent intent, @Flags int flags) { @NonNull Intent intent, @Flags int flags) { return buildServicePendingIntent(context, requestCode, intent, flags, return buildServicePendingIntent(context, requestCode, intent, flags, ActivityManager.INTENT_SENDER_FOREGROUND_SERVICE); INTENT_SENDER_FOREGROUND_SERVICE); } } private static PendingIntent buildServicePendingIntent(Context context, int requestCode, private static PendingIntent buildServicePendingIntent(Context context, int requestCode, Loading Loading @@ -1001,12 +1010,7 @@ public final class PendingIntent implements Parcelable { */ */ @Deprecated @Deprecated public String getTargetPackage() { public String getTargetPackage() { try { return getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1029,12 +1033,7 @@ public final class PendingIntent implements Parcelable { */ */ @Nullable @Nullable public String getCreatorPackage() { public String getCreatorPackage() { try { return getCachedInfo().getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1056,12 +1055,7 @@ public final class PendingIntent implements Parcelable { * none associated with it. * none associated with it. */ */ public int getCreatorUid() { public int getCreatorUid() { try { return getCachedInfo().getCreatorUid(); return ActivityManager.getService() .getUidForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading Loading @@ -1154,13 +1148,8 @@ public final class PendingIntent implements Parcelable { */ */ @Nullable @Nullable public UserHandle getCreatorUserHandle() { public UserHandle getCreatorUserHandle() { try { int uid = getCachedInfo().getCreatorUid(); int uid = ActivityManager.getService() .getUidForIntentSender(mTarget); return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1180,12 +1169,7 @@ public final class PendingIntent implements Parcelable { * Check if this PendingIntent is marked with {@link #FLAG_IMMUTABLE}. * Check if this PendingIntent is marked with {@link #FLAG_IMMUTABLE}. */ */ public boolean isImmutable() { public boolean isImmutable() { try { return getCachedInfo().isImmutable(); return ActivityManager.getService() .isIntentSenderImmutable(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading @@ -1193,48 +1177,28 @@ public final class PendingIntent implements Parcelable { * {@link #getActivity} or {@link #getActivities}. * {@link #getActivity} or {@link #getActivities}. */ */ public boolean isActivity() { public boolean isActivity() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_ACTIVITY; return ActivityManager.getService() .isIntentSenderAnActivity(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** * @return TRUE if this {@link PendingIntent} was created with {@link #getForegroundService}. * @return TRUE if this {@link PendingIntent} was created with {@link #getForegroundService}. */ */ public boolean isForegroundService() { public boolean isForegroundService() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_FOREGROUND_SERVICE; return ActivityManager.getService() .isIntentSenderAForegroundService(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** * @return TRUE if this {@link PendingIntent} was created with {@link #getService}. * @return TRUE if this {@link PendingIntent} was created with {@link #getService}. */ */ public boolean isService() { public boolean isService() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_SERVICE; return ActivityManager.getService() .isIntentSenderAService(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** * @return TRUE if this {@link PendingIntent} was created with {@link #getBroadcast}. * @return TRUE if this {@link PendingIntent} was created with {@link #getBroadcast}. */ */ public boolean isBroadcast() { public boolean isBroadcast() { try { return getCachedInfo().getIntentSenderType() == INTENT_SENDER_BROADCAST; return ActivityManager.getService() .isIntentSenderABroadcast(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } /** /** Loading Loading @@ -1433,4 +1397,16 @@ public final class PendingIntent implements Parcelable { */ */ void onCancelled(PendingIntent intent); void onCancelled(PendingIntent intent); } } private PendingIntentInfo getCachedInfo() { if (mCachedInfo == null) { try { mCachedInfo = ActivityManager.getService().getInfoForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return mCachedInfo; } } }
core/java/android/content/IntentSender.java +21 −29 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.content; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.ActivityManager.PendingIntentInfo; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Handler; Loading Loading @@ -60,6 +61,9 @@ public class IntentSender implements Parcelable { private final IIntentSender mTarget; private final IIntentSender mTarget; IBinder mWhitelistToken; IBinder mWhitelistToken; // cached pending intent information private @Nullable PendingIntentInfo mCachedInfo; /** /** * Exception thrown when trying to send through a PendingIntent that * Exception thrown when trying to send through a PendingIntent that * has been canceled or is otherwise no longer able to execute the request. * has been canceled or is otherwise no longer able to execute the request. Loading Loading @@ -209,13 +213,7 @@ public class IntentSender implements Parcelable { */ */ @Deprecated @Deprecated public String getTargetPackage() { public String getTargetPackage() { try { return getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { // Should never happen. return null; } } } /** /** Loading @@ -228,13 +226,7 @@ public class IntentSender implements Parcelable { * none associated with it. * none associated with it. */ */ public String getCreatorPackage() { public String getCreatorPackage() { try { return getCachedInfo().getCreatorPackage(); return ActivityManager.getService() .getPackageForIntentSender(mTarget); } catch (RemoteException e) { // Should never happen. return null; } } } /** /** Loading @@ -247,13 +239,7 @@ public class IntentSender implements Parcelable { * none associated with it. * none associated with it. */ */ public int getCreatorUid() { public int getCreatorUid() { try { return getCachedInfo().getCreatorUid(); return ActivityManager.getService() .getUidForIntentSender(mTarget); } catch (RemoteException e) { // Should never happen. return -1; } } } /** /** Loading @@ -268,14 +254,8 @@ public class IntentSender implements Parcelable { * none associated with it. * none associated with it. */ */ public UserHandle getCreatorUserHandle() { public UserHandle getCreatorUserHandle() { try { int uid = getCachedInfo().getCreatorUid(); int uid = ActivityManager.getService() .getUidForIntentSender(mTarget); return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; return uid > 0 ? new UserHandle(UserHandle.getUserId(uid)) : null; } catch (RemoteException e) { // Should never happen. return null; } } } /** /** Loading Loading @@ -384,4 +364,16 @@ public class IntentSender implements Parcelable { public IntentSender(IBinder target) { public IntentSender(IBinder target) { mTarget = IIntentSender.Stub.asInterface(target); mTarget = IIntentSender.Stub.asInterface(target); } } private PendingIntentInfo getCachedInfo() { if (mCachedInfo == null) { try { mCachedInfo = ActivityManager.getService().getInfoForIntentSender(mTarget); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } return mCachedInfo; } } }