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

Commit ffcd7a58 authored by Calin Juravle's avatar Calin Juravle
Browse files

Ensure that system server compiler filter is set to verify

It is useless to try a higher filter because system server cannot load
executable code. For now this is hard coded but we should consider making
it a system property to facilitate experiments.

Test: manual, DexManagerTests
Bug: 148774920
Change-Id: I10326823a1737b879f61eb4e1886f697807f1184
parent b1cdba13
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -79,6 +79,10 @@ public class DexManager {
    private static final String PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB_LIST =
            "pm.dexopt.priv-apps-oob-list";

    // System server cannot load executable code outside system partitions.
    // However it can load verification data - thus we pick the "verify" compiler filter.
    private static final String SYSTEM_SERVER_COMPILER_FILTER = "verify";

    private final Context mContext;

    // Maps package name to code locations.
@@ -501,8 +505,17 @@ public class DexManager {
            return PackageDexOptimizer.DEX_OPT_FAILED;
        }

        PackageDexOptimizer pdo = getPackageDexOptimizer(options);
        String packageName = options.getPackageName();
        // Override compiler filter for system server to the expected one.
        //
        // We could let the caller do this every time the invoke PackageManagerServer#dexopt.
        // However, there are a few places were this will need to be done which creates
        // redundancy and the danger of overlooking the config (and thus generating code that will
        // waste storage and time).
        DexoptOptions overriddenOptions = options.overrideCompilerFilter(
                SYSTEM_SERVER_COMPILER_FILTER);

        PackageDexOptimizer pdo = getPackageDexOptimizer(overriddenOptions);
        String packageName = overriddenOptions.getPackageName();
        PackageUseInfo useInfo = getPackageUseInfoOrDefault(packageName);
        if (useInfo.getDexUseInfoMap().isEmpty()) {
            if (DEBUG) {
@@ -527,7 +540,7 @@ public class DexManager {
                continue;
            }

            int newResult = pdo.dexoptSystemServerPath(dexPath, dexUseInfo, options);
            int newResult = pdo.dexoptSystemServerPath(dexPath, dexUseInfo, overriddenOptions);

            // The end result is:
            //  - FAILED if any path failed,
+13 −0
Original line number Diff line number Diff line
@@ -166,4 +166,17 @@ public final class DexoptOptions {
    public int getCompilationReason() {
        return mCompilationReason;
    }

    /**
     * Creates a new set of DexoptOptions which are the same with the exception of the compiler
     * filter (set to the given value).
     */
    public DexoptOptions overrideCompilerFilter(String newCompilerFilter) {
        return new DexoptOptions(
                mPackageName,
                mCompilationReason,
                newCompilerFilter,
                mSplitName,
                mFlags);
    }
}