Merge "Remove notion of skip library check in framework."

This commit is contained in:
Nicolas Geoffray
2019-01-10 08:28:51 +00:00
committed by Gerrit Code Review
3 changed files with 12 additions and 42 deletions

View File

@@ -87,9 +87,6 @@ public class PackageDexOptimizer {
// One minute over PM WATCHDOG_TIMEOUT // One minute over PM WATCHDOG_TIMEOUT
private static final long WAKELOCK_TIMEOUT_MS = WATCHDOG_TIMEOUT + 1000 * 60; 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") @GuardedBy("mInstallLock")
private final Installer mInstaller; private final Installer mInstaller;
private final Object mInstallLock; private final Object mInstallLock;
@@ -399,23 +396,23 @@ public class PackageDexOptimizer {
Slog.e(TAG, "Could not infer CE/DE storage for package " + info.packageName); Slog.e(TAG, "Could not infer CE/DE storage for package " + info.packageName);
return DEX_OPT_FAILED; return DEX_OPT_FAILED;
} }
Log.d(TAG, "Running dexopt on: " + path String classLoaderContext = null;
+ " pkg=" + info.packageName + " isa=" + dexUseInfo.getLoaderIsas()
+ " dexoptFlags=" + printDexoptFlags(dexoptFlags)
+ " target-filter=" + compilerFilter);
String classLoaderContext;
if (dexUseInfo.isUnknownClassLoaderContext() || dexUseInfo.isVariableClassLoaderContext()) { if (dexUseInfo.isUnknownClassLoaderContext() || dexUseInfo.isVariableClassLoaderContext()) {
// If we have an unknown (not yet set), or a variable class loader chain, compile // If we have an unknown (not yet set), or a variable class loader chain. Just extract
// without a context and mark the oat file with SKIP_SHARED_LIBRARY_CHECK. Note that // the dex file.
// this might lead to a incorrect compilation. compilerFilter = "extract";
// TODO(calin): We should just extract in this case.
classLoaderContext = SKIP_SHARED_LIBRARY_CHECK;
} else { } else {
classLoaderContext = dexUseInfo.getClassLoaderContext(); classLoaderContext = dexUseInfo.getClassLoaderContext();
} }
int reason = options.getCompilationReason(); 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 { try {
for (String isa : dexUseInfo.getLoaderIsas()) { for (String isa : dexUseInfo.getLoaderIsas()) {
// Reuse the same dexopt path as for the primary apks. We don't need all the // Reuse the same dexopt path as for the primary apks. We don't need all the

View File

@@ -22,7 +22,6 @@ import android.util.Slog;
import android.util.SparseArray; import android.util.SparseArray;
import com.android.internal.os.ClassLoaderFactory; import com.android.internal.os.ClassLoaderFactory;
import com.android.server.pm.PackageDexOptimizer;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@@ -275,15 +274,11 @@ public final class DexoptUtils {
/** /**
* Encodes a single class loader dependency starting from {@param path} and * Encodes a single class loader dependency starting from {@param path} and
* {@param classLoaderName}. * {@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]" * 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. * for a PathClassLoader or "DLC[path]" for a DelegateLastClassLoader.
*/ */
/*package*/ static String encodeClassLoader(String classpath, String classLoaderName) { /*package*/ static String encodeClassLoader(String classpath, String classLoaderName) {
if (classpath.equals(PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK)) { classpath.getClass(); // Throw NPE if classpath is null
return classpath;
}
String classLoaderDexoptEncoding = classLoaderName; String classLoaderDexoptEncoding = classLoaderName;
if (ClassLoaderFactory.isPathClassLoaderName(classLoaderName)) { if (ClassLoaderFactory.isPathClassLoaderName(classLoaderName)) {
classLoaderDexoptEncoding = "PCL"; classLoaderDexoptEncoding = "PCL";
@@ -306,16 +301,10 @@ public final class DexoptUtils {
/** /**
* Links to dependencies together in a format accepted by dexopt. * Links to dependencies together in a format accepted by dexopt.
* For the special case when either of cl1 or cl2 equals * 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 * NOTE: Keep this in sync with the dexopt expectations! Right now that is a list of split
* dependencies {@see encodeClassLoader} separated by ';'. * dependencies {@see encodeClassLoader} separated by ';'.
*/ */
/*package*/ static String encodeClassLoaderChain(String cl1, String cl2) { /*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 (cl1.isEmpty()) return cl2;
if (cl2.isEmpty()) return cl1; if (cl2.isEmpty()) return cl1;
return cl1 + ";" + cl2; return cl1 + ";" + cl2;

View File

@@ -16,9 +16,6 @@
package com.android.server.pm.dex; package com.android.server.pm.dex;
import com.android.server.pm.PackageDexOptimizer;
import static com.android.server.pm.PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@@ -412,12 +409,6 @@ public class DexoptUtilsTest {
@Test @Test
public void testEncodeClassLoader() { 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", assertEquals("PCL[xyz]", DexoptUtils.encodeClassLoader("xyz",
"dalvik.system.PathClassLoader")); "dalvik.system.PathClassLoader"));
assertEquals("PCL[xyz]", DexoptUtils.encodeClassLoader("xyz", assertEquals("PCL[xyz]", DexoptUtils.encodeClassLoader("xyz",
@@ -435,15 +426,8 @@ public class DexoptUtilsTest {
@Test @Test
public void testEncodeClassLoaderChain() { 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]", assertEquals("PCL[a];DLC[b]", DexoptUtils.encodeClassLoaderChain("PCL[a]",
"DLC[b]")); "DLC[b]"));
assertEquals(SKIP_SHARED_LIBRARY_CHECK, DexoptUtils.encodeClassLoaderChain("PCL[a]",
SKIP_SHARED_LIBRARY_CHECK));
try { try {
DexoptUtils.encodeClassLoaderChain("a", null); DexoptUtils.encodeClassLoaderChain("a", null);
fail(); // exception is expected fail(); // exception is expected