summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-09-03 23:24:55 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-09-03 23:24:55 -0300
commitb0aa49accbd7e45dae38f1bd43b0fbdd11714211 (patch)
treef9173780301097b0da9bba0203402c33036ea72d /platform/android
parent7900d5daf21434a9396894a7c3ac360c03938770 (diff)
merged some stuff for okam
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/detect.py3
-rw-r--r--platform/android/file_access_android.cpp11
-rw-r--r--platform/android/file_access_android.h10
-rw-r--r--platform/android/file_access_jandroid.cpp4
-rw-r--r--platform/android/java/src/com/android/godot/Godot.java2
-rw-r--r--platform/android/java/src/com/android/godot/GodotIO.java5
-rw-r--r--platform/android/java/src/com/android/godot/GodotLib.java2
-rw-r--r--platform/android/java_glue.cpp12
-rw-r--r--platform/android/java_glue.h2
-rw-r--r--platform/android/os_android.cpp10
-rw-r--r--platform/android/os_android.h3
11 files changed, 42 insertions, 22 deletions
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 76575a1ec6..fce1fe3ed6 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -173,8 +173,7 @@ def configure(env):
env.Append(LDPATH=[ld_path])
env.Append(LIBS=['OpenSLES'])
# env.Append(LIBS=['c','m','stdc++','log','EGL','GLESv1_CM','GLESv2','OpenSLES','supc++','android'])
- if (env["ndk_platform"]!="2.2"):
- env.Append(LIBS=['EGL','OpenSLES','android'])
+ env.Append(LIBS=['EGL','OpenSLES','android'])
env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2', 'z'])
env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ")
diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp
index da3a37fb42..ff70d5ae76 100644
--- a/platform/android/file_access_android.cpp
+++ b/platform/android/file_access_android.cpp
@@ -29,16 +29,16 @@
#include "file_access_android.h"
#include "print_string.h"
-#ifdef ANDROID_NATIVE_ACTIVITY
+
AAssetManager *FileAccessAndroid::asset_manager=NULL;
-void FileAccessAndroid::make_default() {
+/*void FileAccessAndroid::make_default() {
create_func=create_android;
-}
+}*/
FileAccess* FileAccessAndroid::create_android() {
@@ -46,7 +46,7 @@ FileAccess* FileAccessAndroid::create_android() {
}
-Error FileAccessAndroid::open(const String& p_path, int p_mode_flags) {
+Error FileAccessAndroid::_open(const String& p_path, int p_mode_flags) {
String path=fix_path(p_path).simplify_path();
if (path.begins_with("/"))
@@ -55,7 +55,6 @@ Error FileAccessAndroid::open(const String& p_path, int p_mode_flags) {
path=path.substr(6,path.length());
-
ERR_FAIL_COND_V(p_mode_flags&FileAccess::WRITE,ERR_UNAVAILABLE); //can't write on android..
a=AAssetManager_open(asset_manager,path.utf8().get_data(),AASSET_MODE_STREAMING);
if (!a)
@@ -184,4 +183,4 @@ FileAccessAndroid::~FileAccessAndroid()
{
close();
}
-#endif
+
diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h
index f477920ae9..506c2c023f 100644
--- a/platform/android/file_access_android.h
+++ b/platform/android/file_access_android.h
@@ -29,14 +29,13 @@
#ifndef FILE_ACCESS_ANDROID_H
#define FILE_ACCESS_ANDROID_H
-#ifdef ANDROID_NATIVE_ACTIVITY
#include "os/file_access.h"
#include <stdio.h>
#include <android/asset_manager.h>
#include <android/log.h>
-#include <android_native_app_glue.h>
+//#include <android_native_app_glue.h>
class FileAccessAndroid : public FileAccess {
@@ -51,7 +50,7 @@ public:
static AAssetManager *asset_manager;
- virtual Error open(const String& p_path, int p_mode_flags); ///< open a file
+ virtual Error _open(const String& p_path, int p_mode_flags); ///< open a file
virtual void close(); ///< close a file
virtual bool is_open() const; ///< true when file is open
@@ -71,12 +70,13 @@ public:
virtual bool file_exists(const String& p_path); ///< return true if a file exists
+ virtual uint64_t _get_modified_time(const String& p_file) { return 0; }
- static void make_default();
+ //static void make_default();
FileAccessAndroid();
~FileAccessAndroid();
};
#endif // FILE_ACCESS_ANDROID_H
-#endif
+
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
index 971d4f84ab..be38d806b2 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -62,13 +62,15 @@ Error FileAccessJAndroid::_open(const String& p_path, int p_mode_flags) {
JNIEnv *env = ThreadAndroid::get_env();
- //OS::get_singleton()->print("env: %p, io %p, fo: %p\n",env,io,_file_open);
jstring js = env->NewStringUTF(path.utf8().get_data());
int res = env->CallIntMethod(io,_file_open,js,p_mode_flags&WRITE?true:false);
env->DeleteLocalRef(js);
+ OS::get_singleton()->print("fopen: '%s' ret %i\n",path.utf8().get_data(),res);
+
+
if (res<=0)
return ERR_FILE_CANT_OPEN;
id=res;
diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java
index 9b9b1ab2ad..4c5a313576 100644
--- a/platform/android/java/src/com/android/godot/Godot.java
+++ b/platform/android/java/src/com/android/godot/Godot.java
@@ -357,7 +357,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
Log.d("GODOT"," " + command_line[w]);
}
}*/
- GodotLib.initialize(this,io.needsReloadHooks(),command_line);
+ GodotLib.initialize(this,io.needsReloadHooks(),command_line,getAssets());
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java
index addceb1528..a7dc0c2f75 100644
--- a/platform/android/java/src/com/android/godot/GodotIO.java
+++ b/platform/android/java/src/com/android/godot/GodotIO.java
@@ -94,6 +94,7 @@ public class GodotIO {
//System.out.printf("file_open: Attempt to Open %s\n",path);
+ //Log.v("MyApp", "TRYING TO OPEN FILE: " + path);
if (write)
return -1;
@@ -105,7 +106,7 @@ public class GodotIO {
} catch (Exception e) {
- //System.out.printf("Exception on file_open: %s\n",e);
+ //System.out.printf("Exception on file_open: %s\n",path);
return -1;
}
@@ -113,7 +114,7 @@ public class GodotIO {
ad.len=ad.is.available();
} catch (Exception e) {
- System.out.printf("Exception availabling on file_open: %s\n",e);
+ System.out.printf("Exception availabling on file_open: %s\n",path);
return -1;
}
diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java
index 71c31e9f83..f099e0feff 100644
--- a/platform/android/java/src/com/android/godot/GodotLib.java
+++ b/platform/android/java/src/com/android/godot/GodotLib.java
@@ -44,7 +44,7 @@ public class GodotLib {
* @param height the current view height
*/
- public static native void initialize(Godot p_instance,boolean need_reload_hook,String[] p_cmdline);
+ public static native void initialize(Godot p_instance,boolean need_reload_hook,String[] p_cmdline,Object p_asset_manager);
public static native void resize(int width, int height,boolean reload);
public static native void newcontext();
public static native void quit();
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 3158254781..d001cface2 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -33,13 +33,14 @@
#include "main/main.h"
#include <unistd.h>
#include "file_access_jandroid.h"
+#include "file_access_android.h"
#include "dir_access_jandroid.h"
#include "audio_driver_jandroid.h"
#include "globals.h"
#include "thread_jandroid.h"
#include "core/os/keyboard.h"
#include "java_class_wrapper.h"
-
+#include "android/asset_manager_jni.h"
static JavaClassWrapper *java_class_wrapper=NULL;
static OS_Android *os_android=NULL;
@@ -764,7 +765,7 @@ static void _stop_video() {
env->CallVoidMethod(godot_io, _stopVideo);
}
-JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline) {
+JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline,jobject p_asset_manager) {
__android_log_print(ANDROID_LOG_INFO,"godot","**INIT EVENT! - %p\n",env);
@@ -820,7 +821,14 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env,
}
ThreadAndroid::make_default(jvm);
+#ifdef USE_JAVA_FILE_ACCESS
FileAccessJAndroid::setup(gob);
+#else
+
+ jobject amgr = env->NewGlobalRef(p_asset_manager);
+
+ FileAccessAndroid::asset_manager=AAssetManager_fromJava(env,amgr);
+#endif
DirAccessJAndroid::setup(gob);
AudioDriverAndroid::setup(gob);
}
diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h
index 57a4cc8651..9410fe7132 100644
--- a/platform/android/java_glue.h
+++ b/platform/android/java_glue.h
@@ -36,7 +36,7 @@
extern "C" {
- JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline);
+ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, jobject obj, jobject activity,jboolean p_need_reload_hook, jobjectArray p_cmdline,jobject p_asset_manager);
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_resize(JNIEnv * env, jobject obj, jint width, jint height, jboolean reload);
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_newcontext(JNIEnv * env, jobject obj);
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_step(JNIEnv * env, jobject obj);
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 612148418b..e2ff128f0d 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -37,6 +37,8 @@
#include "servers/visual/visual_server_wrap_mt.h"
#include "main/main.h"
+#include "file_access_android.h"
+
#include "core/globals.h"
#ifdef ANDROID_NATIVE_ACTIVITY
@@ -89,8 +91,14 @@ void OS_Android::initialize_core() {
if (use_apk_expansion)
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
- else
+ else {
+#ifdef USE_JAVA_FILE_ACCESS
FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
+#else
+ //FileAccess::make_default<FileAccessBufferedFA<FileAccessAndroid> >(FileAccess::ACCESS_RESOURCES);
+ FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
+#endif
+ }
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
//FileAccessBufferedFA<FileAccessUnix>::make_default();
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 7a5a55653f..e9b0d00196 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -41,6 +41,9 @@
#include "servers/visual/rasterizer.h"
+//#ifdef USE_JAVA_FILE_ACCESS
+
+
#ifdef ANDROID_NATIVE_ACTIVITY
#include <android/sensor.h>