summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ivan Chiang <chiangi@google.com> 2024-12-24 08:22:39 +0000
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-01-13 11:44:16 -0800
commit5f3e7eb481fcccc0131b16926d7cc1c523a357cf (patch)
tree17eca7e375bfe45507796ce91bf7633756e0bb63
parent9629d2bde138c17d67312270dd8e163b0c01cae0 (diff)
[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
-rw-r--r--packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java
index 170cb4546d0c..551f52301b56 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java
@@ -47,19 +47,19 @@ import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
+
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
+
+import com.android.packageinstaller.common.EventResultPersister;
+import com.android.packageinstaller.common.UninstallEventReceiver;
import com.android.packageinstaller.handheld.ErrorDialogFragment;
import com.android.packageinstaller.handheld.UninstallAlertDialogFragment;
import com.android.packageinstaller.television.ErrorFragment;
import com.android.packageinstaller.television.UninstallAlertFragment;
import com.android.packageinstaller.television.UninstallAppProgress;
-import com.android.packageinstaller.common.EventResultPersister;
-import com.android.packageinstaller.common.UninstallEventReceiver;
import com.android.packageinstaller.v2.ui.UninstallLaunch;
-import java.util.List;
-
/*
* This activity presents UI to uninstall an application. Usually launched with intent
* Intent.ACTION_UNINSTALL_PKG_COMMAND and attribute
@@ -181,12 +181,15 @@ public class UninstallerActivity extends Activity {
if (mDialogInfo.user == null) {
mDialogInfo.user = Process.myUserHandle();
} else {
- List<UserHandle> 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 != Process.myUserHandle()) {
+ final boolean isCurrentUserProfileOwner =
+ (Process.myUserHandle() == userManager.getProfileParent(mDialogInfo.user));
+ if (!isCurrentUserProfileOwner) {
+ Log.e(TAG, "User " + Process.myUserHandle() + " can't request uninstall "
+ + "for user " + mDialogInfo.user);
+ showUserIsNotAllowed();
+ return;
+ }
}
}