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

Commit f747d863 authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Merge "Simplify cookie usage in allowlist token serialization" into main

parents b0133d13 95615e04
Loading
Loading
Loading
Loading
+7 −11
Original line number Original line Diff line number Diff line
@@ -3259,8 +3259,9 @@ public class Notification implements Parcelable
                boolean mustClearCookie = false;
                boolean mustClearCookie = false;
                if (!parcel.hasClassCookie(Notification.class)) {
                if (!parcel.hasClassCookie(Notification.class)) {
                    // This is the "root" notification, and not an "inner" notification (including
                    // This is the "root" notification, and not an "inner" notification (including
                    // publicVersion or anything else that might be embedded in extras).
                    // publicVersion or anything else that might be embedded in extras). So we want
                    parcel.setClassCookie(Notification.class, this);
                    // to use its token for every inner notification (might be null).
                    parcel.setClassCookie(Notification.class, mAllowlistToken);
                    mustClearCookie = true;
                    mustClearCookie = true;
                }
                }
                try {
                try {
@@ -3269,7 +3270,7 @@ public class Notification implements Parcelable
                    writeToParcelImpl(parcel, flags);
                    writeToParcelImpl(parcel, flags);
                } finally {
                } finally {
                    if (mustClearCookie) {
                    if (mustClearCookie) {
                        parcel.removeClassCookie(Notification.class, this);
                        parcel.removeClassCookie(Notification.class, mAllowlistToken);
                    }
                    }
                }
                }
            } else {
            } else {
@@ -3293,14 +3294,9 @@ public class Notification implements Parcelable
        parcel.writeInt(1);
        parcel.writeInt(1);
        if (Flags.secureAllowlistToken()) {
        if (Flags.secureAllowlistToken()) {
            Notification rootNotification = (Notification) parcel.getClassCookie(
            // Always use the same token as the root notification (might be null).
                    Notification.class);
            IBinder rootNotificationToken = (IBinder) parcel.getClassCookie(Notification.class);
            if (rootNotification != null && rootNotification != this) {
            parcel.writeStrongBinder(rootNotificationToken);
                // Always use the same token as the root notification
                parcel.writeStrongBinder(rootNotification.mAllowlistToken);
            } else {
                parcel.writeStrongBinder(mAllowlistToken);
            }
        } else {
        } else {
            parcel.writeStrongBinder(mAllowlistToken);
            parcel.writeStrongBinder(mAllowlistToken);
        }
        }