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

Commit 7dc6c202 authored by William Loh's avatar William Loh
Browse files

Fix incremental installs with app metadata bundles

Check for the app metadata file in the correct location for incremental
installs when validating the install.

Bug: 344760207
Test: atest InstallAppMetadataTest
Change-Id: I33d3eb6bdc038969471c15bacb279aab15553e3d
parent fda0d93b
Loading
Loading
Loading
Loading
+10 −7
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ import static android.content.pm.PackageManager.INSTALL_FAILED_INVALID_APK;
import static android.content.pm.PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE;
import static android.content.pm.PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE;
import static android.content.pm.PackageManager.INSTALL_FAILED_MISSING_SPLIT;
import static android.content.pm.PackageManager.INSTALL_FAILED_MISSING_SPLIT;
import static android.content.pm.PackageManager.INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE;
import static android.content.pm.PackageManager.INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE;
import static android.content.pm.PackageManager.INSTALL_FAILED_SESSION_INVALID;
import static android.content.pm.PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE;
import static android.content.pm.PackageManager.INSTALL_FAILED_VERIFICATION_FAILURE;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
import static android.content.pm.PackageManager.INSTALL_STAGED;
import static android.content.pm.PackageManager.INSTALL_STAGED;
@@ -3459,11 +3460,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            }
            }
        }
        }


        if (mHasAppMetadataFile && !getStagedAppMetadataFile().exists()) {
            throw new PackageManagerException(INSTALL_FAILED_VERIFICATION_FAILURE,
                    "App metadata file expected but not found in " + stageDir.getAbsolutePath());
        }

        final List<ApkLite> addedFiles = getAddedApkLitesLocked();
        final List<ApkLite> addedFiles = getAddedApkLitesLocked();
        if (addedFiles.isEmpty()
        if (addedFiles.isEmpty()
                && (removeSplitList.size() == 0 || mHasAppMetadataFile)) {
                && (removeSplitList.size() == 0 || mHasAppMetadataFile)) {
@@ -3593,6 +3589,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            }
            }
        }
        }


        File stagedAppMetadataFile = isIncrementalInstallation()
                ? getTmpAppMetadataFile() : getStagedAppMetadataFile();
        if (mHasAppMetadataFile && !stagedAppMetadataFile.exists()) {
            throw new PackageManagerException(INSTALL_FAILED_SESSION_INVALID,
                    "App metadata file expected but not found in " + stageDir.getAbsolutePath());
        }

        if (isIncrementalInstallation()) {
        if (isIncrementalInstallation()) {
            if (!isIncrementalInstallationAllowed(existingPkgSetting)) {
            if (!isIncrementalInstallationAllowed(existingPkgSetting)) {
                throw new PackageManagerException(
                throw new PackageManagerException(
@@ -3601,8 +3604,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            }
            }
            // Since we moved the staged app metadata file so that incfs can be initialized, lets
            // Since we moved the staged app metadata file so that incfs can be initialized, lets
            // now move it back.
            // now move it back.
            if (mHasAppMetadataFile) {
                File appMetadataFile = getTmpAppMetadataFile();
                File appMetadataFile = getTmpAppMetadataFile();
            if (appMetadataFile.exists()) {
                final IncrementalFileStorages incrementalFileStorages =
                final IncrementalFileStorages incrementalFileStorages =
                        getIncrementalFileStorages();
                        getIncrementalFileStorages();
                try {
                try {