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

Commit f3f7057d authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] skip the second user confirmation for unarchive with REQUEST_INSTALL_PACKAGES

For unarchive installers with a weaker permission, there's already a
confirmation dialog prompted to the user at the beginning of unarchive.
There's no need for a second user confirmation during the installation.

BUG: 311709794
Test: atest android.packageinstaller.uninstall.cts.ArchiveTest#unarchiveApp_weakPermissions

Change-Id: Ic2495b3ac964899c67fe52e92f9d3cc794d20256
parent 28b92c63
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -1085,11 +1085,17 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        final boolean isUpdateOwnershipEnforcementEnabled =
        final boolean isUpdateOwnershipEnforcementEnabled =
                mPm.isUpdateOwnershipEnforcementAvailable()
                mPm.isUpdateOwnershipEnforcementAvailable()
                        && existingUpdateOwnerPackageName != null;
                        && existingUpdateOwnerPackageName != null;
        // For an installation that un-archives an app, if the installer doesn't have the
        // INSTALL_PACKAGES permission, the user should have already been prompted to confirm the
        // un-archive request. There's no need for another confirmation during the installation.
        final boolean isInstallUnarchive =
                (params.installFlags & PackageManager.INSTALL_UNARCHIVE) != 0;


        // Device owners and affiliated profile owners are allowed to silently install packages, so
        // Device owners and affiliated profile owners are allowed to silently install packages, so
        // the permission check is waived if the installer is the device owner.
        // the permission check is waived if the installer is the device owner.
        final boolean noUserActionNecessary = isInstallerRoot || isInstallerSystem
        final boolean noUserActionNecessary = isInstallerRoot || isInstallerSystem
                || isInstallerDeviceOwnerOrAffiliatedProfileOwner() || isEmergencyInstall;
                || isInstallerDeviceOwnerOrAffiliatedProfileOwner() || isEmergencyInstall
                || isInstallUnarchive;


        if (noUserActionNecessary) {
        if (noUserActionNecessary) {
            return userActionNotTypicallyNeededResponse;
            return userActionNotTypicallyNeededResponse;