summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiakai Zhang <jiakaiz@google.com>2022-06-22 11:20:07 +0100
committerJiakai Zhang <jiakaiz@google.com>2022-06-22 14:15:11 +0000
commit80ee5fc12d1fbf2b973d42d9189567df4098d3a2 (patch)
treeda45b5c73e055aee5b0e2c36e7fbd011a78be22a
parent82c3268cbec2fd56e79252f5cf029e5153416e26 (diff)
downloadbase-80ee5fc12d1fbf2b973d42d9189567df4098d3a2.tar.gz
Fix a logic error in `getDexoptNeeded`.
When an app has already been compiled with "speed-profile", it should not be re-compiled with a worse compiler filter such as "verify", even if the odex file can be public after then. Bug: 236682949 Bug: 236816601 Test: atest AdbRootDependentCompilationTest#testCompile_usedByOtherApps Change-Id: I290096bf8192a6f695ab8fc8e2a24edbc10ecd74
-rw-r--r--services/core/java/com/android/server/pm/PackageDexOptimizer.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index af0a20ddf337..6cfe093df6d0 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -936,12 +936,15 @@ public class PackageDexOptimizer {
String classLoaderContext, int profileAnalysisResult, boolean downgrade,
int dexoptFlags, String oatDir) {
final boolean shouldBePublic = (dexoptFlags & DEXOPT_PUBLIC) != 0;
- // If the artifacts should be public while the current artifacts are not, we should
- // re-compile anyway.
- if (shouldBePublic && isOdexPrivate(packageName, path, isa, oatDir)) {
- // Ensure compilation by pretending a compiler filter change on the apk/odex location
- // (the reason for the '-'. A positive value means the 'oat' location).
- return adjustDexoptNeeded(-DexFile.DEX2OAT_FOR_FILTER);
+ final boolean isProfileGuidedFilter = (dexoptFlags & DEXOPT_PROFILE_GUIDED) != 0;
+ boolean newProfile = profileAnalysisResult == PROFILE_ANALYSIS_OPTIMIZE;
+
+ if (!newProfile && isProfileGuidedFilter && shouldBePublic
+ && isOdexPrivate(packageName, path, isa, oatDir)) {
+ // The profile that will be used is a cloud profile, while the profile used previously
+ // is a user profile. Typically, this happens after an app starts being used by other
+ // apps.
+ newProfile = true;
}
int dexoptNeeded;
@@ -959,7 +962,6 @@ public class PackageDexOptimizer {
&& profileAnalysisResult == PROFILE_ANALYSIS_DONT_OPTIMIZE_EMPTY_PROFILES) {
actualCompilerFilter = "verify";
}
- boolean newProfile = profileAnalysisResult == PROFILE_ANALYSIS_OPTIMIZE;
dexoptNeeded = DexFile.getDexOptNeeded(path, isa, actualCompilerFilter,
classLoaderContext, newProfile, downgrade);
} catch (IOException ioe) {