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

Commit 19a092cb authored by Rhed Jao's avatar Rhed Jao
Browse files

Fixes testRequiredSplitRemoved failed in SplitTests

Enables to remove one of the splits for the case of
split required, but not to remove all of them.

Bug: 172205977
Test: atest SplitTests
Change-Id: I27dab47cc7a8b86084fbc8060e6635ff206175f2
parent c44ef9e2
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -2536,6 +2536,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                throw new PackageManagerException(INSTALL_FAILED_INVALID_APK,
                        "Full install must include a base package");
            }
            if (baseApk.isSplitRequired && stagedSplits.size() <= 1) {
                throw new PackageManagerException(INSTALL_FAILED_MISSING_SPLIT,
                        "Missing split for " + mPackageName);
            }
        } else {
            final ApplicationInfo appInfo = pkgInfo.applicationInfo;
            ParseResult<PackageLite> pkgLiteResult = ApkLiteParseUtils.parsePackageLite(
@@ -2646,6 +2650,17 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                    mResolvedInheritedFiles.addAll(libFilesToInherit);
                }
            }
            // For the case of split required, failed if no splits existed
            if (baseApk.isSplitRequired) {
                final int existingSplits = ArrayUtils.size(existing.splitNames);
                final boolean allSplitsRemoved = (existingSplits == removeSplitList.size());
                final boolean onlyBaseFileStaged = (stagedSplits.size() == 1
                        && stagedSplits.contains(null));
                if (allSplitsRemoved && (stagedSplits.isEmpty() || onlyBaseFileStaged)) {
                    throw new PackageManagerException(INSTALL_FAILED_MISSING_SPLIT,
                            "Missing split for " + mPackageName);
                }
            }
        }
        if (baseApk.useEmbeddedDex) {
            for (File file : mResolvedStagedFiles) {
@@ -2657,10 +2672,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                }
            }
        }
        if (baseApk.isSplitRequired && stagedSplits.size() <= 1) {
            throw new PackageManagerException(INSTALL_FAILED_MISSING_SPLIT,
                    "Missing split for " + mPackageName);
        }

        final boolean isInstallerShell = (mInstallerUid == Process.SHELL_UID);
        if (isInstallerShell && isIncrementalInstallation() && mIncrementalFileStorages != null) {