Merge "Update DexLoadReporter to comply with the new reporting API"
This commit is contained in:
@@ -28,6 +28,8 @@ import dalvik.system.VMRuntime;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -86,29 +88,46 @@ import java.util.Set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void report(List<String> dexPaths) {
|
||||
if (dexPaths.isEmpty()) {
|
||||
public void report(List<BaseDexClassLoader> classLoadersChain, List<String> classPaths) {
|
||||
if (classLoadersChain.size() != classPaths.size()) {
|
||||
Slog.wtf(TAG, "Bad call to DexLoadReporter: argument size mismatch");
|
||||
return;
|
||||
}
|
||||
if (classPaths.isEmpty()) {
|
||||
Slog.wtf(TAG, "Bad call to DexLoadReporter: empty dex paths");
|
||||
return;
|
||||
}
|
||||
|
||||
// The first element of classPaths is the list of dex files that should be registered.
|
||||
// The classpath is represented as a list of dex files separated by File.pathSeparator.
|
||||
String[] dexPathsForRegistration = classPaths.get(0).split(File.pathSeparator);
|
||||
if (dexPathsForRegistration.length == 0) {
|
||||
// No dex files to register.
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify the package manager about the dex loads unconditionally.
|
||||
// The load might be for either a primary or secondary dex file.
|
||||
notifyPackageManager(dexPaths);
|
||||
// Check for secondary dex files and register them for profiling if
|
||||
// possible.
|
||||
registerSecondaryDexForProfiling(dexPaths);
|
||||
notifyPackageManager(classLoadersChain, classPaths);
|
||||
// Check for secondary dex files and register them for profiling if possible.
|
||||
// Note that we only register the dex paths belonging to the first class loader.
|
||||
registerSecondaryDexForProfiling(dexPathsForRegistration);
|
||||
}
|
||||
|
||||
private void notifyPackageManager(List<String> dexPaths) {
|
||||
private void notifyPackageManager(List<BaseDexClassLoader> ignored,
|
||||
List<String> classPaths) {
|
||||
String packageName = ActivityThread.currentPackageName();
|
||||
try {
|
||||
// Notify only the paths of the first class loader for now.
|
||||
ActivityThread.getPackageManager().notifyDexLoad(
|
||||
packageName, dexPaths, VMRuntime.getRuntime().vmInstructionSet());
|
||||
packageName, Arrays.asList(classPaths.get(0).split(File.pathSeparator)),
|
||||
VMRuntime.getRuntime().vmInstructionSet());
|
||||
} catch (RemoteException re) {
|
||||
Slog.e(TAG, "Failed to notify PM about dex load for package " + packageName, re);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerSecondaryDexForProfiling(List<String> dexPaths) {
|
||||
private void registerSecondaryDexForProfiling(String[] dexPaths) {
|
||||
if (!SystemProperties.getBoolean("dalvik.vm.dexopt.secondary", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user