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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.incrementalinstall; 5 package org.chromium.incrementalinstall;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Build; 8 import android.os.Build;
9 import android.util.Log; 9 import android.util.Log;
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 } 87 }
88 88
89 Log.i(TAG, "Code cache dir: " + optimizedDir); 89 Log.i(TAG, "Code cache dir: " + optimizedDir);
90 // TODO(agrieve): Might need to record classpath ordering if we ever hav e duplicate 90 // TODO(agrieve): Might need to record classpath ordering if we ever hav e duplicate
91 // class names (since then order will matter here). 91 // class names (since then order will matter here).
92 Log.i(TAG, "Loading " + dexFilesArr.length + " dex files"); 92 Log.i(TAG, "Loading " + dexFilesArr.length + " dex files");
93 93
94 Object dexPathList = Reflect.getField(mClassLoader, "pathList"); 94 Object dexPathList = Reflect.getField(mClassLoader, "pathList");
95 Object[] dexElements = (Object[]) Reflect.getField(dexPathList, "dexElem ents"); 95 Object[] dexElements = (Object[]) Reflect.getField(dexPathList, "dexElem ents");
96 Object[] additionalElements = makeDexElements(dexFilesArr, optimizedDir) ; 96 dexElements = addDexElements(dexFilesArr, optimizedDir, dexElements);
97 Reflect.setField(dexPathList, "dexElements", 97 Reflect.setField(dexPathList, "dexElements", dexElements);
98 Reflect.concatArrays(dexElements, dexElements, additionalElement s));
99 } 98 }
100 99
101 /** 100 /**
102 * Sets up all libraries within |libDir| to be loadable by System.loadLibrar y(). 101 * Sets up all libraries within |libDir| to be loadable by System.loadLibrar y().
103 */ 102 */
104 void importNativeLibs(File libDir) throws ReflectiveOperationException, IOEx ception { 103 void importNativeLibs(File libDir) throws ReflectiveOperationException, IOEx ception {
105 Log.i(TAG, "Importing native libraries from: " + libDir); 104 Log.i(TAG, "Importing native libraries from: " + libDir);
106 if (!libDir.exists()) { 105 if (!libDir.exists()) {
107 Log.i(TAG, "No native libs exist."); 106 Log.i(TAG, "No native libs exist.");
108 return; 107 return;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 private static Object[] makeNativePathElements(File[] paths) 214 private static Object[] makeNativePathElements(File[] paths)
216 throws ReflectiveOperationException { 215 throws ReflectiveOperationException {
217 Class<?> entryClazz = Class.forName("dalvik.system.DexPathList$Element") ; 216 Class<?> entryClazz = Class.forName("dalvik.system.DexPathList$Element") ;
218 Object[] entries = new Object[paths.length]; 217 Object[] entries = new Object[paths.length];
219 for (int i = 0; i < paths.length; ++i) { 218 for (int i = 0; i < paths.length; ++i) {
220 entries[i] = Reflect.newInstance(entryClazz, paths[i], true, null, n ull); 219 entries[i] = Reflect.newInstance(entryClazz, paths[i], true, null, n ull);
221 } 220 }
222 return entries; 221 return entries;
223 } 222 }
224 223
225 private static Object[] makeDexElements(File[] files, File optimizedDirector y) 224 private Object[] addDexElements(File[] files, File optimizedDirectory, Objec t[] curDexElements)
226 throws ReflectiveOperationException { 225 throws ReflectiveOperationException {
227 Class<?> entryClazz = Class.forName("dalvik.system.DexPathList$Element") ; 226 Class<?> entryClazz = Class.forName("dalvik.system.DexPathList$Element") ;
228 Class<?> clazz = Class.forName("dalvik.system.DexPathList"); 227 Class<?> clazz = Class.forName("dalvik.system.DexPathList");
229 Object[] entries = new Object[files.length]; 228 Object[] ret =
229 Reflect.concatArrays(curDexElements, curDexElements, new Object[ files.length]);
230 File emptyDir = new File(""); 230 File emptyDir = new File("");
231 for (int i = 0; i < files.length; ++i) { 231 for (int i = 0; i < files.length; ++i) {
232 File file = files[i]; 232 File file = files[i];
233 Object dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, op timizedDirectory); 233 Object dexFile;
234 entries[i] = Reflect.newInstance(entryClazz, emptyDir, false, file, dexFile); 234 if ("N".equals(Build.VERSION.CODENAME)) {
235 // loadDexFile requires that ret contain all previously added el ements.
236 dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, optim izedDirectory,
237 mClassLoader, ret);
238 } else {
239 dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, optim izedDirectory);
240 }
241 ret[curDexElements.length + i] =
242 Reflect.newInstance(entryClazz, emptyDir, false, file, dexFi le);
235 } 243 }
236 return entries; 244 return ret;
237 } 245 }
238 } 246 }
OLDNEW
« 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