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

Commit 33696164 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh Committed by Android (Google) Code Review
Browse files

Merge "Revert "Allow reliable detection of a message that is in use.""

parents d9df0124 ddb2bfeb
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -74,10 +74,6 @@ public final class Message implements Parcelable {
     */
    public Messenger replyTo;
    
    /*package*/ static final int FLAG_IN_USE = 1;
    
    /*package*/ int flags;
    
    /*package*/ long when;
    
    /*package*/ Bundle data;
@@ -257,7 +253,6 @@ public final class Message implements Parcelable {
     * target/callback of the original message.
     */
    public void copyFrom(Message o) {
        this.flags = o.flags;
        this.what = o.what;
        this.arg1 = o.arg1;
        this.arg2 = o.arg2;
@@ -355,7 +350,6 @@ public final class Message implements Parcelable {
    }

    /*package*/ void clearForRecycle() {
        flags = 0;
        what = 0;
        arg1 = 0;
        arg2 = 0;
@@ -367,14 +361,6 @@ public final class Message implements Parcelable {
        data = null;
    }

    /*package*/ boolean isInUse() {
        return ((flags & FLAG_IN_USE) == FLAG_IN_USE);
    }

    /*package*/ void markInUse() {
        flags |= FLAG_IN_USE;
    }

    /** Constructor (but the preferred way to get a Message is to call {@link #obtain() Message.obtain()}).
    */
    public Message() {
@@ -467,3 +453,4 @@ public final class Message implements Parcelable {
        replyTo = Messenger.readMessengerOrNullFromParcel(source);
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ public class MessageQueue {
                now = SystemClock.uptimeMillis();
                Message msg = pullNextLocked(now);
                if (msg != null) {
                    msg.markInUse();
                    return msg;
                }
                
@@ -193,7 +192,7 @@ public class MessageQueue {
    }

    final boolean enqueueMessage(Message msg, long when) {
        if (msg.isInUse()) {
        if (msg.when != 0) {
            throw new AndroidRuntimeException(msg
                    + " This message is already in use.");
        }
+1 −4
Original line number Diff line number Diff line
@@ -41,10 +41,6 @@ public class MessageQueueTest extends TestCase {
        }

        public void handleMessage(Message msg) {
            if (!msg.isInUse()) {
                failure(new RuntimeException(
                        "msg.isInuse is false, should always be true, #" + msg.what));
            }
            if (mCount <= mLastMessage) {
                if (msg.what != mCount) {
                    failure(new RuntimeException(
@@ -104,3 +100,4 @@ public class MessageQueueTest extends TestCase {
        tester.doTest(1000);
    }
}