From 1cc6671bf3252a5c02d78ba4d992ad59ba26b8ba Mon Sep 17 00:00:00 2001 From: Oli Lan Date: Mon, 1 Mar 2021 14:15:04 +0000 Subject: [PATCH] Fix cross-user clipboard issue. This fixes an issue that caused cross-profile clipboard access to break, and the test ManagedProfileCrossProfileTest# testCrossProfileCopyPaste to fail. Bug: 181360460 Test: atest ManagedProfileCrossProfileTest#testCrossProfileCopyPaste Change-Id: I72c87a5b026c2ff383f995d593d60e9226510a0d --- .../java/com/android/server/clipboard/ClipboardService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java index 2de709ebe71da..42fcd4460386f 100644 --- a/services/core/java/com/android/server/clipboard/ClipboardService.java +++ b/services/core/java/com/android/server/clipboard/ClipboardService.java @@ -880,8 +880,8 @@ public class ClipboardService extends SystemService { CharSequence sourceAppLabel = null; if (clipboard.mPrimaryClipPackage != null) { try { - sourceAppLabel = mPm.getApplicationLabel( - mPm.getApplicationInfo(clipboard.mPrimaryClipPackage, 0)); + sourceAppLabel = mPm.getApplicationLabel(mPm.getApplicationInfoAsUser( + clipboard.mPrimaryClipPackage, 0, userId)); } catch (PackageManager.NameNotFoundException e) { // leave label as null } @@ -889,7 +889,7 @@ public class ClipboardService extends SystemService { try { CharSequence callingAppLabel = mPm.getApplicationLabel( - mPm.getApplicationInfo(callingPackage, 0)); + mPm.getApplicationInfoAsUser(callingPackage, 0, userId)); String message; if (sourceAppLabel != null) { message = callingAppLabel + " pasted from " + sourceAppLabel;