Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8c14e92 authored by Calin Juravle's avatar Calin Juravle
Browse files

Add DexClassLoader to the list of supported class loaders

DexClassLoader have the same behavior as PathClassLoader and is still in
use by apps. Add it to the list of supported class loaders so that it can be
recognized during secondary dex file loads.

Bug: 38138251
Bug: 36044779

Test: runtest -x
services/tests/servicestests/src/com/android/server/pm/dex/DexoptUtilsTest.java

(cherry picked from commit d08b3156)

Change-Id: If02081d29f4d8ac917dacd877eb75985ea3895a9
parent a8d14a6e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.os;
import android.os.Trace;

import dalvik.system.DelegateLastClassLoader;
import dalvik.system.DexClassLoader;
import dalvik.system.PathClassLoader;

/**
@@ -31,6 +32,7 @@ public class ClassLoaderFactory {
    private ClassLoaderFactory() {}

    private static final String PATH_CLASS_LOADER_NAME = PathClassLoader.class.getName();
    private static final String DEX_CLASS_LOADER_NAME = DexClassLoader.class.getName();
    private static final String DELEGATE_LAST_CLASS_LOADER_NAME =
            DelegateLastClassLoader.class.getName();

@@ -44,12 +46,14 @@ public class ClassLoaderFactory {
    }

    /**
     * Returns true if {@code name} is the encoding for the PathClassLoader.
     * Returns true if {@code name} is the encoding for either PathClassLoader or DexClassLoader.
     * The two class loaders are grouped together because they have the same behaviour.
     */
    public static boolean isPathClassLoaderName(String name) {
        // For null values we default to PathClassLoader. This cover the case when packages
        // don't specify any value for their class loaders.
        return name == null || PATH_CLASS_LOADER_NAME.equals(name);
        return name == null || PATH_CLASS_LOADER_NAME.equals(name) ||
                DEX_CLASS_LOADER_NAME.equals(name);
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.support.test.runner.AndroidJUnit4;
import android.util.SparseArray;

import dalvik.system.DelegateLastClassLoader;
import dalvik.system.DexClassLoader;
import dalvik.system.PathClassLoader;

import org.junit.Test;
@@ -32,6 +33,7 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class DexoptUtilsTest {
    private static final String DEX_CLASS_LOADER_NAME = DexClassLoader.class.getName();
    private static final String PATH_CLASS_LOADER_NAME = PathClassLoader.class.getName();
    private static final String DELEGATE_LAST_CLASS_LOADER_NAME =
            DelegateLastClassLoader.class.getName();
@@ -57,7 +59,7 @@ public class DexoptUtilsTest {
                    DELEGATE_LAST_CLASS_LOADER_NAME,
                    DELEGATE_LAST_CLASS_LOADER_NAME,
                    PATH_CLASS_LOADER_NAME,
                    PATH_CLASS_LOADER_NAME,
                    DEX_CLASS_LOADER_NAME,
                    PATH_CLASS_LOADER_NAME,
                    null};  // A null class loader name should default to PathClassLoader.
            if (addSplitDependencies) {