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

Commit 9db70d29 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Removing an extra installd call."

parents e07c0cff 54bc47ad
Loading
Loading
Loading
Loading
+8 −21
Original line number Diff line number Diff line
@@ -271,10 +271,7 @@ public class PackageDexOptimizer {
            return DEX_OPT_SKIPPED;
        }

        // TODO(calin): there's no need to try to create the oat dir over and over again,
        //              especially since it involve an extra installd call. We should create
        //              if (if supported) on the fly during the dexopt call.
        String oatDir = createOatDirIfSupported(pkg, isa);
        String oatDir = getPackageOatDirIfSupported(pkg);

        Log.i(TAG, "Running dexopt (dexoptNeeded=" + dexoptNeeded + ") on: " + path
                + " pkg=" + pkg.applicationInfo.packageName + " isa=" + isa
@@ -639,7 +636,7 @@ public class PackageDexOptimizer {
    }

    /**
     * Creates oat dir for the specified package if needed and supported.
     * Gets oat dir for the specified package if needed and supported.
     * In certain cases oat directory
     * <strong>cannot</strong> be created:
     * <ul>
@@ -647,29 +644,19 @@ public class PackageDexOptimizer {
     *      <li>Package location is not a directory, i.e. monolithic install.</li>
     * </ul>
     *
     * @return Absolute path to the oat directory or null, if oat directory
     * cannot be created.
     * @return Absolute path to the oat directory or null, if oat directories
     * not needed or unsupported for the package.
     */
    @Nullable
    private String createOatDirIfSupported(PackageParser.Package pkg, String dexInstructionSet) {
    private String getPackageOatDirIfSupported(PackageParser.Package pkg) {
        if (!pkg.canHaveOatDir()) {
            return null;
        }
        File codePath = new File(pkg.codePath);
        if (codePath.isDirectory()) {
            // TODO(calin): why do we create this only if the codePath is a directory? (i.e for
            //              cluster packages). It seems that the logic for the folder creation is
            //              split between installd and here.
            File oatDir = getOatDir(codePath);
            try {
                mInstaller.createOatDir(oatDir.getAbsolutePath(), dexInstructionSet);
            } catch (InstallerException e) {
                Slog.w(TAG, "Failed to create oat dir", e);
        if (!codePath.isDirectory()) {
            return null;
        }
            return oatDir.getAbsolutePath();
        }
        return null;
        return getOatDir(codePath).getAbsolutePath();
    }

    static File getOatDir(File codePath) {