diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-06-27 18:37:06 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-06-28 14:26:02 -0700 |
commit | cb3ed1dc287ddb9beb7c9186713426f5fba263c3 (patch) | |
tree | 61013d205231d91d8db1ca5d3bd266b4f8e4e067 | |
parent | 6612727c18fe6e7b6edf811f3a1a871a710c0ebe (diff) | |
download | frameworks_base-cb3ed1dc287ddb9beb7c9186713426f5fba263c3.zip frameworks_base-cb3ed1dc287ddb9beb7c9186713426f5fba263c3.tar.gz frameworks_base-cb3ed1dc287ddb9beb7c9186713426f5fba263c3.tar.bz2 |
Add new sendingUid field to Message.
This tell you where the message came from when it was
delivered through a Messenger.
Change-Id: I86a5f521c8ae919b45872dd76b61e83447f397ab
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/os/Handler.java | 1 | ||||
-rw-r--r-- | core/java/android/os/Message.java | 12 |
3 files changed, 14 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index de26fe3..b7d62da 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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; } diff --git a/core/java/android/os/Handler.java b/core/java/android/os/Handler.java index 44367f3..52db060 100644 --- a/core/java/android/os/Handler.java +++ b/core/java/android/os/Handler.java @@ -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); } } diff --git a/core/java/android/os/Message.java b/core/java/android/os/Message.java index d30bbc1..5389144 100644 --- a/core/java/android/os/Message.java +++ b/core/java/android/os/Message.java @@ -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(); } } |