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

Commit 2c513ff8 authored by Mark Fasheh's avatar Mark Fasheh Committed by Android (Google) Code Review
Browse files

Merge "Message: Don't use sentinel for target" into main

parents 734b88b6 d2731127
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -330,23 +330,6 @@ public class Handler {
        return new Handler(looper, callback, true);
    }

    /**
     * Create a new Handler with all reference fields explicitly provided. This is intended to be
     * used for creating a Handler sentinel object.
     */
    private Handler(Looper looper, MessageQueue queue, Callback callback) {
        mLooper = looper;
        mQueue = queue;
        mCallback = callback;
        mAsynchronous = false;
        mIsShared = false;
    }

    /** @hide */
    static Handler createSentinelHandler() {
        return new Handler(null, null, null);
    }

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @NonNull
+1 −5
Original line number Diff line number Diff line
@@ -419,7 +419,6 @@ public final class Message implements Parcelable {
    // Sentinel values used to clear reference fields with a valid 'null' value, to avoid grabbing a
    // removed message when matching for 'null' in these fields.
    private static final Object NULL_OBJECT = new Object();
    private static final Handler NULL_HANDLER = Handler.createSentinelHandler();
    private static final Runnable NULL_RUNNABLE = () -> {};

    /**
@@ -433,7 +432,6 @@ public final class Message implements Parcelable {
        replyTo = null;
        sendingThreadName = null;
        data = null;
        target = NULL_HANDLER;
        callback = NULL_RUNNABLE;
    }

@@ -479,9 +477,7 @@ public final class Message implements Parcelable {
     * worry about yours conflicting with other handlers.
     */
    public Handler getTarget() {
        // We assign this first to avoid a data race that could potentially expose NULL_HANDLER.
        final Handler ret = target;
        return ret == NULL_HANDLER ? null : ret;
        return target;
    }

    /**