istereo2

changeset 27:f0da8b2b61ec

removed iOS cpu restriction and bumped build number to 3 implemented android JNI calls to show/hide ads (untested)
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 05 Oct 2015 17:15:02 +0300
parents 64ca672a79dc
children 74b50b538858
files ios/Info.plist src/android/amain.c
diffstat 2 files changed, 29 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/ios/Info.plist	Mon Oct 05 06:11:54 2015 +0300
     1.2 +++ b/ios/Info.plist	Mon Oct 05 17:15:02 2015 +0300
     1.3 @@ -19,13 +19,9 @@
     1.4  	<key>CFBundleSignature</key>
     1.5  	<string>????</string>
     1.6  	<key>CFBundleVersion</key>
     1.7 -	<string>2</string>
     1.8 +	<string>3</string>
     1.9  	<key>LSRequiresIPhoneOS</key>
    1.10  	<true/>
    1.11 -	<key>UIRequiredDeviceCapabilities</key>
    1.12 -	<array>
    1.13 -		<string>armv7</string>
    1.14 -	</array>
    1.15  	<key>UIRequiresFullScreen</key>
    1.16  	<true/>
    1.17  	<key>UIStatusBarHidden</key>
     2.1 --- a/src/android/amain.c	Mon Oct 05 06:11:54 2015 +0300
     2.2 +++ b/src/android/amain.c	Mon Oct 05 17:15:02 2015 +0300
     2.3 @@ -2,6 +2,7 @@
     2.4  #include <stdlib.h>
     2.5  #include <assert.h>
     2.6  #include <EGL/egl.h>
     2.7 +#include <jni.h>
     2.8  #include "android_native_app_glue.h"
     2.9  #include <android/window.h>
    2.10  #include <android/sensor.h>
    2.11 @@ -25,6 +26,10 @@
    2.12  static int width, height;
    2.13  static int init_done;
    2.14  
    2.15 +static JavaVM *jvm;
    2.16 +static JNIEnv *jni;
    2.17 +static jclass activity_class;
    2.18 +
    2.19  void android_main(struct android_app *app_ptr)
    2.20  {
    2.21  	app_dummy();
    2.22 @@ -37,6 +42,13 @@
    2.23  
    2.24  	start_logger();
    2.25  
    2.26 +	jvm = app->activity->vm;
    2.27 +	if((*jvm)->AttachCurrentThread(jvm, &jni, 0) != 0) {
    2.28 +		fprintf(stderr, "failed to attach native thread to Java VM\n");
    2.29 +		exit(1);
    2.30 +	}
    2.31 +	activity_class = (*jni)->GetObjectClass(jni, app->activity->clazz);
    2.32 +
    2.33  	for(;;) {
    2.34  		int num_events;
    2.35  		struct android_poll_source *pollsrc;
    2.36 @@ -69,10 +81,26 @@
    2.37  /* TODO */
    2.38  void ad_banner_show(void)
    2.39  {
    2.40 +	jmethodID method;
    2.41 +	if(!jvm) return;
    2.42 +
    2.43 +	if(!(method = (*jni)->GetMethodID(jni, activity_class, "show_ad", "()V"))) {
    2.44 +		fprintf(stderr, "failed to retrieve MainActivity.show_ad method\n");
    2.45 +		return;
    2.46 +	}
    2.47 +	(*jni)->CallVoidMethod(jni, activity_class, method);
    2.48  }
    2.49  
    2.50  void ad_banner_hide(void)
    2.51  {
    2.52 +	jmethodID method;
    2.53 +	if(!jvm) return;
    2.54 +
    2.55 +	if(!(method = (*jni)->GetMethodID(jni, activity_class, "hide_ad", "()V"))) {
    2.56 +		fprintf(stderr, "failed to retrieve MainActivity.hide_ad method\n");
    2.57 +		return;
    2.58 +	}
    2.59 +	(*jni)->CallVoidMethod(jni, activity_class, method);
    2.60  }
    2.61  
    2.62  static void handle_command(struct android_app *app, int32_t cmd)