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

Commit cb3ed1dc authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add new sendingUid field to Message.

This tell you where the message came from when it was
delivered through a Messenger.

Change-Id: I86a5f521c8ae919b45872dd76b61e83447f397ab
parent 6612727c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21189,6 +21189,7 @@ package android.os {
    field public int arg2;
    field public java.lang.Object obj;
    field public android.os.Messenger replyTo;
    field public int sendingUid;
    field public int what;
  }
+1 −0
Original line number Diff line number Diff line
@@ -717,6 +717,7 @@ public class Handler {

    private final class MessengerImpl extends IMessenger.Stub {
        public void send(Message msg) {
            msg.sendingUid = Binder.getCallingUid();
            Handler.this.sendMessage(msg);
        }
    }
+12 −0
Original line number Diff line number Diff line
@@ -71,6 +71,13 @@ public final class Message implements Parcelable {
     */
    public Messenger replyTo;

    /**
     * Optional field indicating the uid that sent the message.  This is
     * only valid for messages posted by a {@link Messenger}; otherwise,
     * it will be -1.
     */
    public int sendingUid = -1;

    /** If set message is in use.
     * This flag is set when the message is enqueued and remains set while it
     * is delivered and afterwards when it is recycled.  The flag is only cleared
@@ -137,6 +144,7 @@ public final class Message implements Parcelable {
        m.arg2 = orig.arg2;
        m.obj = orig.obj;
        m.replyTo = orig.replyTo;
        m.sendingUid = orig.sendingUid;
        if (orig.data != null) {
            m.data = new Bundle(orig.data);
        }
@@ -277,6 +285,7 @@ public final class Message implements Parcelable {
        arg2 = 0;
        obj = null;
        replyTo = null;
        sendingUid = -1;
        when = 0;
        target = null;
        callback = null;
@@ -303,6 +312,7 @@ public final class Message implements Parcelable {
        this.arg2 = o.arg2;
        this.obj = o.obj;
        this.replyTo = o.replyTo;
        this.sendingUid = o.sendingUid;

        if (o.data != null) {
            this.data = (Bundle) o.data.clone();
@@ -534,6 +544,7 @@ public final class Message implements Parcelable {
        dest.writeLong(when);
        dest.writeBundle(data);
        Messenger.writeMessengerOrNullToParcel(replyTo, dest);
        dest.writeInt(sendingUid);
    }

    private void readFromParcel(Parcel source) {
@@ -546,5 +557,6 @@ public final class Message implements Parcelable {
        when = source.readLong();
        data = source.readBundle();
        replyTo = Messenger.readMessengerOrNullFromParcel(source);
        sendingUid = source.readInt();
    }
}