diff options
| author | 2018-12-20 09:47:00 +0000 | |
|---|---|---|
| committer | 2019-01-09 08:48:38 +0000 | |
| commit | 03dba3ba8c99b99c2252f3929ebf1df3fae34c89 (patch) | |
| tree | 59083b9bdbe4841f296277de826ecd865caabf96 | |
| parent | b444a8b822b5b8891f100c5b0464b9b997b879c0 (diff) | |
Remove notion of skip library check in framework.
bug: 111174995
Test: m
Change-Id: Id4d69258116696db3662ac7678f6d235fcccabc7
3 files changed, 16 insertions, 45 deletions
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java index f9e31aed1174..5412e9425adf 100644 --- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java +++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java @@ -85,9 +85,6 @@ public class PackageDexOptimizer { // One minute over PM WATCHDOG_TIMEOUT private static final long WAKELOCK_TIMEOUT_MS = WATCHDOG_TIMEOUT + 1000 * 60; - /** Special library name that skips shared libraries check during compilation. */ - public static final String SKIP_SHARED_LIBRARY_CHECK = "&"; - @GuardedBy("mInstallLock") private final Installer mInstaller; private final Object mInstallLock; @@ -397,23 +394,23 @@ public class PackageDexOptimizer { Slog.e(TAG, "Could not infer CE/DE storage for package " + info.packageName); return DEX_OPT_FAILED; } - Log.d(TAG, "Running dexopt on: " + path - + " pkg=" + info.packageName + " isa=" + dexUseInfo.getLoaderIsas() - + " dexoptFlags=" + printDexoptFlags(dexoptFlags) - + " target-filter=" + compilerFilter); - - String classLoaderContext; + String classLoaderContext = null; if (dexUseInfo.isUnknownClassLoaderContext() || dexUseInfo.isVariableClassLoaderContext()) { - // If we have an unknown (not yet set), or a variable class loader chain, compile - // without a context and mark the oat file with SKIP_SHARED_LIBRARY_CHECK. Note that - // this might lead to a incorrect compilation. - // TODO(calin): We should just extract in this case. - classLoaderContext = SKIP_SHARED_LIBRARY_CHECK; + // If we have an unknown (not yet set), or a variable class loader chain. Just extract + // the dex file. + compilerFilter = "extract"; } else { classLoaderContext = dexUseInfo.getClassLoaderContext(); } int reason = options.getCompilationReason(); + Log.d(TAG, "Running dexopt on: " + path + + " pkg=" + info.packageName + " isa=" + dexUseInfo.getLoaderIsas() + + " reason=" + getReasonName(reason) + + " dexoptFlags=" + printDexoptFlags(dexoptFlags) + + " target-filter=" + compilerFilter + + " class-loader-context=" + classLoaderContext); + try { for (String isa : dexUseInfo.getLoaderIsas()) { // Reuse the same dexopt path as for the primary apks. We don't need all the diff --git a/services/core/java/com/android/server/pm/dex/DexoptUtils.java b/services/core/java/com/android/server/pm/dex/DexoptUtils.java index 93ee44cdf0ce..91ad11e53538 100644 --- a/services/core/java/com/android/server/pm/dex/DexoptUtils.java +++ b/services/core/java/com/android/server/pm/dex/DexoptUtils.java @@ -22,7 +22,6 @@ import android.util.Slog; import android.util.SparseArray; import com.android.internal.os.ClassLoaderFactory; -import com.android.server.pm.PackageDexOptimizer; import java.io.File; import java.util.List; @@ -275,15 +274,11 @@ public final class DexoptUtils { /** * Encodes a single class loader dependency starting from {@param path} and * {@param classLoaderName}. - * When classpath is {@link PackageDexOptimizer#SKIP_SHARED_LIBRARY_CHECK}, the method returns - * the same. This special property is used only during OTA. * NOTE: Keep this in sync with the dexopt expectations! Right now that is either "PCL[path]" * for a PathClassLoader or "DLC[path]" for a DelegateLastClassLoader. */ /*package*/ static String encodeClassLoader(String classpath, String classLoaderName) { - if (classpath.equals(PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK)) { - return classpath; - } + classpath.getClass(); // Throw NPE if classpath is null String classLoaderDexoptEncoding = classLoaderName; if (ClassLoaderFactory.isPathClassLoaderName(classLoaderName)) { classLoaderDexoptEncoding = "PCL"; @@ -306,16 +301,10 @@ public final class DexoptUtils { /** * Links to dependencies together in a format accepted by dexopt. * For the special case when either of cl1 or cl2 equals - * {@link PackageDexOptimizer#SKIP_SHARED_LIBRARY_CHECK}, the method returns the same. This - * property is used only during OTA. * NOTE: Keep this in sync with the dexopt expectations! Right now that is a list of split * dependencies {@see encodeClassLoader} separated by ';'. */ /*package*/ static String encodeClassLoaderChain(String cl1, String cl2) { - if (cl1.equals(PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK) || - cl2.equals(PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK)) { - return PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK; - } if (cl1.isEmpty()) return cl2; if (cl2.isEmpty()) return cl1; return cl1 + ";" + cl2; diff --git a/services/tests/servicestests/src/com/android/server/pm/dex/DexoptUtilsTest.java b/services/tests/servicestests/src/com/android/server/pm/dex/DexoptUtilsTest.java index 813fa8237096..d9faaa418c88 100644 --- a/services/tests/servicestests/src/com/android/server/pm/dex/DexoptUtilsTest.java +++ b/services/tests/servicestests/src/com/android/server/pm/dex/DexoptUtilsTest.java @@ -16,8 +16,6 @@ package com.android.server.pm.dex; -import static com.android.server.pm.PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -31,16 +29,16 @@ import android.util.SparseArray; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; -import org.junit.Test; -import org.junit.runner.RunWith; - import dalvik.system.DelegateLastClassLoader; import dalvik.system.DexClassLoader; import dalvik.system.PathClassLoader; +import org.junit.Test; +import org.junit.runner.RunWith; + import java.io.File; -import java.util.Arrays; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -412,12 +410,6 @@ public class DexoptUtilsTest { @Test public void testEncodeClassLoader() { - assertEquals(SKIP_SHARED_LIBRARY_CHECK, DexoptUtils.encodeClassLoader( - SKIP_SHARED_LIBRARY_CHECK, "dalvik.system.PathClassLoader")); - assertEquals(SKIP_SHARED_LIBRARY_CHECK, DexoptUtils.encodeClassLoader( - SKIP_SHARED_LIBRARY_CHECK, "dalvik.system.DexClassLoader")); - assertEquals(SKIP_SHARED_LIBRARY_CHECK, DexoptUtils.encodeClassLoader( - SKIP_SHARED_LIBRARY_CHECK, "dalvik.system.DelegateLastClassLoader")); assertEquals("PCL[xyz]", DexoptUtils.encodeClassLoader("xyz", "dalvik.system.PathClassLoader")); assertEquals("PCL[xyz]", DexoptUtils.encodeClassLoader("xyz", @@ -435,15 +427,8 @@ public class DexoptUtilsTest { @Test public void testEncodeClassLoaderChain() { - assertEquals(SKIP_SHARED_LIBRARY_CHECK, DexoptUtils.encodeClassLoaderChain( - SKIP_SHARED_LIBRARY_CHECK, "PCL[a]")); - assertEquals(SKIP_SHARED_LIBRARY_CHECK, DexoptUtils.encodeClassLoaderChain("PCL[a]", - SKIP_SHARED_LIBRARY_CHECK)); assertEquals("PCL[a];DLC[b]", DexoptUtils.encodeClassLoaderChain("PCL[a]", "DLC[b]")); - assertEquals(SKIP_SHARED_LIBRARY_CHECK, DexoptUtils.encodeClassLoaderChain("PCL[a]", - SKIP_SHARED_LIBRARY_CHECK)); - try { DexoptUtils.encodeClassLoaderChain("a", null); fail(); // exception is expected |