diff options
| author | Calin Juravle <calin@google.com> | 2017-07-22 12:33:41 -0700 |
|---|---|---|
| committer | Calin Juravle <calin@google.com> | 2017-08-03 15:28:36 -0700 |
| commit | cd8fbd25d3b0e510e626a36767ebbea0282ea2ae (patch) | |
| tree | 0b1ac9ce71de7b31dfff32fde85573e5057ab204 /core/java | |
| parent | 01d686b85ebc5f7eea1a43db33a2f3e3f3becc3e (diff) | |
Update DexLoadReporter to comply with the new reporting API
This is a partial cherry pick of commit
3bec94d78b0a66c4fa5cebd851ea33bcc51916b0.
It is partial because it only adapts DexLoadReporter to use the new
reporter BaseDexClassLoader.Reporter API.
Bug: 38138251
Test: make
Merged-In: I2486522fb811f9fc58a44b92642f43a41e7d5bac
(cherry picked from commit 3bec94d78b0a66c4fa5cebd851ea33bcc51916b0)
Change-Id: I4c41dbeb8a9297caac8b0eb936cf74832569f33e
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/DexLoadReporter.java | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/core/java/android/app/DexLoadReporter.java b/core/java/android/app/DexLoadReporter.java index 13f288ab7454..5f61e07ec46e 100644 --- a/core/java/android/app/DexLoadReporter.java +++ b/core/java/android/app/DexLoadReporter.java @@ -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; } |
