summaryrefslogtreecommitdiffstats
path: root/core/java/android/os/Binder.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/os/Binder.java')
-rw-r--r--core/java/android/os/Binder.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 24569fa..577fc43 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -49,6 +49,7 @@ public class Binder implements IBinder {
private static final boolean FIND_POTENTIAL_LEAKS = false;
private static final String TAG = "Binder";
+ /* mObject is used by native code, do not remove or rename */
private int mObject;
private IInterface mOwner;
private String mDescriptor;
@@ -70,7 +71,35 @@ public class Binder implements IBinder {
* incoming transaction, then its own uid is returned.
*/
public static final native int getCallingUid();
-
+
+ /**
+ * Return the original ID of the user 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 incoming transaction, then its own uid is returned.
+ * <p/>
+ * This value cannot be reset by calls to {@link #clearCallingIdentity()}.
+ * @hide
+ */
+ public static final int getOrigCallingUid() {
+ if (UserId.MU_ENABLED) {
+ return getOrigCallingUidNative();
+ } else {
+ return getCallingUid();
+ }
+ }
+
+ private static final native int getOrigCallingUidNative();
+
+ /**
+ * Utility function to return the user id of the calling process.
+ * @return userId of the calling process, extracted from the callingUid
+ * @hide
+ */
+ public static final int getOrigCallingUser() {
+ return UserId.getUserId(getOrigCallingUid());
+ }
+
/**
* 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