Skip to content

Commit 35744c1

Browse files
committed
Bind to screenshot service for current user.
Let apps bindService() across user boundaries if they hold the INTERACT_ACROSS_USERS_FULL permission. Bug: 7012034 Change-Id: I2047d8318e1de47bfae7470d1dbc6fe5cfe44fdc
1 parent 0d43c56 commit 35744c1

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
@@ -3134,7 +3134,8 @@ public void handleMessage(Message msg) {
31343134
@Override
31353135
public void onServiceDisconnected(ComponentName name) {}
31363136
};
3137-
if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) {
3137+
if (mContext.bindService(
3138+
intent, conn, Context.BIND_AUTO_CREATE, UserHandle.USER_CURRENT)) {
31383139
mScreenshotConnection = conn;
31393140
mHandler.postDelayed(mScreenshotTimeout, 10000);
31403141
}

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

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

10676-
checkValidCaller(Binder.getCallingUid(), userId);
10676+
if (userId != UserHandle.getCallingUserId()) {
10677+
// Requesting a different user, make sure that they have permission
10678+
if (checkComponentPermission(
10679+
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
10680+
Binder.getCallingPid(), Binder.getCallingUid(), -1, true)
10681+
== PackageManager.PERMISSION_GRANTED) {
10682+
// Translate to the current user id, if caller wasn't aware
10683+
if (userId == UserHandle.USER_CURRENT) {
10684+
userId = mCurrentUserId;
10685+
}
10686+
} else {
10687+
String msg = "Permission Denial: Request to bindService as user " + userId
10688+
+ " but is calling from user " + UserHandle.getCallingUserId()
10689+
+ "; this requires "
10690+
+ android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
10691+
Slog.w(TAG, msg);
10692+
throw new SecurityException(msg);
10693+
}
10694+
}
1067710695

1067810696
synchronized(this) {
1067910697
return mServices.bindServiceLocked(caller, token, service, resolvedType,

0 commit comments

Comments
 (0)