Skip to content

Commit acd9811

Browse files
quh4gko8thestinger
authored andcommitted
Enforce cross profile clipboard access settings
1 parent 2d3d1f3 commit acd9811

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

services/core/java/com/android/server/clipboard/ClipboardService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,10 @@ private void setPrimaryClipInternalLocked(
953953
}
954954
setPrimaryClipInternalLocked(clipboard, clip, uid, sourcePackage);
955955

956+
if (!android.ext.settings.CrossProfileClipboardAccessSettings
957+
.isExportAccessAllowed(getContext(), userId)) {
958+
return;
959+
}
956960
// Update related users
957961
List<UserInfo> related = getRelatedProfiles(userId);
958962
if (related != null) {
@@ -984,6 +988,10 @@ private void setPrimaryClipInternalLocked(
984988
if (id != userId) {
985989
final boolean canCopyIntoProfile = !hasRestriction(
986990
UserManager.DISALLOW_SHARE_INTO_MANAGED_PROFILE, id);
991+
if (!android.ext.settings.CrossProfileClipboardAccessSettings
992+
.isImportAccessAllowed(getContext(), id)) {
993+
continue;
994+
}
987995
if (canCopyIntoProfile) {
988996
Clipboard relatedClipboard = getClipboardLocked(id, deviceId);
989997
if (relatedClipboard != null) {

services/core/java/com/android/server/wm/DragState.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ void broadcastDragStartedLocked(final float touchX, final float touchY) {
500500
final UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class);
501501
mCrossProfileCopyAllowed = !userManager.getUserRestriction(
502502
mSourceUserId, UserManager.DISALLOW_CROSS_PROFILE_COPY_PASTE);
503+
if (!android.ext.settings.CrossProfileClipboardAccessSettings
504+
.isExportAccessAllowed(mDisplayContent.mAtmService.mContext, mSourceUserId)) {
505+
mCrossProfileCopyAllowed = false;
506+
}
503507

504508
if (DEBUG_DRAG) {
505509
Slog.d(TAG_WM, "Broadcasting DRAG_STARTED at (" + touchX + ", " + touchY + ")");

0 commit comments

Comments
 (0)