diff options
author | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 07:34:01 +0000 |
---|---|---|
committer | morrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-25 07:34:01 +0000 |
commit | db6659bb3dba39a89560717b5000ad43e64f5944 (patch) | |
tree | b3927059d5b10f85cd4fbfbae592f65ba06dc035 /mojo/shell/android | |
parent | 7bc0db2b06d64e392a8ede2659a0dc4b4a4d6fb8 (diff) | |
download | chromium_src-db6659bb3dba39a89560717b5000ad43e64f5944.zip chromium_src-db6659bb3dba39a89560717b5000ad43e64f5944.tar.gz chromium_src-db6659bb3dba39a89560717b5000ad43e64f5944.tar.bz2 |
Mojo: Fix crash on MojoShell on Android
MojoShell crashed when it goes backgound then comes to front again.
It did hit an assertion in InitApplicationContext() that is expected
to be called oly once for each process.
This change ensures it to be called once at most.
TEST=none
BUG=none
R=abarth,beng
Review URL: https://codereview.chromium.org/249713006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/shell/android')
-rw-r--r-- | mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java | 16 | ||||
-rw-r--r-- | mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java b/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java index 364f4d3..55fa0be 100644 --- a/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java +++ b/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java @@ -8,13 +8,24 @@ import android.content.Context; import org.chromium.base.JNINamespace; +/** + * A placeholder class to call native functions. + **/ @JNINamespace("mojo") public class MojoMain { /** + * A guard flag for calling nativeInit() only once. + **/ + private static boolean sInitialized = false; + + /** * Initializes the native system. **/ - public static void init(Context context) { + public static void ensureInitialized(Context context) { + if (sInitialized) + return; nativeInit(context); + sInitialized = true; } /** @@ -24,6 +35,9 @@ public class MojoMain { nativeStart(context, appUrl); } + /** + * Initializes the native system. This API should be called only once per process. + **/ private static native void nativeInit(Context context); private static native void nativeStart(Context context, String appUrl); }; diff --git a/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java b/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java index 15a5861..2f81c6ad 100644 --- a/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java +++ b/mojo/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java @@ -33,7 +33,7 @@ public class MojoShellActivity extends Activity { return; } - MojoMain.init(this); + MojoMain.ensureInitialized(this); String appUrl = getUrlFromIntent(getIntent()); if (appUrl == null) { |