mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-17 14:47:19 +01:00
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 void onNativeSurfaceDestroyed();
|
||||||
public static native String nativeGetHint(String name);
|
public static native String nativeGetHint(String name);
|
||||||
public static native void nativeSetenv(String name, String value);
|
public static native void nativeSetenv(String name, String value);
|
||||||
public static native void nativeEnvironmentVariablesSet();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called by SDL using JNI.
|
* 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.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static void getManifestEnvironmentVariables() {
|
public static boolean getManifestEnvironmentVariables() {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo applicationInfo = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA);
|
ApplicationInfo applicationInfo = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA);
|
||||||
Bundle bundle = applicationInfo.metaData;
|
Bundle bundle = applicationInfo.metaData;
|
||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
String prefix = "SDL_ENV.";
|
String prefix = "SDL_ENV.";
|
||||||
final int trimLength = prefix.length();
|
final int trimLength = prefix.length();
|
||||||
@ -634,10 +633,12 @@ public class SDLActivity extends Activity {
|
|||||||
nativeSetenv(name, value);
|
nativeSetenv(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nativeEnvironmentVariablesSet();
|
/* environment variables set! */
|
||||||
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.v("SDL", "exception " + e.toString());
|
Log.v("SDL", "exception " + e.toString());
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShowTextInputTask implements Runnable {
|
static class ShowTextInputTask implements Runnable {
|
||||||
|
@ -251,7 +251,7 @@ static jfieldID fidSeparateMouseAndTouch;
|
|||||||
static float fLastAccelerometer[3];
|
static float fLastAccelerometer[3];
|
||||||
static SDL_bool bHasNewData;
|
static SDL_bool bHasNewData;
|
||||||
|
|
||||||
static SDL_bool bHasEnvironmentVariables;
|
static SDL_bool bHasEnvironmentVariables = SDL_FALSE;
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Functions called by JNI
|
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;");
|
"openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;");
|
||||||
|
|
||||||
midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||||
"getManifestEnvironmentVariables", "()V");
|
"getManifestEnvironmentVariables", "()Z");
|
||||||
|
|
||||||
midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
|
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
|
Functions called by SDL into Java
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -2143,7 +2137,10 @@ void Android_JNI_GetManifestEnvironmentVariables(void)
|
|||||||
|
|
||||||
if (!bHasEnvironmentVariables) {
|
if (!bHasEnvironmentVariables) {
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
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
Block a user