| Summary: | Android, issues with getManifestEnvironmentVariable | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Sylvain <sylvain.becker> |
| Component: | *don't know* | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | don't know | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
| Attachments: |
patch
patch patch patch |
||
|
Description
Sylvain
2017-10-24 11:01:25 UTC
Your patches are in. Regarding the environment variable handling, can they be pushed to native SDL_setenv() before running SDL_main()? Will they persist across activities if we do that? Yes, we can read the Manifest Environment Variables in the onCreate() method and push them with SDL_setenv(). It's a much better option.
Especially because currently SDL_getenv() is broken: it doesn't get the real variable environments anymore (e.g. SDL_getenv("PATH"), for quick test, would return null).
Yes, if you start a second activity, you can get the environment variables you have set from the first activity.
Though, I am not sure that setting environment in AndroidManifest.xml is good option. It tends to make platform different.
It's needed to fix race conditions with joystick initialization. Can you implement a patch which pushes the variables with setenv()? It should be a static function on the SDL class and be called from SDL_JAVA_INTERFACE(nativeSetupJNI), since there are use cases where SDL is used without instantiating SDLActivity. Thanks! I just give a try, that does not seems to work because it requires a "Context", which mean an activity started ! Created attachment 3056 [details]
patch
This is a quick patch, it requires the context to be set before calling setupJNI(). That probably needs to be modified !
patch is also problematic because Os.setenv appears in API_21 Can't a race condition for joystick initialization be solved simply by adding a mutex ? Created attachment 3065 [details]
patch
Updated patch so that it doesn't require java Os.setenv of API_21, but uses SDL_setenv() and native setenv() instead.
Can you try this patch and see if that works? https://hg.libsdl.org/SDL/rev/1f10a52295e3 It should allow querying all the environment variables at once, after the activity is set. Created attachment 3067 [details]
patch
Yes this is working! Some "tabs" in the SDLActivity though.
What about getting some return code instead of creating another native function. But maybe this is to use from other classes. see patch.
Created attachment 3068 [details]
patch
patch updated - typo.
maybe also, write an explicit initialization :
static SDL_bool bHasEnvironmentVariables = SDL_FALSE;
This looks good, thanks! https://hg.libsdl.org/SDL/rev/e4d90d54cb01 |