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