diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index be8aeccad..a6f6e4eb8 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -513,7 +513,6 @@ public class SDLActivity extends Activity { public static native void onNativeSurfaceDestroyed(); public static native String nativeGetHint(String name); public static native void nativeSetenv(String name, String value); - public static native void nativeEnvironmentVariablesSet(); /** * This method is called by SDL using JNI. @@ -618,12 +617,12 @@ public class SDLActivity extends Activity { /** * This method is called by SDL using JNI. */ - public static void getManifestEnvironmentVariables() { + public static boolean getManifestEnvironmentVariables() { try { ApplicationInfo applicationInfo = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = applicationInfo.metaData; if (bundle == null) { - return; + return false; } String prefix = "SDL_ENV."; final int trimLength = prefix.length(); @@ -634,10 +633,12 @@ public class SDLActivity extends Activity { nativeSetenv(name, value); } } - nativeEnvironmentVariablesSet(); + /* environment variables set! */ + return true; } catch (Exception e) { Log.v("SDL", "exception " + e.toString()); } + return false; } static class ShowTextInputTask implements Runnable { diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 28f9a19d8..02afdf1cc 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -251,7 +251,7 @@ static jfieldID fidSeparateMouseAndTouch; static float fLastAccelerometer[3]; static SDL_bool bHasNewData; -static SDL_bool bHasEnvironmentVariables; +static SDL_bool bHasEnvironmentVariables = SDL_FALSE; /******************************************************************************* Functions called by JNI @@ -324,7 +324,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass c "openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;"); midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, - "getManifestEnvironmentVariables", "()V"); + "getManifestEnvironmentVariables", "()Z"); midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;"); @@ -831,12 +831,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( } -JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeEnvironmentVariablesSet)( - JNIEnv* env, jclass cls) -{ - bHasEnvironmentVariables = SDL_TRUE; -} - /******************************************************************************* Functions called by SDL into Java *******************************************************************************/ @@ -2143,7 +2137,10 @@ void Android_JNI_GetManifestEnvironmentVariables(void) if (!bHasEnvironmentVariables) { JNIEnv *env = Android_JNI_GetEnv(); - (*env)->CallStaticVoidMethod(env, mActivityClass, midGetManifestEnvironmentVariables); + SDL_bool ret = (*env)->CallStaticBooleanMethod(env, mActivityClass, midGetManifestEnvironmentVariables); + if (ret) { + bHasEnvironmentVariables = SDL_TRUE; + } } }