Added support for data directory on Android.

This makes GNUstep use the path returned by Context.getFilesDir() as the basis for storing data (e.g. NSUserDefaults) and when querying system directory paths (NSLibraryDirectory, NSApplicationSupportDirectory, etc.). Requires calling a new GSInitializeProcessAndroid() initialization function.
This commit is contained in:
Frederik Seiffert 2019-09-25 12:11:50 +02:00
parent ae95e859d6
commit d23c5013bf
4 changed files with 113 additions and 31 deletions

View file

@ -30,6 +30,10 @@
#import <Foundation/NSObject.h>
#ifdef __ANDROID__
#include <jni.h>
#endif
#if defined(__cplusplus)
extern "C" {
#endif
@ -265,6 +269,12 @@ DEFINE_BLOCK_TYPE(GSPerformExpiringActivityBlock, void, BOOL);
+ (void) initializeWithArguments: (char**)argv
count: (int)argc
environment: (char**)env;
#ifdef __ANDROID__
- (jobject) androidContext;
- (NSString *) androidFilesDir;
#endif
@end
/**
@ -278,6 +288,16 @@ DEFINE_BLOCK_TYPE(GSPerformExpiringActivityBlock, void, BOOL);
*/
GS_EXPORT void GSInitializeProcess(int argc, char **argv, char **envp);
#ifdef __ANDROID__
/**
* Android process initialization function.
* This should be called on Android to initialize GNUstep with the JNI
* environment and application context, which is used to set up support
* for the Android data directory and asset loading via NSBundle.
*/
GS_EXPORT void GSInitializeProcessAndroid(JNIEnv *env, jobject context);
#endif
/**
* Function for rapid testing to see if a debug level is set.<br />
* This is used by the debugging macros.<br />