Skip to content

Commit a99e4ca

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Bind to screenshot service for current user." into jb-mr1-dev
2 parents 7808581 + 35744c1 commit a99e4ca

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3141,7 +3141,8 @@ public void handleMessage(Message msg) {
31413141
@Override
31423142
public void onServiceDisconnected(ComponentName name) {}
31433143
};
3144-
if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) {
3144+
if (mContext.bindService(
3145+
intent, conn, Context.BIND_AUTO_CREATE, UserHandle.USER_CURRENT)) {
31453146
mScreenshotConnection = conn;
31463147
mHandler.postDelayed(mScreenshotTimeout, 10000);
31473148
}

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10742,7 +10742,25 @@ public int bindService(IApplicationThread caller, IBinder token,
1074210742
throw new IllegalArgumentException("File descriptors passed in Intent");
1074310743
}
1074410744

10745-
checkValidCaller(Binder.getCallingUid(), userId);
10745+
if (userId != UserHandle.getCallingUserId()) {
10746+
// Requesting a different user, make sure that they have permission
10747+
if (checkComponentPermission(
10748+
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
10749+
Binder.getCallingPid(), Binder.getCallingUid(), -1, true)
10750+
== PackageManager.PERMISSION_GRANTED) {
10751+
// Translate to the current user id, if caller wasn't aware
10752+
if (userId == UserHandle.USER_CURRENT) {
10753+
userId = mCurrentUserId;
10754+
}
10755+
} else {
10756+
String msg = "Permission Denial: Request to bindService as user " + userId
10757+
+ " but is calling from user " + UserHandle.getCallingUserId()
10758+
+ "; this requires "
10759+
+ android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
10760+
Slog.w(TAG, msg);
10761+
throw new SecurityException(msg);
10762+
}
10763+
}
1074610764

1074710765
synchronized(this) {
1074810766
return mServices.bindServiceLocked(caller, token, service, resolvedType,

0 commit comments

Comments
 (0)