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

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

Issue 1407233017: Define a Java-side global application context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo changes to ApplicationStatus Created 5 years, 1 month 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
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 942c19c4b4dbd4c5e9fd70d4d984cdb5acfe6c8f..d0c2b6ee594986c0b93ffd51ab8b11b206531133 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
@@ -11,6 +11,7 @@ import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
+import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
@@ -38,24 +39,22 @@ public class ShellMain {
/**
* Initializes the native system.
**/
- public static void ensureInitialized(Context applicationContext, String[] parameters) {
+ public static void ensureInitialized(Context context, String[] parameters) {
if (sInitialized) return;
- File cachedAppsDir = getCachedAppsDir(applicationContext);
+ File cachedAppsDir = getCachedAppsDir(context);
try {
- final File timestamp =
- FileHelper.prepareDirectoryForAssets(applicationContext, cachedAppsDir);
- for (String assetPath : FileHelper.getAssetsList(applicationContext)) {
- FileHelper.extractFromAssets(applicationContext, assetPath, cachedAppsDir,
- FileHelper.FileType.PERMANENT);
+ final File timestamp = FileHelper.prepareDirectoryForAssets(context, cachedAppsDir);
+ for (String assetPath : FileHelper.getAssetsList(context)) {
+ FileHelper.extractFromAssets(
+ context, assetPath, cachedAppsDir, FileHelper.FileType.PERMANENT);
}
- ApplicationInfo ai = applicationContext.getPackageManager().getApplicationInfo(
- applicationContext.getPackageName(), PackageManager.GET_META_DATA);
+ ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
+ context.getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
String mojo_lib = bundle.getString(MOJO_LIB_KEY);
FileHelper.createTimestampIfNecessary(timestamp);
- File mojoShell =
- new File(applicationContext.getApplicationInfo().nativeLibraryDir, mojo_lib);
+ File mojoShell = new File(context.getApplicationInfo().nativeLibraryDir, mojo_lib);
List<String> parametersList = new ArrayList<String>();
// Program name.
@@ -63,10 +62,10 @@ public class ShellMain {
parametersList.addAll(Arrays.asList(parameters));
}
- nativeInit(applicationContext, mojoShell.getAbsolutePath(),
+ ContextUtils.initApplicationContext(context.getApplicationContext());
+ nativeInit(context, mojoShell.getAbsolutePath(),
parametersList.toArray(new String[parametersList.size()]),
- cachedAppsDir.getAbsolutePath(),
- getTmpDir(applicationContext).getAbsolutePath());
+ cachedAppsDir.getAbsolutePath(), getTmpDir(context).getAbsolutePath());
sInitialized = true;
} catch (Exception e) {
Log.e(TAG, "ShellMain initialization failed.", e);

Powered by Google App Engine
This is Rietveld 408576698