diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index cea0b6b5f3ad5..88deec7b083ac 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -16,6 +16,7 @@ package android.content.pm; +import static android.Manifest.permission; import android.annotation.CallbackExecutor; import android.annotation.IntDef; import android.annotation.NonNull; @@ -485,11 +486,15 @@ public class LauncherApps { } /** - * Show an error log on logcat, when the calling user is a managed profile, and the target - * user is different from the calling user, in order to help developers to detect it. + * Show an error log on logcat, when the calling user is a managed profile, the target + * user is different from the calling user, and it is not called from a package that has the + * {@link permission.INTERACT_ACROSS_USERS_FULL} permission, in order to help + * developers to detect it. */ private void logErrorForInvalidProfileAccess(@NonNull UserHandle target) { - if (UserHandle.myUserId() != target.getIdentifier() && mUserManager.isManagedProfile()) { + if (UserHandle.myUserId() != target.getIdentifier() && mUserManager.isManagedProfile() + && mContext.checkSelfPermission(permission.INTERACT_ACROSS_USERS_FULL) + != PackageManager.PERMISSION_GRANTED) { Log.w(TAG, "Accessing other profiles/users from managed profile is no longer allowed."); } } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 181a32d062331..6206b57d97b38 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2377,6 +2377,7 @@ @hide --> +