| OLD | NEW |
| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // No need to delete stale libs since libraries are loaded explicitly. | 174 // No need to delete stale libs since libraries are loaded explicitly. |
| 175 int numNotChanged = 0; | 175 int numNotChanged = 0; |
| 176 for (File f : srcDir.listFiles()) { | 176 for (File f : srcDir.listFiles()) { |
| 177 // Note: Tried using hardlinks, but resulted in EACCES exceptions. | 177 // Note: Tried using hardlinks, but resulted in EACCES exceptions. |
| 178 File dest = new File(dstDir, f.getName()); | 178 File dest = new File(dstDir, f.getName()); |
| 179 if (!copyIfModified(f, dest)) { | 179 if (!copyIfModified(f, dest)) { |
| 180 numNotChanged++; | 180 numNotChanged++; |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 if (numNotChanged > 0) { | 183 if (numNotChanged > 0) { |
| 184 Log.i(TAG, numNotChanged + " libs already up-to-date."); | 184 Log.i(TAG, numNotChanged + " libs already up to date."); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 private static boolean copyIfModified(File src, File dest) throws IOExceptio
n { | 188 private static boolean copyIfModified(File src, File dest) throws IOExceptio
n { |
| 189 long lastModified = src.lastModified(); | 189 long lastModified = src.lastModified(); |
| 190 if (dest.exists() && dest.lastModified() == lastModified) { | 190 if (dest.exists() && dest.lastModified() == lastModified) { |
| 191 return false; | 191 return false; |
| 192 } | 192 } |
| 193 Log.i(TAG, "Copying " + src + " -> " + dest); | 193 Log.i(TAG, "Copying " + src + " -> " + dest); |
| 194 FileInputStream istream = new FileInputStream(src); | 194 FileInputStream istream = new FileInputStream(src); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 mClassLoader, ret); | 238 mClassLoader, ret); |
| 239 } else { | 239 } else { |
| 240 dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, optim
izedDirectory); | 240 dexFile = Reflect.invokeMethod(clazz, "loadDexFile", file, optim
izedDirectory); |
| 241 } | 241 } |
| 242 ret[curDexElements.length + i] = | 242 ret[curDexElements.length + i] = |
| 243 Reflect.newInstance(entryClazz, emptyDir, false, file, dexFi
le); | 243 Reflect.newInstance(entryClazz, emptyDir, false, file, dexFi
le); |
| 244 } | 244 } |
| 245 return ret; | 245 return ret; |
| 246 } | 246 } |
| 247 } | 247 } |
| OLD | NEW |