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

Unified Diff: shell/android/apk/src/org/chromium/mojo/shell/AndroidHandler.java

Issue 1133283002: Android handler: Fix name collision. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix app tests. Created 5 years, 7 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 | « shell/android/android_handler.cc ('k') | shell/android/apk/src/org/chromium/mojo/shell/FileHelper.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/android/apk/src/org/chromium/mojo/shell/AndroidHandler.java
diff --git a/shell/android/apk/src/org/chromium/mojo/shell/AndroidHandler.java b/shell/android/apk/src/org/chromium/mojo/shell/AndroidHandler.java
index 9719f1902e18f05f2cd55512860535e6a7ae382d..a10266f834fe42a94ae4439bf154c0d16a300113 100644
--- a/shell/android/apk/src/org/chromium/mojo/shell/AndroidHandler.java
+++ b/shell/android/apk/src/org/chromium/mojo/shell/AndroidHandler.java
@@ -69,11 +69,15 @@ public class AndroidHandler {
File cacheDir = new File(cachePath);
File compiledDexDir = new File(cacheDir, "dex");
File assetDir = new File(cacheDir, "asset");
- assetDir.mkdirs();
- File preparedSentinel = new File(cacheDir, "prepared");
- // If the sentinel doesn't exist, extract the assets from the apk.
- if (!preparedSentinel.exists()) {
+ // If the timestamp file doesn't exist, or the assets are obsolete, extract the assets from
+ // the apk.
+ String timestampToCreate = FileHelper.checkAssetTimestamp(context, cacheDir);
+ if (timestampToCreate != null) {
+ for (File file : cacheDir.listFiles()) {
+ FileHelper.deleteRecursively(file);
+ }
+ assetDir.mkdirs();
compiledDexDir.mkdirs();
try {
TraceEvent.begin("ExtractBootstrapJavaLibrary");
@@ -85,9 +89,10 @@ public class AndroidHandler {
TraceEvent.begin("MoveBootstrapNativeLibrary");
// Rename the bootstrap library to prevent dlopen to think it is alread opened.
new File(assetDir, BOOTSTRAP_NATIVE_LIBRARY)
- .renameTo(File.createTempFile("bootstrap", ".so", assetDir));
+ .renameTo(new File(nativeCreateTemporaryFile(
+ assetDir.getAbsolutePath(), "bootstrap", ".so")));
TraceEvent.end("MoveBootstrapNativeLibrary");
- new java.io.FileOutputStream(preparedSentinel).close();
+ new File(cacheDir, timestampToCreate).createNewFile();
} catch (Exception e) {
Log.e(TAG, "Extraction of bootstrap files from assets failed.", e);
return false;
@@ -124,4 +129,7 @@ public class AndroidHandler {
return true;
}
+ // Create a new temporary file. The android version has predictable names.
+ private static native String nativeCreateTemporaryFile(
+ String directory, String basename, String extension);
}
« no previous file with comments | « shell/android/android_handler.cc ('k') | shell/android/apk/src/org/chromium/mojo/shell/FileHelper.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698