Index: mojo/runner/android/apk/src/org/chromium/mojo/shell/ShellMain.java |
diff --git a/mojo/runner/android/apk/src/org/chromium/mojo/shell/ShellMain.java b/mojo/runner/android/apk/src/org/chromium/mojo/shell/ShellMain.java |
index 5e981302c64fde34c0a02f9f0a7eacd391ee1db3..771b9c5d26f0665d67f17b7007cbf11e59d6c351 100644 |
--- a/mojo/runner/android/apk/src/org/chromium/mojo/shell/ShellMain.java |
+++ b/mojo/runner/android/apk/src/org/chromium/mojo/shell/ShellMain.java |
@@ -14,11 +14,7 @@ import android.util.Log; |
import org.chromium.base.CalledByNative; |
import org.chromium.base.JNINamespace; |
-import java.io.BufferedReader; |
import java.io.File; |
-import java.io.IOException; |
-import java.io.InputStreamReader; |
-import java.nio.charset.Charset; |
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.List; |
@@ -30,14 +26,9 @@ import java.util.List; |
public class ShellMain { |
private static final String TAG = "ShellMain"; |
- // Directory where applications cached with the shell will be extracted. |
- // TODO(sky): rename this to CACHED_APP_DIRECTORY. |
- private static final String LOCAL_APP_DIRECTORY = "local_apps"; |
// The key to the library to run in forked processes when running multi-process. |
private static final String MOJO_LIB_KEY = "mojo_lib"; |
- // Name of the file containing the assets to extract. File format is a file per line. |
- private static final String ASSETS_LIST_NAME = "assets_list"; |
/** |
* A guard flag for calling nativeInit() only once. |
@@ -45,41 +36,17 @@ public class ShellMain { |
private static boolean sInitialized = false; |
/** |
- * Returns the names of the assets in ASSETS_LIST_NAME. |
- */ |
- private static List<String> getAssetsList(Context context) throws IOException { |
- List<String> results = new ArrayList<String>(); |
- BufferedReader reader = new BufferedReader(new InputStreamReader( |
- context.getAssets().open(ASSETS_LIST_NAME), Charset.forName("UTF-8"))); |
- |
- try { |
- String line; |
- while ((line = reader.readLine()) != null) { |
- line = line.trim(); |
- // These two are read by the system and don't need to be extracted. |
- if (!line.isEmpty() && !line.equals("bootstrap_java.dex.jar") |
- && !line.equals("libbootstrap.so")) { |
- results.add(line); |
- } |
- } |
- } finally { |
- reader.close(); |
- } |
- return results; |
- } |
- |
- /** |
* Initializes the native system. |
**/ |
public static void ensureInitialized(Context applicationContext, String[] parameters) { |
if (sInitialized) return; |
- File localAppsDir = getLocalAppsDir(applicationContext); |
+ File cachedAppsDir = getCachedAppsDir(applicationContext); |
try { |
final File timestamp = |
- FileHelper.prepareDirectoryForAssets(applicationContext, localAppsDir); |
- for (String assetPath : getAssetsList(applicationContext)) { |
- FileHelper.extractFromAssets( |
- applicationContext, assetPath, localAppsDir, FileHelper.FileType.PERMANENT); |
+ FileHelper.prepareDirectoryForAssets(applicationContext, cachedAppsDir); |
+ for (String assetPath : FileHelper.getAssetsList(applicationContext)) { |
+ FileHelper.extractFromAssets(applicationContext, assetPath, cachedAppsDir, |
+ FileHelper.FileType.PERMANENT); |
} |
ApplicationInfo ai = applicationContext.getPackageManager().getApplicationInfo( |
applicationContext.getPackageName(), PackageManager.GET_META_DATA); |
@@ -98,7 +65,7 @@ public class ShellMain { |
nativeInit(applicationContext, mojoShell.getAbsolutePath(), |
parametersList.toArray(new String[parametersList.size()]), |
- localAppsDir.getAbsolutePath(), |
+ cachedAppsDir.getAbsolutePath(), |
getTmpDir(applicationContext).getAbsolutePath()); |
sInitialized = true; |
} catch (Exception e) { |
@@ -121,8 +88,8 @@ public class ShellMain { |
nativeAddApplicationURL(url); |
} |
- static File getLocalAppsDir(Context context) { |
- return context.getDir(LOCAL_APP_DIRECTORY, Context.MODE_PRIVATE); |
+ static File getCachedAppsDir(Context context) { |
+ return FileHelper.getCachedAppsDir(context); |
} |
private static File getTmpDir(Context context) { |