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

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

Merge "Copy preopted profiles to ref for first boot"

parents 36310290 235845dc
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -310,6 +310,16 @@ public class Installer extends SystemService {
        }
    }

    public boolean copySystemProfile(String systemProfile, int uid, String packageName)
            throws InstallerException {
        if (!checkBeforeRemote()) return false;
        try {
            return mInstalld.copySystemProfile(systemProfile, uid, packageName);
        } catch (Exception e) {
            throw InstallerException.from(e);
        }
    }

    public void idmap(String targetApkPath, String overlayApkPath, int uid)
            throws InstallerException {
        if (!checkBeforeRemote()) return;
+28 −0
Original line number Diff line number Diff line
@@ -8695,6 +8695,13 @@ public class PackageManagerService extends IPackageManager.Stub
        MetricsLogger.histogram(mContext, "opt_dialog_time_s", elapsedTimeSeconds);
    }
    /*
     * Return the prebuilt profile path given a package base code path.
     */
    private static String getPrebuildProfilePath(PackageParser.Package pkg) {
        return pkg.baseCodePath + ".prof";
    }
    /**
     * Performs dexopt on the set of packages in {@code packages} and returns an int array
     * containing statistics about the invocation. The array consists of three elements,
@@ -8713,6 +8720,27 @@ public class PackageManagerService extends IPackageManager.Stub
        for (PackageParser.Package pkg : pkgs) {
            numberOfPackagesVisited++;
            if ((isFirstBoot() || isUpgrade()) && isSystemApp(pkg)) {
                // Copy over initial preopt profiles since we won't get any JIT samples for methods
                // that are already compiled.
                File profileFile = new File(getPrebuildProfilePath(pkg));
                // Copy profile if it exists.
                if (profileFile.exists()) {
                    try {
                        // We could also do this lazily before calling dexopt in
                        // PackageDexOptimizer to prevent this happening on first boot. The issue
                        // is that we don't have a good way to say "do this only once".
                        if (!mInstaller.copySystemProfile(profileFile.getAbsolutePath(),
                                pkg.applicationInfo.uid, pkg.packageName)) {
                            Log.e(TAG, "Installer failed to copy system profile!");
                        }
                    } catch (Exception e) {
                        Log.e(TAG, "Failed to copy profile " + profileFile.getAbsolutePath() + " ",
                                e);
                    }
                }
            }
            if (!PackageDexOptimizer.canOptimizePackage(pkg)) {
                if (DEBUG_DEXOPT) {
                    Log.i(TAG, "Skipping update of of non-optimizable app " + pkg.packageName);