Merge "Add Binder.getCallingUserHandle()." into jb-mr1-dev
diff --git a/api/current.txt b/api/current.txt
index b89f2f4..9d7bb14 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15617,6 +15617,7 @@
method public static final void flushPendingCommands();
method public static final int getCallingPid();
method public static final int getCallingUid();
+ method public static final android.os.UserHandle getCallingUserHandle();
method public java.lang.String getInterfaceDescriptor();
method public boolean isBinderAlive();
method public static final void joinThreadPool();
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 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 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
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 90e8d73..ca45946 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -10851,7 +10851,7 @@
builder.append("; this requires ");
builder.append(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL);
if (!requireFull) {
- builder.append("or");
+ builder.append(" or ");
builder.append(android.Manifest.permission.INTERACT_ACROSS_USERS);
}
String msg = builder.toString();