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

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

Merge "resolve merge conflicts of 4b092e47 to master"

parents 22101e2f f95fb4fb
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -459,23 +459,19 @@ interface IPackageManager {

    /**
     * Ask the package manager to perform dex-opt (if needed) on the given
     * package and for the given instruction set if it already hasn't done
     * so.
     *
     * If the supplied instructionSet is null, the package manager will use
     * the packages default instruction set.
     * package if it already hasn't done so.
     *
     * In most cases, apps are dexopted in advance and this function will
     * be a no-op.
     */
    boolean performDexOptIfNeeded(String packageName, String instructionSet);
    boolean performDexOptIfNeeded(String packageName);

    /**
     * Ask the package manager to perform a dex-opt for the given reason. The package
     * manager will map the reason to a compiler filter according to the current system
     * configuration.
     */
    boolean performDexOpt(String packageName, String instructionSet, boolean checkProfiles,
    boolean performDexOpt(String packageName, boolean checkProfiles,
            int compileReason, boolean force);
    /**
     * Ask the package manager to perform a dex-opt with the given compiler filter.
@@ -483,7 +479,7 @@ interface IPackageManager {
     * Note: exposed only for the shell command to allow moving packages explicitly to a
     *       definite state.
     */
    boolean performDexOptMode(String packageName, String instructionSet, boolean checkProfiles,
    boolean performDexOptMode(String packageName, boolean checkProfiles,
            String targetCompilerFilter, boolean force);

    void forceDexOpt(String packageName);
+0 −2
Original line number Diff line number Diff line
@@ -154,7 +154,6 @@ public class BackgroundDexOptService extends JobService {
                    // behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
                    // trade-off worth doing to save boot time work.
                    pm.performDexOpt(pkg,
                            /* instruction set */ null,
                            /* checkProfiles */ false,
                            PackageManagerService.REASON_BOOT,
                            /* force */ false);
@@ -192,7 +191,6 @@ public class BackgroundDexOptService extends JobService {
                    // Optimize package if needed. Note that there can be no race between
                    // concurrent jobs because PackageDexOptimizer.performDexOpt is synchronized.
                    if (pm.performDexOpt(pkg,
                            /* instruction set */ null,
                            /* checkProfiles */ true,
                            PackageManagerService.REASON_BACKGROUND_DEXOPT,
                            /* force */ false)) {
+19 −23
Original line number Diff line number Diff line
@@ -7267,9 +7267,13 @@ public class PackageManagerService extends IPackageManager.Stub {
                }
            }
            // checkProfiles is false to avoid merging profiles during boot which
            // might interfere with background compilation (b/28612421).
            // Unfortunately this will also means that "pm.dexopt.boot=speed-profile" will
            // behave differently than "pm.dexopt.bg-dexopt=speed-profile" but that's a
            // trade-off worth doing to save boot time work.
            int dexOptStatus = performDexOptTraced(pkg.packageName,
                    null /* instructionSet */,
                    true /* checkProfiles */,
                    false /* checkProfiles */,
                    getCompilerFilterForReason(causeFirstBoot ? REASON_FIRST_BOOT : REASON_BOOT),
                    false /* force */);
            switch (dexOptStatus) {
@@ -7310,33 +7314,33 @@ public class PackageManagerService extends IPackageManager.Stub {
    // TODO: this is not used nor needed. Delete it.
    @Override
    public boolean performDexOptIfNeeded(String packageName, String instructionSet) {
        int dexOptStatus = performDexOptTraced(packageName, instructionSet,
    public boolean performDexOptIfNeeded(String packageName) {
        int dexOptStatus = performDexOptTraced(packageName,
                false /* checkProfiles */, getFullCompilerFilter(), false /* force */);
        return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
    }
    @Override
    public boolean performDexOpt(String packageName, String instructionSet,
    public boolean performDexOpt(String packageName,
            boolean checkProfiles, int compileReason, boolean force) {
        int dexOptStatus = performDexOptTraced(packageName, instructionSet, checkProfiles,
        int dexOptStatus = performDexOptTraced(packageName, checkProfiles,
                getCompilerFilterForReason(compileReason), force);
        return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
    }
    @Override
    public boolean performDexOptMode(String packageName, String instructionSet,
    public boolean performDexOptMode(String packageName,
            boolean checkProfiles, String targetCompilerFilter, boolean force) {
        int dexOptStatus = performDexOptTraced(packageName, instructionSet, checkProfiles,
        int dexOptStatus = performDexOptTraced(packageName, checkProfiles,
                targetCompilerFilter, force);
        return dexOptStatus != PackageDexOptimizer.DEX_OPT_FAILED;
    }
    private int performDexOptTraced(String packageName, String instructionSet,
    private int performDexOptTraced(String packageName,
                boolean checkProfiles, String targetCompilerFilter, boolean force) {
        Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
        try {
            return performDexOptInternal(packageName, instructionSet, checkProfiles,
            return performDexOptInternal(packageName, checkProfiles,
                    targetCompilerFilter, force);
        } finally {
            Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
@@ -7345,10 +7349,9 @@ public class PackageManagerService extends IPackageManager.Stub {
    // Run dexopt on a given package. Returns true if dexopt did not fail, i.e.
    // if the package can now be considered up to date for the given filter.
    private int performDexOptInternal(String packageName, String instructionSet,
    private int performDexOptInternal(String packageName,
                boolean checkProfiles, String targetCompilerFilter, boolean force) {
        PackageParser.Package p;
        final String targetInstructionSet;
        synchronized (mPackages) {
            p = mPackages.get(packageName);
            if (p == null) {
@@ -7356,15 +7359,11 @@ public class PackageManagerService extends IPackageManager.Stub {
                return PackageDexOptimizer.DEX_OPT_FAILED;
            }
            mPackageUsage.write(false);
            targetInstructionSet = instructionSet != null ? instructionSet :
                    getPrimaryInstructionSet(p.applicationInfo);
        }
        long callingId = Binder.clearCallingIdentity();
        try {
            synchronized (mInstallLock) {
                final String[] instructionSets = new String[] { targetInstructionSet };
                return performDexOptInternalWithDependenciesLI(p, instructionSets, checkProfiles,
                return performDexOptInternalWithDependenciesLI(p, checkProfiles,
                        targetCompilerFilter, force);
            }
        } finally {
@@ -7385,7 +7384,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    }
    private int performDexOptInternalWithDependenciesLI(PackageParser.Package p,
            String instructionSets[], boolean checkProfiles, String targetCompilerFilter,
            boolean checkProfiles, String targetCompilerFilter,
            boolean force) {
        // Select the dex optimizer based on the force parameter.
        // Note: The force option is rarely used (cmdline input for testing, mostly), so it's OK to
@@ -7397,6 +7396,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        // Optimize all dependencies first. Note: we ignore the return value and march on
        // on errors.
        Collection<PackageParser.Package> deps = findSharedNonSystemLibraries(p);
        final String[] instructionSets = getAppDexInstructionSets(p.applicationInfo);
        if (!deps.isEmpty()) {
            for (PackageParser.Package depPackage : deps) {
                // TODO: Analyze and investigate if we (should) profile libraries.
@@ -7406,7 +7406,6 @@ public class PackageManagerService extends IPackageManager.Stub {
                        getCompilerFilterForReason(REASON_NON_SYSTEM_LIBRARY));
            }
        }
        return pdo.performDexOpt(p, p.usesLibraryFiles, instructionSets, checkProfiles,
                targetCompilerFilter);
    }
@@ -7478,14 +7477,11 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
        synchronized (mInstallLock) {
            final String[] instructionSets = new String[] {
                    getPrimaryInstructionSet(pkg.applicationInfo) };
            Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
            // Whoever is calling forceDexOpt wants a fully compiled package.
            // Don't use profiles since that may cause compilation to be skipped.
            final int res = performDexOptInternalWithDependenciesLI(pkg, instructionSets,
            final int res = performDexOptInternalWithDependenciesLI(pkg,
                    false /* checkProfiles */, getCompilerFilterForReason(REASON_FORCED_DEXOPT),
                    true /* force */);
+1 −1
Original line number Diff line number Diff line
@@ -358,7 +358,7 @@ class PackageManagerShellCommand extends ShellCommand {
                mInterface.clearApplicationProfileData(packageName);
            }

            boolean result = mInterface.performDexOptMode(packageName, null /* instructionSet */,
            boolean result = mInterface.performDexOptMode(packageName,
                    checkProfiles, targetCompilerFilter, forceCompilation);
            if (!result) {
                failedPackages.add(packageName);