Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a30de548 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

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
parent 554705dd
Loading
Loading
Loading
Loading
+9 −8
Original line number Original line Diff line number Diff line
@@ -56,8 +56,6 @@ import com.android.packageinstaller.television.ErrorFragment;
import com.android.packageinstaller.television.UninstallAlertFragment;
import com.android.packageinstaller.television.UninstallAlertFragment;
import com.android.packageinstaller.television.UninstallAppProgress;
import com.android.packageinstaller.television.UninstallAppProgress;


import java.util.List;

/*
/*
 * This activity presents UI to uninstall an application. Usually launched with intent
 * This activity presents UI to uninstall an application. Usually launched with intent
 * Intent.ACTION_UNINSTALL_PKG_COMMAND and attribute
 * Intent.ACTION_UNINSTALL_PKG_COMMAND and attribute
@@ -162,14 +160,17 @@ public class UninstallerActivity extends Activity {
        if (mDialogInfo.user == null) {
        if (mDialogInfo.user == null) {
            mDialogInfo.user = Process.myUserHandle();
            mDialogInfo.user = Process.myUserHandle();
        } else {
        } else {
            List<UserHandle> profiles = userManager.getUserProfiles();
            if (!mDialogInfo.user.equals(Process.myUserHandle())) {
            if (!profiles.contains(mDialogInfo.user)) {
                final boolean isCurrentUserProfileOwner = Process.myUserHandle().equals(
                        userManager.getProfileParent(mDialogInfo.user));
                if (!isCurrentUserProfileOwner) {
                    Log.e(TAG, "User " + Process.myUserHandle() + " can't request uninstall "
                    Log.e(TAG, "User " + Process.myUserHandle() + " can't request uninstall "
                            + "for user " + mDialogInfo.user);
                            + "for user " + mDialogInfo.user);
                    showUserIsNotAllowed();
                    showUserIsNotAllowed();
                    return;
                    return;
                }
                }
            }
            }
        }


        mDialogInfo.callback = intent.getParcelableExtra(PackageInstaller.EXTRA_CALLBACK,
        mDialogInfo.callback = intent.getParcelableExtra(PackageInstaller.EXTRA_CALLBACK,
                                            PackageManager.UninstallCompleteCallback.class);
                                            PackageManager.UninstallCompleteCallback.class);