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
This commit is contained in:
Oli Lan
2021-03-01 14:15:04 +00:00
parent 949bcca3ad
commit 1cc6671bf3

View File

@@ -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;