summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-09-07 18:33:18 -0700
committerDianne Hackborn <hackbod@google.com>2012-09-07 18:33:18 -0700
commit74ee8652e02fc94901177214fc9370659732c921 (patch)
treed3b5c4848416a4957342f36b326364fb20d8e45e /core/java/android/os
parentd888399ad4a4ec0a08e97518bf22d726a8bd4eaa (diff)
downloadframeworks_base-74ee8652e02fc94901177214fc9370659732c921.zip
frameworks_base-74ee8652e02fc94901177214fc9370659732c921.tar.gz
frameworks_base-74ee8652e02fc94901177214fc9370659732c921.tar.bz2
Add Binder.getCallingUserHandle().
Change-Id: I2a7eedfdc7baeeb4c2cd2ca0153aa95e0cf0bf45
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/Binder.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index ea14098..16b4835 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -64,7 +64,7 @@ public class Binder implements IBinder {
public static final native int getCallingPid();
/**
- * Return the ID of the user assigned to the process that sent you the
+ * Return the Linux uid assigned to the process that sent you the
* current transaction that is being processed. This uid can be used with
* higher-level system services to determine its identity and check
* permissions. If the current thread is not currently executing an
@@ -73,6 +73,18 @@ public class Binder implements IBinder {
public static final native int getCallingUid();
/**
+ * Return the UserHandle assigned to the process that sent you the
+ * current transaction that is being processed. This is the user
+ * of the caller. It is distinct from {@link #getCallingUid()} in that a
+ * particular user will have multiple distinct apps running under it each
+ * with their own uid. If the current thread is not currently executing an
+ * incoming transaction, then its own UserHandle is returned.
+ */
+ public static final UserHandle getCallingUserHandle() {
+ return new UserHandle(UserHandle.getUserId(getCallingUid()));
+ }
+
+ /**
* Reset the identity of the incoming IPC on the current thread. This can
* be useful if, while handling an incoming call, you will be calling
* on interfaces of other objects that may be local to your process and