From ff3e4a1b2fb082e8146d00a41f702d0b00d9cab0 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Thu, 1 Feb 2018 17:23:13 +0000 Subject: [PATCH] Allow public profile compilation for primary apks It is ok to perform a "public" compilation with profiles comming from dex metdata files. Test: adb install foo.apk foo.dm Bug: 30934496 Change-Id: I1d15e3281ccc61b19a2aafe3c885285a83ff6115 --- services/core/java/com/android/server/pm/PackageDexOptimizer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java index b8a1691d77df..2c68e67a3bd5 100644 --- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java +++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java @@ -520,9 +520,13 @@ public class PackageDexOptimizer { private int getDexFlags(ApplicationInfo info, String compilerFilter, DexoptOptions options) { int flags = info.flags; boolean debuggable = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; - // Profile guide compiled oat files should not be public. + // Profile guide compiled oat files should not be public unles they are based + // on profiles from dex metadata archives. + // The flag isDexoptInstallWithDexMetadata applies only on installs when we know that + // the user does not have an existing profile. boolean isProfileGuidedFilter = isProfileGuidedCompilerFilter(compilerFilter); - boolean isPublic = !info.isForwardLocked() && !isProfileGuidedFilter; + boolean isPublic = !info.isForwardLocked() && + (!isProfileGuidedFilter || options.isDexoptInstallWithDexMetadata()); int profileFlag = isProfileGuidedFilter ? DEXOPT_PROFILE_GUIDED : 0; // System apps are invoked with a runtime flag which exempts them from // restrictions on hidden API usage. We dexopt with the same runtime flag -- 2.11.0