Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0773220f authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

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
parent b41548eb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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,
+12 −0
Original line number Diff line number Diff line
@@ -1144,6 +1144,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.
+9 −0
Original line number Diff line number Diff line
@@ -4889,6 +4889,15 @@ public class ActivityManagerService extends IActivityManager.Stub
        return false;
    }
    @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)) {