author | Gian-Carlo Pascutto <gpascutto@mozilla.com> |
Sat, 09 Feb 2013 15:50:28 -0800 | |
changeset 127640 | 6354187a454d3958431f610c3d538473c30c1f98 |
parent 127639 | c96c8b020a27e0ca6476ab582e8d5a45e8eb5dfe |
child 127641 | 5dd1785e07a02d52f2cc79f4cb45790cada08bc4 |
push id | 24509 |
push user | ryanvm@gmail.com |
push date | Fri, 05 Apr 2013 00:57:47 +0000 |
treeherder | mozilla-central@55f9e3e3dae7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | blassey |
bugs | 839831 |
milestone | 23.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -11,16 +11,17 @@ #include <dlfcn.h> #include "mozilla/Hal.h" #include "nsXULAppAPI.h" #include <prthread.h> #include "nsXPCOMStrings.h" #include "AndroidBridge.h" +#include "AndroidJNIWrapper.h" #include "nsAppShell.h" #include "nsOSHelperAppService.h" #include "nsWindow.h" #include "mozilla/Preferences.h" #include "nsThreadUtils.h" #include "nsIThreadManager.h" #include "mozilla/dom/mobilemessage/PSms.h" #include "gfxImageSurface.h" @@ -2553,59 +2554,8 @@ AndroidBridge::UnlockProfile() AutoLocalJNIFrame jniFrame(env, 0); bool ret = env->CallStaticBooleanMethod(mGeckoAppShellClass, jUnlockProfile); if (jniFrame.CheckForException()) return false; return ret; } -extern "C" { - __attribute__ ((visibility("default"))) - jclass - jsjni_FindClass(const char *className) { - JNIEnv *env = AndroidBridge::GetJNIEnv(); - if (!env) return NULL; - return env->FindClass(className); - } - - __attribute__ ((visibility("default"))) - jmethodID - jsjni_GetStaticMethodID(jclass methodClass, - const char *methodName, - const char *signature) { - JNIEnv *env = AndroidBridge::GetJNIEnv(); - if (!env) return NULL; - return env->GetStaticMethodID(methodClass, methodName, signature); - } - - __attribute__ ((visibility("default"))) - bool - jsjni_ExceptionCheck() { - JNIEnv *env = AndroidBridge::GetJNIEnv(); - if (!env) return NULL; - return env->ExceptionCheck(); - } - - __attribute__ ((visibility("default"))) - void - jsjni_CallStaticVoidMethodA(jclass cls, - jmethodID method, - jvalue *values) { - JNIEnv *env = AndroidBridge::GetJNIEnv(); - if (!env) return; - - AutoLocalJNIFrame jniFrame(env); - env->CallStaticVoidMethodA(cls, method, values); - } - - __attribute__ ((visibility("default"))) - int - jsjni_CallStaticIntMethodA(jclass cls, - jmethodID method, - jvalue *values) { - JNIEnv *env = AndroidBridge::GetJNIEnv(); - if (!env) return -1; - - AutoLocalJNIFrame jniFrame(env); - return env->CallStaticIntMethodA(cls, method, values); - } -}
--- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -34,23 +34,16 @@ // #define DEBUG_ANDROID_EVENTS // #define DEBUG_ANDROID_WIDGET class nsWindow; class nsIDOMMozSmsMessage; /* See the comment in AndroidBridge about this function before using it */ extern "C" JNIEnv * GetJNIForThread(); -extern "C" jclass jsjni_FindClass(const char *className); -extern "C" jmethodID jsjni_GetStaticMethodID(jclass methodClass, - const char *methodName, - const char *signature); -extern "C" bool jsjni_ExceptionCheck(); -extern "C" void jsjni_CallStaticVoidMethodA(jclass cls, jmethodID method, jvalue *values); -extern "C" int jsjni_CallStaticIntMethodA(jclass cls, jmethodID method, jvalue *values); extern bool mozilla_AndroidBridge_SetMainThread(void *); extern jclass GetGeckoAppShellClass(); namespace base { class Thread; } // end namespace base
new file mode 100644 --- /dev/null +++ b/widget/android/AndroidJNIWrapper.cpp @@ -0,0 +1,75 @@ +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/Util.h" + +#include <android/log.h> +#include <dlfcn.h> +#include <prthread.h> + +#include "mozilla/Assertions.h" +#include "nsThreadUtils.h" +#include "AndroidBridge.h" + +#ifdef DEBUG +#define ALOG_BRIDGE(args...) ALOG(args) +#else +#define ALOG_BRIDGE(args...) +#endif + +extern "C" { + __attribute__ ((visibility("default"))) + jclass + jsjni_FindClass(const char *className) { + // FindClass outside the main thread will run into problems due + // to missing the classpath + MOZ_ASSERT(NS_IsMainThread()); + JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv(); + if (!env) return NULL; + return env->FindClass(className); + } + + __attribute__ ((visibility("default"))) + jmethodID + jsjni_GetStaticMethodID(jclass methodClass, + const char *methodName, + const char *signature) { + JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv(); + if (!env) return NULL; + return env->GetStaticMethodID(methodClass, methodName, signature); + } + + __attribute__ ((visibility("default"))) + bool + jsjni_ExceptionCheck() { + JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv(); + if (!env) return NULL; + return env->ExceptionCheck(); + } + + __attribute__ ((visibility("default"))) + void + jsjni_CallStaticVoidMethodA(jclass cls, + jmethodID method, + jvalue *values) { + JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv(); + if (!env) return; + + mozilla::AutoLocalJNIFrame jniFrame(env); + env->CallStaticVoidMethodA(cls, method, values); + } + + __attribute__ ((visibility("default"))) + int + jsjni_CallStaticIntMethodA(jclass cls, + jmethodID method, + jvalue *values) { + JNIEnv *env = mozilla::AndroidBridge::GetJNIEnv(); + if (!env) return -1; + + mozilla::AutoLocalJNIFrame jniFrame(env); + return env->CallStaticIntMethodA(cls, method, values); + } +}
new file mode 100644 --- /dev/null +++ b/widget/android/AndroidJNIWrapper.h @@ -0,0 +1,21 @@ +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef AndroidJNIWrapper_h__ +#define AndroidJNIWrapper_h__ + +#include <jni.h> +#include <android/log.h> + +extern "C" jclass jsjni_FindClass(const char *className); +extern "C" jmethodID jsjni_GetStaticMethodID(jclass methodClass, + const char *methodName, + const char *signature); +extern "C" bool jsjni_ExceptionCheck(); +extern "C" void jsjni_CallStaticVoidMethodA(jclass cls, jmethodID method, jvalue *values); +extern "C" int jsjni_CallStaticIntMethodA(jclass cls, jmethodID method, jvalue *values); + + +#endif /* AndroidJNIWrapper_h__ */
--- a/widget/android/Makefile.in +++ b/widget/android/Makefile.in @@ -27,16 +27,17 @@ CPPSRCS = \ GfxInfo.cpp \ nsWidgetFactory.cpp \ nsAppShell.cpp \ AndroidJavaWrappers.cpp \ AndroidBridge.cpp \ AndroidDirectTexture.cpp \ AndroidGraphicBuffer.cpp \ AndroidJNI.cpp \ + AndroidJNIWrapper.cpp \ nsWindow.cpp \ nsLookAndFeel.cpp \ nsScreenManagerAndroid.cpp \ nsIdleServiceAndroid.cpp \ nsClipboard.cpp \ nsFilePicker.cpp \ nsIMEPicker.cpp \ nsDeviceContextAndroid.cpp \ @@ -49,17 +50,17 @@ NOT_THERE_YET_CPPSRCS = \ nsDragService.cpp \ nsNativeThemeQt.cpp \ mozqwidget.cpp \ nsSound.cpp \ $(NULL) SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a -EXPORTS = AndroidBridge.h AndroidJavaWrappers.h +EXPORTS = AndroidBridge.h AndroidJavaWrappers.h AndroidJNIWrapper.h include $(topsrcdir)/config/rules.mk DEFINES += -D_IMPL_NS_WIDGET #DEFINES += -DDEBUG_WIDGETS LOCAL_INCLUDES += \ -I$(topsrcdir)/widget/xpwidgets \