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

Commit 80f593d4 authored by Calin Juravle's avatar Calin Juravle Committed by Automerger Merge Worker
Browse files

Merge changes from topics "delete_odex", "verify-prof" am: 4ebbeba9 am: d9a207e9 am: 66286842

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1735259

Change-Id: I88c04c0bbefdc6857219523dcb9731ee98e7117b
parents fccfdd77 66286842
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -665,13 +665,17 @@ public class Installer extends SystemService {
        }
        }
    }
    }


    public void deleteOdex(String apkPath, String instructionSet, String outputPath)
    /**
     * Deletes the optimized artifacts generated by ART and returns the number
     * of freed bytes.
     */
    public long deleteOdex(String apkPath, String instructionSet, String outputPath)
            throws InstallerException {
            throws InstallerException {
        if (!checkBeforeRemote()) return;
        if (!checkBeforeRemote()) return -1;
        BlockGuard.getVmPolicy().onPathAccess(apkPath);
        BlockGuard.getVmPolicy().onPathAccess(apkPath);
        BlockGuard.getVmPolicy().onPathAccess(outputPath);
        BlockGuard.getVmPolicy().onPathAccess(outputPath);
        try {
        try {
            mInstalld.deleteOdex(apkPath, instructionSet, outputPath);
            return mInstalld.deleteOdex(apkPath, instructionSet, outputPath);
        } catch (Exception e) {
        } catch (Exception e) {
            throw InstallerException.from(e);
            throw InstallerException.from(e);
        }
        }
+2 −2
Original line number Original line Diff line number Diff line
@@ -28391,14 +28391,14 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        }
    }
    }
    void deleteOatArtifactsOfPackage(String packageName) {
    long deleteOatArtifactsOfPackage(String packageName) {
        final AndroidPackage pkg;
        final AndroidPackage pkg;
        final PackageSetting pkgSetting;
        final PackageSetting pkgSetting;
        synchronized (mLock) {
        synchronized (mLock) {
            pkg = mPackages.get(packageName);
            pkg = mPackages.get(packageName);
            pkgSetting = mSettings.getPackageLPr(packageName);
            pkgSetting = mSettings.getPackageLPr(packageName);
        }
        }
        mDexManager.deleteOptimizedFiles(ArtUtils.createArtPackageInfo(pkg, pkgSetting));
        return mDexManager.deleteOptimizedFiles(ArtUtils.createArtPackageInfo(pkg, pkgSetting));
    }
    }
    Set<String> getUnusedPackages(long downgradeTimeThresholdMillis) {
    Set<String> getUnusedPackages(long downgradeTimeThresholdMillis) {
+10 −2
Original line number Original line Diff line number Diff line
@@ -1034,18 +1034,26 @@ public class DexManager {


    /**
    /**
     * Deletes all the optimizations files generated by ART.
     * Deletes all the optimizations files generated by ART.
     * This is best effort, and the method will log but not throw errors
     * for individual deletes
     *
     * @param packageInfo the package information.
     * @param packageInfo the package information.
     * @return the number of freed bytes or -1 if there was an error in the process.
     */
     */
    public void deleteOptimizedFiles(ArtPackageInfo packageInfo) {
    public long deleteOptimizedFiles(ArtPackageInfo packageInfo) {
        long freedBytes = 0;
        boolean hadErrors = false;
        for (String codePath : packageInfo.getCodePaths()) {
        for (String codePath : packageInfo.getCodePaths()) {
            for (String isa : packageInfo.getInstructionSets()) {
            for (String isa : packageInfo.getInstructionSets()) {
                try {
                try {
                    mInstaller.deleteOdex(codePath, isa, packageInfo.getOatDir());
                    freedBytes += mInstaller.deleteOdex(codePath, isa, packageInfo.getOatDir());
                } catch (InstallerException e) {
                } catch (InstallerException e) {
                    Log.e(TAG, "Failed deleting oat files for " + codePath, e);
                    Log.e(TAG, "Failed deleting oat files for " + codePath, e);
                    hadErrors = true;
                }
                }
            }
            }
        }
        }
        return hadErrors ? -1 : freedBytes;
    }
    }


    public static class RegisterDexModuleResult {
    public static class RegisterDexModuleResult {