From a6a7d2e1966739708a1f3be20110fc5b29fd71b7 Mon Sep 17 00:00:00 2001 From: Ivan Chiang Date: Tue, 24 Dec 2024 08:22:39 +0000 Subject: RESTRICT AUTOMERGE [PM] Fix the profile issue in UninstallerActivity Only the parent profile can uninstall the app that is in the child profiles. Flag: EXEMPT security bug fix Bug: 333681693 Test: atest CtsPackageInstallerCUJMultiUsersTestCases (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:585d5d6835dd2ddd65316fbbabd714c140da20fa) Merged-In: Id4eb5484563fdec530d5fc89a2c5973c351fdab8 Change-Id: Id4eb5484563fdec530d5fc89a2c5973c351fdab8 --- .../android/packageinstaller/UninstallerActivity.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java index 9c67817cbef4..bf3bc8e7dcb3 100644 --- a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java +++ b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java @@ -56,8 +56,6 @@ import com.android.packageinstaller.television.ErrorFragment; import com.android.packageinstaller.television.UninstallAlertFragment; import com.android.packageinstaller.television.UninstallAppProgress; -import java.util.List; - /* * This activity presents UI to uninstall an application. Usually launched with intent * Intent.ACTION_UNINSTALL_PKG_COMMAND and attribute @@ -162,12 +160,15 @@ public class UninstallerActivity extends Activity { if (mDialogInfo.user == null) { mDialogInfo.user = Process.myUserHandle(); } else { - List profiles = userManager.getUserProfiles(); - if (!profiles.contains(mDialogInfo.user)) { - Log.e(TAG, "User " + Process.myUserHandle() + " can't request uninstall " - + "for user " + mDialogInfo.user); - showUserIsNotAllowed(); - return; + if (!mDialogInfo.user.equals(Process.myUserHandle())) { + final boolean isCurrentUserProfileOwner = Process.myUserHandle().equals( + userManager.getProfileParent(mDialogInfo.user)); + if (!isCurrentUserProfileOwner) { + Log.e(TAG, "User " + Process.myUserHandle() + " can't request uninstall " + + "for user " + mDialogInfo.user); + showUserIsNotAllowed(); + return; + } } } -- cgit v1.2.3-59-g8ed1b