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

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

Issue 1684583003: Add java-side support for _incremental instrumentation tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java ('k') | 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 c1682e81e049ebda1ab784f4b628f5c96a803b75..c382799003489ba328a4b60fd7290c5218b53554 100644
--- a/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java
+++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java
@@ -103,6 +103,10 @@ final class ClassLoaderPatcher {
*/
void importNativeLibs(File libDir) throws ReflectiveOperationException, IOException {
Log.i(TAG, "Importing native libraries from: " + libDir);
+ if (!libDir.exists()) {
+ Log.i(TAG, "No native libs exist.");
+ return;
+ }
// The library copying is not necessary on older devices, but we do it anyways to
// simplify things (it's fast compared to dexing).
// https://code.google.com/p/android/issues/detail?id=79480
@@ -169,28 +173,34 @@ final class ClassLoaderPatcher {
private static void copyChangedFiles(File srcDir, File dstDir) throws IOException {
// No need to delete stale libs since libraries are loaded explicitly.
+ int numNotChanged = 0;
for (File f : srcDir.listFiles()) {
// Note: Tried using hardlinks, but resulted in EACCES exceptions.
File dest = new File(dstDir, f.getName());
- copyIfModified(f, dest);
+ if (!copyIfModified(f, dest)) {
+ numNotChanged++;
+ }
+ }
+ if (numNotChanged > 0) {
+ Log.i(TAG, numNotChanged + " libs already up-to-date.");
}
}
- private static void copyIfModified(File src, File dest) throws IOException {
+ private static boolean copyIfModified(File src, File dest) throws IOException {
long lastModified = src.lastModified();
- if (!dest.exists() || dest.lastModified() != lastModified) {
- Log.i(TAG, "Copying " + src + " -> " + dest);
- FileInputStream istream = new FileInputStream(src);
- FileOutputStream ostream = new FileOutputStream(dest);
- ostream.getChannel().transferFrom(istream.getChannel(), 0, istream.getChannel().size());
- istream.close();
- ostream.close();
- dest.setReadable(true, false);
- dest.setExecutable(true, false);
- dest.setLastModified(lastModified);
- } else {
- Log.i(TAG, "Up-to-date: " + dest);
+ if (dest.exists() && dest.lastModified() == lastModified) {
+ return false;
}
+ Log.i(TAG, "Copying " + src + " -> " + dest);
+ FileInputStream istream = new FileInputStream(src);
+ FileOutputStream ostream = new FileOutputStream(dest);
+ ostream.getChannel().transferFrom(istream.getChannel(), 0, istream.getChannel().size());
+ istream.close();
+ ostream.close();
+ dest.setReadable(true, false);
+ dest.setExecutable(true, false);
+ dest.setLastModified(lastModified);
+ return true;
}
private void ensureAppFilesSubDirExists() {
« no previous file with comments | « build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698