3dphotoshoot

diff src/android/native_glue.c @ 2:cf5964db7ff3

finally jni calls fucking work
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 15 May 2015 02:06:26 +0300
parents 7eb73ce46dd0
children
line diff
     1.1 --- a/src/android/native_glue.c	Thu May 14 23:46:56 2015 +0300
     1.2 +++ b/src/android/native_glue.c	Fri May 15 02:06:26 2015 +0300
     1.3 @@ -37,6 +37,36 @@
     1.4  #  define LOGV(...)  ((void)0)
     1.5  #endif
     1.6  
     1.7 +/*
     1.8 +jint JNI_OnLoad(JavaVM *jvm, void *unused)
     1.9 +{
    1.10 +	JNIEnv *jni;
    1.11 +	jclass act_cls_local;
    1.12 +
    1.13 +	LOGI("OnLoad called ! <------------------\n");
    1.14 +
    1.15 +	if((*jvm)->GetEnv(jvm, (void**)&jni, JNI_VERSION_1_6) != JNI_OK) {
    1.16 +		LOGE("OnLoad: failed to get JNIEnv from VM\n");
    1.17 +		return -1;
    1.18 +	}
    1.19 +
    1.20 +	jclass foo = (*jni)->FindClass(jni, "java/lang/String");
    1.21 +	if(!foo) {
    1.22 +		LOGE("String class not found!!!!!!\n");
    1.23 +	} else {
    1.24 +		LOGE("Found String class!!!!!!\n");
    1.25 +	}
    1.26 +
    1.27 +	if(!(act_cls_local = (*jni)->FindClass(jni, ACTIVITY_NAME))) {
    1.28 +		LOGE("could not find activity: " ACTIVITY_NAME);
    1.29 +		return 0;
    1.30 +	}
    1.31 +	activity_class = (*jni)->NewGlobalRef(jni, act_cls_local);
    1.32 +
    1.33 +	return JNI_VERSION_1_6;
    1.34 +}
    1.35 +*/
    1.36 +
    1.37  static void free_saved_state(struct android_app* android_app) {
    1.38      pthread_mutex_lock(&android_app->mutex);
    1.39      if (android_app->savedState != NULL) {
    1.40 @@ -180,6 +210,7 @@
    1.41          AInputQueue_detachLooper(android_app->inputQueue);
    1.42      }
    1.43      AConfiguration_delete(android_app->config);
    1.44 +
    1.45      android_app->destroyed = 1;
    1.46      pthread_cond_broadcast(&android_app->cond);
    1.47      pthread_mutex_unlock(&android_app->mutex);
    1.48 @@ -243,25 +274,10 @@
    1.49  
    1.50  static struct android_app* android_app_create(ANativeActivity* activity,
    1.51          void* savedState, size_t savedStateSize) {
    1.52 -	JNIEnv *jni = activity->env;
    1.53      struct android_app* android_app = malloc(sizeof(struct android_app));
    1.54      memset(android_app, 0, sizeof(struct android_app));
    1.55      android_app->activity = activity;
    1.56  
    1.57 -	{
    1.58 -		jclass foo = (*jni)->FindClass(jni, "java/lang/String");
    1.59 -		if(!foo) {
    1.60 -			LOGE("String class not found!!!!!!\n");
    1.61 -		} else {
    1.62 -			LOGE("Found String class!!!!!!\n");
    1.63 -		}
    1.64 -	}
    1.65 -
    1.66 -	if(!(android_app->activity_class = (*jni)->FindClass(jni, ACTIVITY_NAME))) {
    1.67 -		LOGE("could not find activity: " ACTIVITY_NAME);
    1.68 -		return 0;
    1.69 -	}
    1.70 -
    1.71      pthread_mutex_init(&android_app->mutex, NULL);
    1.72      pthread_cond_init(&android_app->cond, NULL);
    1.73