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

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

Issue 1731593003: Revert of Add increment install native libraries first in lookup paths (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 144
145 @SuppressWarnings("unchecked") 145 @SuppressWarnings("unchecked")
146 private void addNativeLibrarySearchPath(File nativeLibDir) throws Reflective OperationException { 146 private void addNativeLibrarySearchPath(File nativeLibDir) throws Reflective OperationException {
147 Object dexPathList = Reflect.getField(mClassLoader, "pathList"); 147 Object dexPathList = Reflect.getField(mClassLoader, "pathList");
148 Object currentDirs = Reflect.getField(dexPathList, "nativeLibraryDirecto ries"); 148 Object currentDirs = Reflect.getField(dexPathList, "nativeLibraryDirecto ries");
149 File[] newDirs = new File[] { nativeLibDir }; 149 File[] newDirs = new File[] { nativeLibDir };
150 // Switched from an array to an ArrayList in Lollipop. 150 // Switched from an array to an ArrayList in Lollipop.
151 if (currentDirs instanceof List) { 151 if (currentDirs instanceof List) {
152 List<File> dirsAsList = (List<File>) currentDirs; 152 List<File> dirsAsList = (List<File>) currentDirs;
153 dirsAsList.add(0, nativeLibDir); 153 dirsAsList.add(nativeLibDir);
154 } else { 154 } else {
155 File[] dirsAsArray = (File[]) currentDirs; 155 File[] dirsAsArray = (File[]) currentDirs;
156 Reflect.setField(dexPathList, "nativeLibraryDirectories", 156 Reflect.setField(dexPathList, "nativeLibraryDirectories",
157 Reflect.concatArrays(newDirs, dirsAsArray)); 157 Reflect.concatArrays(dirsAsArray, newDirs));
158 } 158 }
159 159
160 Object[] nativeLibraryPathElements; 160 Object[] nativeLibraryPathElements;
161 try { 161 try {
162 nativeLibraryPathElements = 162 nativeLibraryPathElements =
163 (Object[]) Reflect.getField(dexPathList, "nativeLibraryPathE lements"); 163 (Object[]) Reflect.getField(dexPathList, "nativeLibraryPathE lements");
164 } catch (NoSuchFieldException e) { 164 } catch (NoSuchFieldException e) {
165 // This field doesn't exist pre-M. 165 // This field doesn't exist pre-M.
166 return; 166 return;
167 } 167 }
168 Object[] additionalElements = makeNativePathElements(newDirs); 168 Object[] additionalElements = makeNativePathElements(newDirs);
169 Reflect.setField( 169 Reflect.setField(
170 dexPathList, "nativeLibraryPathElements", 170 dexPathList, "nativeLibraryPathElements",
171 Reflect.concatArrays(additionalElements, nativeLibraryPathElemen ts)); 171 Reflect.concatArrays(nativeLibraryPathElements, additionalElemen ts));
172 } 172 }
173 173
174 private static void copyChangedFiles(File srcDir, File dstDir) throws IOExce ption { 174 private static void copyChangedFiles(File srcDir, File dstDir) throws IOExce ption {
175 // No need to delete stale libs since libraries are loaded explicitly. 175 // No need to delete stale libs since libraries are loaded explicitly.
176 int numNotChanged = 0; 176 int numNotChanged = 0;
177 for (File f : srcDir.listFiles()) { 177 for (File f : srcDir.listFiles()) {
178 // Note: Tried using hardlinks, but resulted in EACCES exceptions. 178 // Note: Tried using hardlinks, but resulted in EACCES exceptions.
179 File dest = new File(dstDir, f.getName()); 179 File dest = new File(dstDir, f.getName());
180 if (!copyIfModified(f, dest)) { 180 if (!copyIfModified(f, dest)) {
181 numNotChanged++; 181 numNotChanged++;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 Object[] entries = new Object[files.length]; 229 Object[] entries = 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 = Reflect.invokeMethod(clazz, "loadDexFile", file, op timizedDirectory);
234 entries[i] = Reflect.newInstance(entryClazz, emptyDir, false, file, dexFile); 234 entries[i] = Reflect.newInstance(entryClazz, emptyDir, false, file, dexFile);
235 } 235 }
236 return entries; 236 return entries;
237 } 237 }
238 } 238 }
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