8 #include <android/asset_manager.h>
9 #include <android/native_window.h>
19 , assetManagerGlobalRef(NULL)
29 , classLoaderClass(NULL)
30 , classLoaderLoadClassMethod(0)
31 , m_nativeMessageRunner(NULL)
34 pthread_t javaMainThread;
37 JNIEnv* mainThreadEnv;
40 jobject assetManagerGlobalRef;
41 AAssetManager* assetManager;
42 ANativeWindow* window;
51 const char* deviceModel;
53 std::string versionName;
58 jclass classLoaderClass;
59 jmethodID classLoaderLoadClassMethod;
62 jclass LoadClass(JNIEnv* env, jstring strClassName)
64 return (jclass)env->CallObjectMethod(classLoader, classLoaderLoadClassMethod, strClassName);
67 void DetermineDeviceModel(JNIEnv* env)
69 jclass buildClass = env->FindClass(
"android/os/Build");
70 jfieldID modelMethod = env->GetStaticFieldID(buildClass,
"MODEL",
"Ljava/lang/String;");
71 jstring deviceNameString = (jstring)env->GetStaticObjectField(buildClass, modelMethod);
72 deviceModel = env->GetStringUTFChars(deviceNameString, NULL);
75 void SetNativeMessageRunner(jobject nativeMessageRunner)
77 m_nativeMessageRunner = nativeMessageRunner;
80 jobject GetNativeMessageRunner()
82 return m_nativeMessageRunner;
86 jobject m_nativeMessageRunner;
92 bool shouldBeAttached;
98 :nativeState(nativeState)
100 int result = nativeState.vm->GetEnv((
void **) &envForThread, JNI_VERSION_1_6);
101 shouldBeAttached = (result == JNI_EDETACHED);
105 int result = nativeState.vm->AttachCurrentThread(&envForThread, NULL);
106 Eegeo_ASSERT(result == 0);
114 nativeState.vm->DetachCurrentThread();