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

Commit 85e45048 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:4e97e828c996fbcb5f9a2491bf5ce45bbe9136b5)
Merged-In: Id4eb5484563fdec530d5fc89a2c5973c351fdab8
Change-Id: Id4eb5484563fdec530d5fc89a2c5973c351fdab8
parent 93f8c8b0
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -63,8 +64,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
@@ -172,15 +171,18 @@ public class UninstallerActivity extends Activity {
        if (mDialogInfo.user == null) {
            mDialogInfo.user = android.os.Process.myUserHandle();
        } else {
            UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
            List<UserHandle> profiles = userManager.getUserProfiles();
            if (!profiles.contains(mDialogInfo.user)) {
                Log.e(TAG, "User " + android.os.Process.myUserHandle() + " can't request uninstall "
            if (!mDialogInfo.user.equals(Process.myUserHandle())) {
                UserManager userManager = getBaseContext().getSystemService(UserManager.class);
                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.getIBinderExtra(PackageInstaller.EXTRA_CALLBACK);