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

Commit 1fdf0843 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

[PM] Fix the profile issue for PIA V2

Only the parent profile can uninstall the app that is in the child
profiles.

Flag: android.content.pm.use_pia_v2
Bug: 333681693
Bug: 423034415
Test: atest CtsPackageInstallerCUJMultiUsersTestCases
Change-Id: Ia1dcac1b7b5cc54c49e55007231875b9256f9716
parent e608e21b
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -144,8 +144,10 @@ class UninstallRepository(private val context: Context) {
        if (uninstalledUser == null) {
            uninstalledUser = Process.myUserHandle()
        } else {
            val profiles = userManager!!.userProfiles
            if (!profiles.contains(uninstalledUser)) {
            if (uninstalledUser!! != Process.myUserHandle()) {
                val isCurrentUserProfileOwner =
                    Process.myUserHandle() == userManager!!.getProfileParent(uninstalledUser!!)
                if (!isCurrentUserProfileOwner) {
                    Log.e(
                        LOG_TAG,
                        "User " + Process.myUserHandle() + " can't request uninstall " +
@@ -154,6 +156,7 @@ class UninstallRepository(private val context: Context) {
                    return UninstallAborted(UninstallAborted.ABORT_REASON_USER_NOT_ALLOWED)
                }
            }
        }

        callback = intent.getParcelableExtra(
            PackageInstaller.EXTRA_CALLBACK, PackageManager.UninstallCompleteCallback::class.java