mirror of https://github.com/encounter/SDL.git
Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
Sylvain What about getting some return code instead of creating another native function.
This commit is contained in:
parent
2c5724ef5d
commit
50e422adfe
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue