Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2821)

Unified Diff: build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java

Issue 1772843002: Fix incremental install for Android N (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@depfile-minimize
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java
diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java
index 8bf37799a3aeea72d1950c8cd63d1cbfa3bb3753..ac51be9e9a656ca385fbc987ae8ad7451aaf412a 100644
--- a/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java
+++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java
@@ -93,9 +93,8 @@ final class ClassLoaderPatcher {
Object dexPathList = Reflect.getField(mClassLoader, "pathList");
Object[] dexElements = (Object[]) Reflect.getField(dexPathList, "dexElements");
- Object[] additionalElements = makeDexElements(dexFilesArr, optimizedDir);
- Reflect.setField(dexPathList, "dexElements",
- Reflect.concatArrays(dexElements, dexElements, additionalElements));
+ dexElements = addDexElements(dexFilesArr, optimizedDir, dexElements);
+ Reflect.setField(dexPathList, "dexElements", dexElements);
}
/**
@@ -222,17 +221,26 @@ final class ClassLoaderPatcher {
return entries;
}
- private static Object[] makeDexElements(File[] files, File optimizedDirectory)
+ private Object[] addDexElements(File[] files, File optimizedDirectory, Object[] curDexElements)
throws ReflectiveOperationException {
Class<?> entryClazz = Class.forName("dalvik.system.DexPathList$Element");
Class<?> clazz = Class.forName("dalvik.system.DexPathList");
- Object[] entries = new Object[files.length];
+ Object[] ret =
+ Reflect.concatArrays(curDexElements, curDexElements, new Object[files.length]);
File emptyDir = new File("");
for (int i = 0; i < files.length; ++i) {
File file = files[i];
- Object dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, optimizedDirectory);
- entries[i] = Reflect.newInstance(entryClazz, emptyDir, false, file, dexFile);
+ Object dexFile;
+ if ("N".equals(Build.VERSION.CODENAME)) {
+ // loadDexFile requires that ret contain all previously added elements.
+ dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, optimizedDirectory,
+ mClassLoader, ret);
+ } else {
+ dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, optimizedDirectory);
+ }
+ ret[curDexElements.length + i] =
+ Reflect.newInstance(entryClazz, emptyDir, false, file, dexFile);
}
- return entries;
+ return ret;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698