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

Commit ba653901 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update InstallLocationUtils.calculateInstalledSize." into main

parents 38559184 065913b5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -349,3 +349,11 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "alternative_for_dexopt_cleanup"
    namespace: "art_cloud"
    description: "Flag guarding the alternative code path replacing the legacy dexopt code, to allow legacy dexopt cleanup."
    bug: "258223472"
    is_fixed_read_only: true
}
+26 −7
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@ import libcore.io.IoUtils;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.UUID;

@@ -445,6 +449,20 @@ public class InstallLocationUtils {
            String abiOverride) throws IOException {
        long sizeBytes = 0;

        if (android.content.pm.Flags.alternativeForDexoptCleanup()) {
            Path path = pkg.getPath() != null ? Paths.get(pkg.getPath()) : null;
            if (path == null || !Files.isDirectory(path)) { // monolithic
                sizeBytes += Files.size(Paths.get(pkg.getBaseApkPath()));
            } else { // cluster
                try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
                    for (Path child : stream) {
                        if (!Files.isDirectory(child)) {
                            sizeBytes += Files.size(child);
                        }
                    }
                }
            }
        } else {
            // Include raw APKs, and possibly unpacked resources
            for (String codePath : pkg.getAllApkPaths()) {
                final File codeFile = new File(codePath);
@@ -453,6 +471,7 @@ public class InstallLocationUtils {

            // Include raw dex metadata files
            sizeBytes += DexMetadataHelper.getPackageDexMetadataSize(pkg);
        }

        if (pkg.isExtractNativeLibs()) {
            // Include all relevant native code