Skip to content

Commit 5d75052

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Add Binder.getCallingUserHandle()." into jb-mr1-dev
2 parents ddb12e8 + 74ee865 commit 5d75052

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15617,6 +15617,7 @@ package android.os {
1561715617
method public static final void flushPendingCommands();
1561815618
method public static final int getCallingPid();
1561915619
method public static final int getCallingUid();
15620+
method public static final android.os.UserHandle getCallingUserHandle();
1562015621
method public java.lang.String getInterfaceDescriptor();
1562115622
method public boolean isBinderAlive();
1562215623
method public static final void joinThreadPool();

core/java/android/os/Binder.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,26 @@ public class Binder implements IBinder {
6464
public static final native int getCallingPid();
6565

6666
/**
67-
* Return the ID of the user assigned to the process that sent you the
67+
* Return the Linux uid assigned to the process that sent you the
6868
* current transaction that is being processed. This uid can be used with
6969
* higher-level system services to determine its identity and check
7070
* permissions. If the current thread is not currently executing an
7171
* incoming transaction, then its own uid is returned.
7272
*/
7373
public static final native int getCallingUid();
7474

75+
/**
76+
* Return the UserHandle assigned to the process that sent you the
77+
* current transaction that is being processed. This is the user
78+
* of the caller. It is distinct from {@link #getCallingUid()} in that a
79+
* particular user will have multiple distinct apps running under it each
80+
* with their own uid. If the current thread is not currently executing an
81+
* incoming transaction, then its own UserHandle is returned.
82+
*/
83+
public static final UserHandle getCallingUserHandle() {
84+
return new UserHandle(UserHandle.getUserId(getCallingUid()));
85+
}
86+
7587
/**
7688
* Reset the identity of the incoming IPC on the current thread. This can
7789
* be useful if, while handling an incoming call, you will be calling

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10851,7 +10851,7 @@ && checkComponentPermission(
1085110851
builder.append("; this requires ");
1085210852
builder.append(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL);
1085310853
if (!requireFull) {
10854-
builder.append("or");
10854+
builder.append(" or ");
1085510855
builder.append(android.Manifest.permission.INTERACT_ACROSS_USERS);
1085610856
}
1085710857
String msg = builder.toString();

0 commit comments

Comments
 (0)