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

Commit 4c269d7b authored by Ivan Chiang's avatar Ivan Chiang Committed by Android Build Coastguard Worker
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)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3bcfb940869219e379c0100e3f7c90b4daa46516)
Merged-In: Id4eb5484563fdec530d5fc89a2c5973c351fdab8
Change-Id: Id4eb5484563fdec530d5fc89a2c5973c351fdab8
parent c1aa9e66
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -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
@@ -182,14 +182,17 @@ public class UninstallerActivity extends Activity {
        if (mDialogInfo.user == null) {
            mDialogInfo.user = Process.myUserHandle();
        } else {
            List<UserHandle> profiles = userManager.getUserProfiles();
            if (!profiles.contains(mDialogInfo.user)) {
            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;
                }
            }
        }

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