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

Commit 975ab5c0 authored by Svetoslav's avatar Svetoslav Committed by Android (Google) Code Review
Browse files

Merge "Add a mechanism to make pending intents immutable."

parents 69010094 b0a78390
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5149,6 +5149,7 @@ package android.app {
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.PendingIntent> CREATOR;
    field public static final int FLAG_CANCEL_CURRENT = 268435456; // 0x10000000
    field public static final int FLAG_IMMUTABLE = 67108864; // 0x4000000
    field public static final int FLAG_NO_CREATE = 536870912; // 0x20000000
    field public static final int FLAG_ONE_SHOT = 1073741824; // 0x40000000
    field public static final int FLAG_UPDATE_CURRENT = 134217728; // 0x8000000
+1 −0
Original line number Diff line number Diff line
@@ -5240,6 +5240,7 @@ package android.app {
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.PendingIntent> CREATOR;
    field public static final int FLAG_CANCEL_CURRENT = 268435456; // 0x10000000
    field public static final int FLAG_IMMUTABLE = 67108864; // 0x4000000
    field public static final int FLAG_NO_CREATE = 536870912; // 0x20000000
    field public static final int FLAG_ONE_SHOT = 1073741824; // 0x40000000
    field public static final int FLAG_UPDATE_CURRENT = 134217728; // 0x8000000
+14 −1
Original line number Diff line number Diff line
@@ -150,6 +150,14 @@ public final class PendingIntent implements Parcelable {
     */
    public static final int FLAG_UPDATE_CURRENT = 1<<27;

    /**
     * Flag indicating that the created PendingIntent should be immutable.
     * This means that the additional intent argument passed to the send
     * methods to fill in unpopulated properties of this intent will be
     * ignored.
     */
    public static final int FLAG_IMMUTABLE = 1<<26;

    /**
     * Exception thrown when trying to send through a PendingIntent that
     * has been canceled or is otherwise no longer able to execute the request.
@@ -618,7 +626,8 @@ public final class PendingIntent implements Parcelable {
     * @param code Result code to supply back to the PendingIntent's target.
     * @param intent Additional Intent data.  See {@link Intent#fillIn
     * Intent.fillIn()} for information on how this is applied to the
     * original Intent.
     * original Intent. If flag {@link #FLAG_IMMUTABLE} was set when this
     * pending intent was created, this argument will be ignored.
     *
     * @see #send(Context, int, Intent, android.app.PendingIntent.OnFinished, Handler)
     *
@@ -667,6 +676,8 @@ public final class PendingIntent implements Parcelable {
     * @param intent Additional Intent data.  See {@link Intent#fillIn
     * Intent.fillIn()} for information on how this is applied to the
     * original Intent.  Use null to not modify the original Intent.
     * If flag {@link #FLAG_IMMUTABLE} was set when this pending intent was
     * created, this argument will be ignored.
     * @param onFinished The object to call back on when the send has
     * completed, or null for no callback.
     * @param handler Handler identifying the thread on which the callback
@@ -703,6 +714,8 @@ public final class PendingIntent implements Parcelable {
     * @param intent Additional Intent data.  See {@link Intent#fillIn
     * Intent.fillIn()} for information on how this is applied to the
     * original Intent.  Use null to not modify the original Intent.
     * If flag {@link #FLAG_IMMUTABLE} was set when this pending intent was
     * created, this argument will be ignored.
     * @param onFinished The object to call back on when the send has
     * completed, or null for no callback.
     * @param handler Handler identifying the thread on which the callback
+7 −4
Original line number Diff line number Diff line
@@ -674,7 +674,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku

    @Override
    public IntentSender createAppWidgetConfigIntentSender(String callingPackage, int appWidgetId,
            int intentFlags) {
            final int intentFlags) {
        final int userId = UserHandle.getCallingUserId();

        if (DEBUG) {
@@ -701,18 +701,21 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku
                throw new IllegalArgumentException("Widget not bound " + appWidgetId);
            }

            // Make sure only safe flags can be passed it.
            final int secureFlags = intentFlags & ~Intent.IMMUTABLE_FLAGS;

            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.setComponent(provider.info.configure);
            intent.setFlags(intentFlags);
            intent.setFlags(secureFlags);

            // All right, create the sender.
            final long identity = Binder.clearCallingIdentity();
            try {
                return PendingIntent.getActivityAsUser(
                        mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT
                                | PendingIntent.FLAG_CANCEL_CURRENT, null,
                                new UserHandle(provider.getUserId()))
                                | PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT,
                                null, new UserHandle(provider.getUserId()))
                        .getIntentSender();
            } finally {
                Binder.restoreCallingIdentity(identity);
+13 −6
Original line number Diff line number Diff line
@@ -222,8 +222,12 @@ final class PendingIntentRecord extends IIntentSender.Stub {
                    owner.cancelIntentSenderLocked(this, true);
                    canceled = true;
                }

                Intent finalIntent = key.requestIntent != null
                        ? new Intent(key.requestIntent) : new Intent();

                final boolean immutable = (key.flags & PendingIntent.FLAG_IMMUTABLE) != 0;
                if (!immutable) {
                    if (intent != null) {
                        int changes = finalIntent.fillIn(intent, key.flags);
                        if ((changes & Intent.FILL_IN_DATA) == 0) {
@@ -235,6 +239,9 @@ final class PendingIntentRecord extends IIntentSender.Stub {
                    flagsMask &= ~Intent.IMMUTABLE_FLAGS;
                    flagsValues &= flagsMask;
                    finalIntent.setFlags((finalIntent.getFlags() & ~flagsMask) | flagsValues);
                } else {
                    resolvedType = key.requestResolvedType;
                }

                final long origId = Binder.clearCallingIdentity();

Loading