15 #include "config_android.h" 16 #include "config_util.h" 17 #include "virtualFileMountAndroidAsset.h" 18 #include "virtualFileSystem.h" 21 #include "config_display.h" 25 #include <android_native_app_glue.h> 29 extern int main(
int argc,
char **argv);
37 void android_main(
struct android_app* app) {
38 panda_android_app = app;
42 ANativeActivity* activity = app->activity;
43 int status = activity->vm->AttachCurrentThread(&env, NULL);
44 if (status < 0 || env == NULL) {
45 android_cat.error() <<
"Failed to attach thread to JVM!\n";
50 jclass activity_class = env->GetObjectClass(activity->clazz);
51 jmethodID get_appinfo = env->GetMethodID(activity_class,
"getApplicationInfo",
"()Landroid/content/pm/ApplicationInfo;");
53 jobject appinfo = env->CallObjectMethod(activity->clazz, get_appinfo);
54 jclass appinfo_class = env->GetObjectClass(appinfo);
57 jfieldID datadir_field = env->GetFieldID(appinfo_class,
"dataDir",
"Ljava/lang/String;");
58 jstring datadir = (jstring) env->GetObjectField(appinfo, datadir_field);
59 const char *data_path = env->GetStringUTFChars(datadir, NULL);
61 Filename::_internal_data_dir = data_path;
62 android_cat.info() <<
"Path to data: " << data_path <<
"\n";
64 env->ReleaseStringUTFChars(datadir, data_path);
67 jfieldID libdir_field = env->GetFieldID(appinfo_class,
"nativeLibraryDir",
"Ljava/lang/String;");
68 jstring libdir = (jstring) env->GetObjectField(appinfo, libdir_field);
69 const char *lib_path = env->GetStringUTFChars(libdir, NULL);
71 string dtool_name = string(lib_path) +
"/libp3dtool.so";
73 android_cat.info() <<
"Path to dtool: " << dtool_name <<
"\n";
75 env->ReleaseStringUTFChars(libdir, lib_path);
78 jmethodID methodID = env->GetMethodID(activity_class,
"getPackageCodePath",
"()Ljava/lang/String;");
79 jstring code_path = (jstring) env->CallObjectMethod(activity->clazz, methodID);
82 apk_path = env->GetStringUTFChars(code_path, NULL);
83 android_cat.info() <<
"Path to APK: " << apk_path <<
"\n";
86 PT(VirtualFileMountAndroidAsset) asset_mount;
87 asset_mount =
new VirtualFileMountAndroidAsset(app->activity->assetManager, apk_path);
89 vfs->
mount(asset_mount,
"/android_asset", 0);
92 env->ReleaseStringUTFChars(code_path, apk_path);
98 char *argv[] = {NULL};
103 activity->vm->DetachCurrentThread();
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS's file system.
static void set_dtool_name(const string &name)
Do not use.
bool mount(Multifile *multifile, const Filename &mount_point, int flags)
Mounts the indicated Multifile at the given mount point.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
void append_directory(const Filename &directory)
Adds a new directory to the end of the search list.