summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2020-04-09 20:05:33 -0700
committer Calin Juravle <calin@google.com> 2020-04-14 18:26:49 -0700
commitffcd7a586bcea521a6d47f9f36fc5c08764eb9a7 (patch)
treeb51d811637905ac6cae6bc60e44ace1d91e78b22
parentb1cdba13f08a0230821b1b2fd0936f586cb61c29 (diff)
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
-rw-r--r--services/core/java/com/android/server/pm/dex/DexManager.java19
-rw-r--r--services/core/java/com/android/server/pm/dex/DexoptOptions.java13
2 files changed, 29 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/pm/dex/DexManager.java b/services/core/java/com/android/server/pm/dex/DexManager.java
index 7538e86c8e9e..1f41724da7e2 100644
--- a/services/core/java/com/android/server/pm/dex/DexManager.java
+++ b/services/core/java/com/android/server/pm/dex/DexManager.java
@@ -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,
diff --git a/services/core/java/com/android/server/pm/dex/DexoptOptions.java b/services/core/java/com/android/server/pm/dex/DexoptOptions.java
index de3c9f28218d..b453c898ded8 100644
--- a/services/core/java/com/android/server/pm/dex/DexoptOptions.java
+++ b/services/core/java/com/android/server/pm/dex/DexoptOptions.java
@@ -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);
+ }
}