summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/AndroidManifest.xml.template9
-rw-r--r--platform/android/SCsub6
-rw-r--r--platform/android/android_native_app_glue.h4
-rw-r--r--platform/android/audio_driver_jandroid.cpp2
-rw-r--r--platform/android/audio_driver_jandroid.h2
-rw-r--r--platform/android/audio_driver_opensl.cpp13
-rw-r--r--platform/android/audio_driver_opensl.h2
-rw-r--r--platform/android/cpu-features.c2
-rw-r--r--platform/android/detect.py148
-rw-r--r--platform/android/dir_access_android.cpp5
-rw-r--r--platform/android/dir_access_android.h3
-rw-r--r--platform/android/dir_access_jandroid.cpp72
-rw-r--r--platform/android/dir_access_jandroid.h4
-rw-r--r--platform/android/export/export.cpp184
-rw-r--r--platform/android/file_access_android.cpp13
-rw-r--r--platform/android/file_access_android.h12
-rw-r--r--platform/android/file_access_jandroid.cpp7
-rw-r--r--platform/android/file_access_jandroid.h2
-rw-r--r--platform/android/globals/global_defaults.cpp2
-rw-r--r--platform/android/godot_android.cpp2
-rw-r--r--platform/android/java/res/drawable/icon.pngbin91728 -> 12574 bytes
-rw-r--r--platform/android/java/res/values-fa/strings.xml16
-rw-r--r--platform/android/java/src/com/android/godot/Godot.java81
-rw-r--r--platform/android/java/src/com/android/godot/GodotIO.java42
-rw-r--r--platform/android/java/src/com/android/godot/GodotLib.java4
-rw-r--r--platform/android/java/src/com/android/godot/GodotPaymentV3.java60
-rw-r--r--platform/android/java/src/com/android/godot/GodotView.java39
-rw-r--r--platform/android/java/src/com/android/godot/payments/PaymentsManager.java127
-rw-r--r--platform/android/java/src/com/android/godot/payments/PurchaseTask.java8
-rw-r--r--platform/android/java_glue.cpp161
-rw-r--r--platform/android/java_glue.h4
-rw-r--r--platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java6
-rw-r--r--platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java73
-rw-r--r--platform/android/os_android.cpp32
-rw-r--r--platform/android/os_android.h8
-rw-r--r--platform/android/platform_config.h2
-rw-r--r--platform/android/project.properties.template2
-rw-r--r--platform/android/thread_jandroid.cpp2
-rw-r--r--platform/android/thread_jandroid.h2
39 files changed, 809 insertions, 354 deletions
diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template
index 60861db603..c95c86c060 100644
--- a/platform/android/AndroidManifest.xml.template
+++ b/platform/android/AndroidManifest.xml.template
@@ -7,15 +7,15 @@
>
<supports-screens android:smallScreens="true"
android:normalScreens="true"
- android:largeScreens="true"
+ android:largeScreens="false"
android:xlargeScreens="true"/>
- <application android:label="@string/godot_project_name_string" android:icon="@drawable/icon" android:allowBackup="false">
+ <application android:label="@string/godot_project_name_string" android:icon="@drawable/icon" android:allowBackup="false" $$ADD_APPATTRIBUTE_CHUNKS$$ >
<activity android:name="com.android.godot.Godot"
android:label="@string/godot_project_name_string"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
- android:screenOrientation="portrait"
+ android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize">
<intent-filter>
@@ -33,6 +33,7 @@ $$ADD_APPLICATION_CHUNKS$$
</application>
<uses-feature android:glEsVersion="0x00020000"/>
+$$ADD_PERMISSION_CHUNKS$$
<uses-permission android:name="godot.ACCESS_CHECKIN_PROPERTIES"/>
<uses-permission android:name="godot.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="godot.ACCESS_FINE_LOCATION"/>
@@ -199,6 +200,6 @@ $$ADD_APPLICATION_CHUNKS$$
<uses-permission android:name="godot.custom.18"/>
<uses-permission android:name="godot.custom.19"/>
-<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15"/>
+<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19"/>
</manifest>
diff --git a/platform/android/SCsub b/platform/android/SCsub
index cffec5ae95..834ee58adc 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -56,14 +56,16 @@ pp_basein = open(abspath+"/AndroidManifest.xml.template","rb")
pp_baseout = open(abspath+"/java/AndroidManifest.xml","wb")
manifest = pp_basein.read()
manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$",env.android_manifest_chunk)
+manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$",env.android_permission_chunk)
+manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$",env.android_appattributes_chunk)
pp_baseout.write( manifest )
for x in env.android_source_files:
- shutil.copy(x,abspath+"/java/src/com/android/godot")
+ shutil.copy(x,abspath+"/java/src/com/android/godot")
for x in env.android_module_libraries:
- shutil.copy(x,abspath+"/java/libs")
+ shutil.copy(x,abspath+"/java/libs")
env_android.SharedLibrary("#bin/libgodot",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"])
diff --git a/platform/android/android_native_app_glue.h b/platform/android/android_native_app_glue.h
index fe8684b5d2..f5ba27ae66 100644
--- a/platform/android/android_native_app_glue.h
+++ b/platform/android/android_native_app_glue.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,7 +26,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
- * Copyright (C) 2010 The Android Open Source Project
+/* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp
index 6e3f6f9505..1a3a1cb563 100644
--- a/platform/android/audio_driver_jandroid.cpp
+++ b/platform/android/audio_driver_jandroid.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h
index f102acf154..bf8584051d 100644
--- a/platform/android/audio_driver_jandroid.h
+++ b/platform/android/audio_driver_jandroid.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index 857d1a4a54..761bef27aa 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -236,13 +236,12 @@ void AudioDriverOpenSL::start(){
ERR_FAIL_COND( res !=SL_RESULT_SUCCESS );
/* Initialize arrays required[] and iidArray[] */
- int i;
SLboolean required[MAX_NUMBER_INTERFACES];
SLInterfaceID iidArray[MAX_NUMBER_INTERFACES];
#if 0
- for (i=0; i<MAX_NUMBER_INTERFACES; i++)
+ for (int i=0; i<MAX_NUMBER_INTERFACES; i++)
{
required[i] = SL_BOOLEAN_FALSE;
iidArray[i] = SL_IID_NULL;
@@ -396,6 +395,14 @@ void AudioDriverOpenSL::finish(){
void AudioDriverOpenSL::set_pause(bool p_pause) {
pause=p_pause;
+
+ if (active) {
+ if (pause) {
+ (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PAUSED);
+ } else {
+ (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING);
+ }
+ }
}
diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h
index d852928ab8..e9d7c7a7ea 100644
--- a/platform/android/audio_driver_opensl.h
+++ b/platform/android/audio_driver_opensl.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/cpu-features.c b/platform/android/cpu-features.c
index 156d464729..9cdadd5407 100644
--- a/platform/android/cpu-features.c
+++ b/platform/android/cpu-features.c
@@ -127,7 +127,7 @@ static __inline__ void x86_cpuid(int func, int values[4])
static int
get_file_size(const char* pathname)
{
- int fd, ret, result = 0;
+ int fd, result = 0;
char buffer[256];
fd = open(pathname, O_RDONLY);
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 417f3e68ab..9db5d02b48 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -20,15 +20,14 @@ def can_build():
def get_opts():
return [
- ('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
- ('NDK_TOOLCHAIN', 'toolchain to use for the NDK',"arm-eabi-4.4.0"),
- #android 2.3
- ('ndk_platform', 'compile for platform: (2.2,2.3)',"2.2"),
- ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"),
- ('android_stl','enable STL support in android port (for modules)','no'),
- ('armv6','compile for older phones running arm v6 (instead of v7+neon+smp)','no'),
- ('x86','Xompile for Android-x86','no')
-
+ ('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
+ ('NDK_TOOLCHAIN', 'toolchain to use for the NDK',"arm-eabi-4.4.0"),
+ ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"),
+ ('NDK_TARGET_X86', 'toolchain to use for the NDK x86',"x86-4.8"),
+ ('ndk_platform', 'compile for platform: (android-<api> , example: android-15)',"android-15"),
+ ('android_arch', 'select compiler architecture: (armv7/armv6/x86)',"armv7"),
+ ('android_neon','enable neon (armv7 only)',"yes"),
+ ('android_stl','enable STL support in android port (for modules)',"no")
]
def get_flags():
@@ -38,8 +37,6 @@ def get_flags():
('nedmalloc', 'no'),
('builtin_zlib', 'no'),
('openssl','builtin'), #use builtin openssl
- ('theora','no'), #use builtin openssl
-
]
@@ -54,31 +51,82 @@ def create(env):
def configure(env):
- if env['x86']=='yes':
- env['NDK_TARGET']='x86-4.8'
+ # Workaround for MinGW. See:
+ # http://www.scons.org/wiki/LongCmdLinesOnWin32
+ import os
+ if (os.name=="nt"):
+
+ import subprocess
+
+ def mySubProcess(cmdline,env):
+ #print "SPAWNED : " + cmdline
+ startupinfo = subprocess.STARTUPINFO()
+ startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+ proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
+ data, err = proc.communicate()
+ rv = proc.wait()
+ if rv:
+ print "====="
+ print err
+ print "====="
+ return rv
+
+ def mySpawn(sh, escape, cmd, args, env):
+
+ newargs = ' '.join(args[1:])
+ cmdline = cmd + " " + newargs
+
+ rv=0
+ if len(cmdline) > 32000 and cmd.endswith("ar") :
+ cmdline = cmd + " " + args[1] + " " + args[2] + " "
+ for i in range(3,len(args)) :
+ rv = mySubProcess( cmdline + args[i], env )
+ if rv :
+ break
+ else:
+ rv = mySubProcess( cmdline, env )
+
+ return rv
+
+ env['SPAWN'] = mySpawn
+
+ ndk_platform=env['ndk_platform']
+
+ if env['android_arch'] not in ['armv7','armv6','x86']:
+ env['android_arch']='armv7'
+
+ if env['android_arch']=='x86':
+ env['NDK_TARGET']=env['NDK_TARGET_X86']
if env['PLATFORM'] == 'win32':
import methods
env.Tool('gcc')
- env['SPAWN'] = methods.win32_spawn
+ #env['SPAWN'] = methods.win32_spawn
env['SHLIBSUFFIX'] = '.so'
-# env.android_source_modules.append("../libs/apk_expansion")
+ #env.android_source_modules.append("../libs/apk_expansion")
env.android_source_modules.append("../libs/google_play_services")
env.android_source_modules.append("../libs/downloader_library")
env.android_source_modules.append("../libs/play_licensing")
-
- ndk_platform=""
-
- ndk_platform="android-15"
- print("Godot Android!!!!!")
+ neon_text=""
+ if env["android_arch"]=="armv7" and env['android_neon']=='yes':
+ neon_text=" (with neon)"
+ print("Godot Android!!!!! ("+env['android_arch']+")"+neon_text)
env.Append(CPPPATH=['#platform/android'])
- if env['x86']=='yes':
- env.extra_suffix=".x86"
-
+ if env['android_arch']=='x86':
+ env.extra_suffix=".x86"+env.extra_suffix
+ elif env['android_arch']=='armv6':
+ env.extra_suffix=".armv6"+env.extra_suffix
+ elif env["android_arch"]=="armv7":
+ if env['android_neon']=='yes':
+ env.extra_suffix=".armv7.neon"+env.extra_suffix
+ else:
+ env.extra_suffix=".armv7"+env.extra_suffix
+
gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/";
import os
@@ -91,12 +139,12 @@ def configure(env):
gcc_path=gcc_path+"/darwin-x86_64/bin" #this may be wrong
env['SHLINKFLAGS'][1] = '-shared'
elif (os.name=="nt"):
- gcc_path=gcc_path+"/windows/bin" #this may be wrong
+ gcc_path=gcc_path+"/windows-x86_64/bin" #this may be wrong
env['ENV']['PATH'] = gcc_path+":"+env['ENV']['PATH']
- if env['x86']=='yes':
+ if env['android_arch']=='x86':
env['CC'] = gcc_path+'/i686-linux-android-gcc'
env['CXX'] = gcc_path+'/i686-linux-android-g++'
env['AR'] = gcc_path+"/i686-linux-android-ar"
@@ -109,7 +157,7 @@ def configure(env):
env['RANLIB'] = gcc_path+"/arm-linux-androideabi-ranlib"
env['AS'] = gcc_path+"/arm-linux-androideabi-as"
- if env['x86']=='yes':
+ if env['android_arch']=='x86':
env['ARCH'] = 'arch-x86'
else:
env['ARCH'] = 'arch-arm'
@@ -123,18 +171,23 @@ def configure(env):
env.Append(CPPPATH=[gcc_include])
# env['CCFLAGS'] = string.split('-DNO_THREADS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -mthumb -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED ')
- if env['x86']=='yes':
- env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED -DGLES1_ENABLED')
- elif env["armv6"]!="no":
- env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED -DGLES1_ENABLED')
- else:
- env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_7__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED -DGLES1_ENABLED')
+ env['neon_enabled']=False
+ if env['android_arch']=='x86':
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__ -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ elif env["android_arch"]=="armv6":
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__ -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ elif env["android_arch"]=="armv7":
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__GLIBC__ -Wno-psabi -march=armv7-a -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+ if env['android_neon']=='yes':
+ env['neon_enabled']=True
+ env.Append(CCFLAGS=['-mfpu=neon','-D__ARM_NEON__'])
+ else:
+ env.Append(CCFLAGS=['-mfpu=vfpv3-d16'])
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 ")
@@ -153,17 +206,26 @@ def configure(env):
env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED'])
env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
- if env["armv6"] == "no" and env['x86'] != 'yes':
- env['neon_enabled']=True
-
env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT'])
# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
+ if(env["opus"]=="yes"):
+ env.Append(CFLAGS=["-DOPUS_ARM_OPT"])
+ env.opus_fixed_point="yes"
+
if (env['android_stl']=='yes'):
#env.Append(CCFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/system/include"])
- env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/include"])
- env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi/include"])
- env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi"])
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/include"])
+ if env['android_arch']=='x86':
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86"])
+ elif env['android_arch']=='armv6':
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi"])
+ elif env["android_arch"]=="armv7":
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a"])
+
env.Append(LIBS=["gnustl_static","supc++"])
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
@@ -174,10 +236,12 @@ def configure(env):
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/include"])
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
- if env['x86']=='yes':
+ if env['android_arch']=='x86':
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/x86"])
- else:
+ elif env["android_arch"]=="armv6":
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/armeabi"])
+ elif env["android_arch"]=="armv7":
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/armeabi-v7a"])
env.Append(LIBS=['gabi++_static'])
env.Append(CCFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST'])
diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp
index 60bde61fc4..ca1e58da3f 100644
--- a/platform/android/dir_access_android.cpp
+++ b/platform/android/dir_access_android.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -79,6 +79,9 @@ bool DirAccessAndroid::current_is_dir() const{
return false;
}
+bool DirAccessAndroid::current_is_hidden() const{
+ return current!="." && current!=".." && current.begins_with(".");
+}
void DirAccessAndroid::list_dir_end(){
if (aad==NULL)
diff --git a/platform/android/dir_access_android.h b/platform/android/dir_access_android.h
index a6aead6eb3..cbbcdb71bb 100644
--- a/platform/android/dir_access_android.h
+++ b/platform/android/dir_access_android.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -52,6 +52,7 @@ public:
virtual bool list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
+ virtual bool current_is_hidden() const;
virtual void list_dir_end(); ///<
virtual int get_drive_count();
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index f32e16e7d8..2b5fc6a50a 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,11 +31,15 @@
#include "dir_access_jandroid.h"
#include "file_access_jandroid.h"
#include "thread_jandroid.h"
+#include "print_string.h"
+
+
jobject DirAccessJAndroid::io=NULL;
jclass DirAccessJAndroid::cls=NULL;
jmethodID DirAccessJAndroid::_dir_open=NULL;
jmethodID DirAccessJAndroid::_dir_next=NULL;
jmethodID DirAccessJAndroid::_dir_close=NULL;
+jmethodID DirAccessJAndroid::_dir_is_dir=NULL;
DirAccess *DirAccessJAndroid::create_fs() {
@@ -67,44 +71,25 @@ String DirAccessJAndroid::get_next(){
if (!str)
return "";
- int sl = env->GetStringLength(str);
- if (sl==0) {
- env->DeleteLocalRef((jobject)str);
- return "";
- }
-
- CharString cs;
- cs.resize(sl+1);
- env->GetStringRegion(str,0,sl,(jchar*)&cs[0]);
- cs[sl]=0;
-
- String ret;
- ret.parse_utf8(&cs[0]);
+ String ret = String::utf8(env->GetStringUTFChars( (jstring)str, NULL ));
env->DeleteLocalRef((jobject)str);
-
return ret;
}
bool DirAccessJAndroid::current_is_dir() const{
- JNIEnv *env = ThreadAndroid::get_env();
- String sd;
- if (current_dir=="")
- sd=current;
- else
- sd=current_dir+"/"+current;
- jstring js = env->NewStringUTF(sd.utf8().get_data());
+ JNIEnv *env = ThreadAndroid::get_env();
- int res = env->CallIntMethod(io,_dir_open,js);
- if (res<=0)
- return false;
+ return env->CallBooleanMethod(io,_dir_is_dir,id);
- env->CallObjectMethod(io,_dir_close,res);
+}
+bool DirAccessJAndroid::current_is_hidden() const {
- return true;
+ return current!="." && current!=".." && current.begins_with(".");
}
+
void DirAccessJAndroid::list_dir_end(){
if (id==0)
@@ -136,24 +121,31 @@ Error DirAccessJAndroid::change_dir(String p_dir){
String new_dir;
+ if (p_dir!="res://" && p_dir.length()>1 && p_dir.ends_with("/"))
+ p_dir=p_dir.substr(0,p_dir.length()-1);
+
if (p_dir.begins_with("/"))
new_dir=p_dir.substr(1,p_dir.length());
else if (p_dir.begins_with("res://"))
new_dir=p_dir.substr(6,p_dir.length());
- else //relative
- new_dir=new_dir+"/"+p_dir;
+ else if (current_dir=="")
+ new_dir=p_dir;
+ else
+ new_dir=current_dir.plus_file(p_dir);
+ //print_line("new dir is: "+new_dir);
//test if newdir exists
new_dir=new_dir.simplify_path();
jstring js = env->NewStringUTF(new_dir.utf8().get_data());
int res = env->CallIntMethod(io,_dir_open,js);
+ env->DeleteLocalRef(js);
if (res<=0)
return ERR_INVALID_PARAMETER;
env->CallObjectMethod(io,_dir_close,res);
-
+ current_dir=new_dir;
return OK;
}
@@ -170,7 +162,7 @@ bool DirAccessJAndroid::file_exists(String p_file){
if (current_dir=="")
sd=p_file;
else
- sd=current_dir+"/"+p_file;
+ sd=current_dir.plus_file(p_file);
FileAccessJAndroid *f = memnew(FileAccessJAndroid);
bool exists = f->file_exists(sd);
@@ -184,12 +176,19 @@ bool DirAccessJAndroid::dir_exists(String p_dir) {
JNIEnv *env = ThreadAndroid::get_env();
String sd;
+
+
if (current_dir=="")
sd=p_dir;
- else
- sd=current_dir+"/"+p_dir;
+ else {
+ if (p_dir.is_rel_path())
+ sd=current_dir.plus_file(p_dir);
+ else
+ sd=fix_path(p_dir);
+ }
+
+ String path=sd.simplify_path();
- String path=fix_path(sd).simplify_path();
if (path.begins_with("/"))
path=path.substr(1,path.length());
else if (path.begins_with("res://"))
@@ -197,6 +196,7 @@ bool DirAccessJAndroid::dir_exists(String p_dir) {
jstring js = env->NewStringUTF(path.utf8().get_data());
int res = env->CallIntMethod(io,_dir_open,js);
+ env->DeleteLocalRef(js);
if (res<=0)
return false;
@@ -250,6 +250,10 @@ void DirAccessJAndroid::setup( jobject p_io) {
if(_dir_close != 0) {
__android_log_print(ANDROID_LOG_INFO,"godot","*******GOT METHOD _dir_close ok!!");
}
+ _dir_is_dir = env->GetMethodID(cls, "dir_is_dir", "(I)Z");
+ if(_dir_is_dir != 0) {
+ __android_log_print(ANDROID_LOG_INFO,"godot","*******GOT METHOD _dir_is_dir ok!!");
+ }
// (*env)->CallVoidMethod(env,obj,aMethodID, myvar);
}
diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h
index 958ea34891..7b6242ca32 100644
--- a/platform/android/dir_access_jandroid.h
+++ b/platform/android/dir_access_jandroid.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,6 +47,7 @@ class DirAccessJAndroid : public DirAccess {
static jmethodID _dir_open;
static jmethodID _dir_next;
static jmethodID _dir_close;
+ static jmethodID _dir_is_dir;
int id;
@@ -60,6 +61,7 @@ public:
virtual bool list_dir_begin(); ///< This starts dir listing
virtual String get_next();
virtual bool current_is_dir() const;
+ virtual bool current_is_hidden() const;
virtual void list_dir_end(); ///<
virtual int get_drive_count();
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 3e4ea8a4e0..1deeb3457a 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -185,6 +185,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool _signed;
bool apk_expansion;
bool remove_prev;
+ bool use_32_fb;
+ bool immersive;
+ bool export_arm;
+ bool export_x86;
String apk_expansion_salt;
String apk_expansion_pkey;
int orientation;
@@ -221,8 +225,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
static void _device_poll_thread(void *ud);
+ String get_package_name();
+
String get_project_name() const;
- void _fix_manifest(Vector<uint8_t>& p_manifest);
+ void _fix_manifest(Vector<uint8_t>& p_manifest, bool p_give_internet);
void _fix_resources(Vector<uint8_t>& p_manifest);
static Error save_apk_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total);
@@ -243,11 +249,11 @@ public:
virtual int get_device_count() const;
virtual String get_device_name(int p_device) const;
virtual String get_device_info(int p_device) const;
- virtual Error run(int p_device,bool p_dumb=false);
+ virtual Error run(int p_device,int p_flags=0);
virtual bool requieres_password(bool p_debug) const { return !p_debug; }
virtual String get_binary_extension() const { return "apk"; }
- virtual Error export_project(const String& p_path,bool p_debug,bool p_dumb=false);
+ virtual Error export_project(const String& p_path, bool p_debug, int p_flags=0);
virtual bool can_export(String *r_error=NULL) const;
@@ -279,6 +285,14 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
icon=p_value;
else if (n=="package/signed")
_signed=p_value;
+ else if (n=="architecture/arm")
+ export_arm=p_value;
+ else if (n=="architecture/x86")
+ export_x86=p_value;
+ else if (n=="screen/use_32_bits_view")
+ use_32_fb=p_value;
+ else if (n=="screen/immersive_mode")
+ immersive=p_value;
else if (n=="screen/orientation")
orientation=p_value;
else if (n=="screen/support_small")
@@ -303,7 +317,7 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
apk_expansion_pkey=p_value;
else if (n.begins_with("permissions/")) {
- String what = n.get_slice("/",1).to_upper();
+ String what = n.get_slicec('/',1).to_upper();
bool state = p_value;
if (state)
perms.insert(what);
@@ -311,7 +325,7 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
perms.erase(what);
} else if (n.begins_with("user_permissions/")) {
- int which = n.get_slice("/",1).to_int();
+ int which = n.get_slicec('/',1).to_int();
ERR_FAIL_INDEX_V(which,MAX_USER_PERMISSIONS,false);
user_perms[which]=p_value;
@@ -344,6 +358,14 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret)
r_ret=icon;
else if (n=="package/signed")
r_ret=_signed;
+ else if (n=="architecture/arm")
+ r_ret=export_arm;
+ else if (n=="architecture/x86")
+ r_ret=export_x86;
+ else if (n=="screen/use_32_bits_view")
+ r_ret=use_32_fb;
+ else if (n=="screen/immersive_mode")
+ r_ret=immersive;
else if (n=="screen/orientation")
r_ret=orientation;
else if (n=="screen/support_small")
@@ -368,11 +390,11 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret)
r_ret=apk_expansion_pkey;
else if (n.begins_with("permissions/")) {
- String what = n.get_slice("/",1).to_upper();
+ String what = n.get_slicec('/',1).to_upper();
r_ret = perms.has(what);
} else if (n.begins_with("user_permissions/")) {
- int which = n.get_slice("/",1).to_int();
+ int which = n.get_slicec('/',1).to_int();
ERR_FAIL_INDEX_V(which,MAX_USER_PERMISSIONS,false);
r_ret=user_perms[which];
} else
@@ -393,6 +415,10 @@ void EditorExportPlatformAndroid::_get_property_list( List<PropertyInfo> *p_list
p_list->push_back( PropertyInfo( Variant::STRING, "package/name") );
p_list->push_back( PropertyInfo( Variant::STRING, "package/icon",PROPERTY_HINT_FILE,"png") );
p_list->push_back( PropertyInfo( Variant::BOOL, "package/signed") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/arm") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/x86") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "screen/use_32_bits_view") );
+ p_list->push_back( PropertyInfo( Variant::BOOL, "screen/immersive_mode") );
p_list->push_back( PropertyInfo( Variant::INT, "screen/orientation",PROPERTY_HINT_ENUM,"Landscape,Portrait") );
p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_small") );
p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_normal") );
@@ -582,7 +608,7 @@ String EditorExportPlatformAndroid::get_project_name() const {
}
-void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
+void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool p_give_internet) {
const int CHUNK_AXML_FILE = 0x00080003;
@@ -629,11 +655,11 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
int iofs=ofs+8;
- uint32_t string_count=decode_uint32(&p_manifest[iofs]);
- uint32_t styles_count=decode_uint32(&p_manifest[iofs+4]);
+ string_count=decode_uint32(&p_manifest[iofs]);
+ styles_count=decode_uint32(&p_manifest[iofs+4]);
uint32_t string_flags=decode_uint32(&p_manifest[iofs+8]);
- uint32_t string_data_offset=decode_uint32(&p_manifest[iofs+12]);
- uint32_t styles_offset=decode_uint32(&p_manifest[iofs+16]);
+ string_data_offset=decode_uint32(&p_manifest[iofs+12]);
+ styles_offset=decode_uint32(&p_manifest[iofs+16]);
/*
printf("string count: %i\n",string_count);
printf("flags: %i\n",string_flags);
@@ -732,7 +758,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
if (tname=="manifest" && attrname=="package") {
print_line("FOUND PACKAGE");
- string_table[attr_value]=package;
+ string_table[attr_value]=get_package_name();
}
//print_line("tname: "+tname);
@@ -756,19 +782,21 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
if (tname=="activity" && /*nspace=="android" &&*/ attrname=="screenOrientation") {
+ encode_uint32(orientation==0?0:1,&p_manifest[iofs+16]);
+ /*
print_line("FOUND screen orientation");
if (attr_value==0xFFFFFFFF) {
WARN_PRINT("Version name in a resource, should be plaintext")
} else {
string_table[attr_value]=(orientation==0?"landscape":"portrait");
- }
+ }*/
}
if (tname=="application" && /*nspace=="android" &&*/ attrname=="label") {
print_line("FOUND application");
if (attr_value==0xFFFFFFFF) {
- WARN_PRINT("Application name in a resource, should be plaintext.")
+ WARN_PRINT("Application name in a resource, should be plaintext (but you can ignore this).")
} else {
String aname = get_project_name();
@@ -779,7 +807,7 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
print_line("FOUND activity name");
if (attr_value==0xFFFFFFFF) {
- WARN_PRINT("Activity name in a resource, should be plaintext")
+ WARN_PRINT("Activity name in a resource, should be plaintext (but you can ignore this)")
} else {
String aname;
if (this->name!="") {
@@ -810,7 +838,10 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
} else if (value.begins_with("godot.")) {
String perm = value.get_slice(".",1);
- if (perms.has(perm)) {
+ print_line("PERM: "+perm+" HAS: "+itos(perms.has(perm)));
+
+ if (perms.has(perm) || (p_give_internet && perm=="INTERNET")) {
+
string_table[attr_value]="android.permission."+perm;
}
@@ -823,23 +854,19 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest) {
WARN_PRINT("Screen res name in a resource, should be plaintext")
} else if (attrname=="smallScreens") {
- print_line("SMALLSCREEN");
- string_table[attr_value]=screen_support[SCREEN_SMALL]?"true":"false";
+ encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
} else if (attrname=="mediumScreens") {
- print_line("MEDSCREEN");
- string_table[attr_value]=screen_support[SCREEN_NORMAL]?"true":"false";
+ encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
} else if (attrname=="largeScreens") {
- print_line("LARGECREEN");
- string_table[attr_value]=screen_support[SCREEN_LARGE]?"true":"false";
+ encode_uint32(screen_support[SCREEN_LARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
} else if (attrname=="xlargeScreens") {
- print_line("XLARGECREEN");
- string_table[attr_value]=screen_support[SCREEN_XLARGE]?"true":"false";
+ encode_uint32(screen_support[SCREEN_XLARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
}
}
@@ -987,7 +1014,7 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String&
-Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_debug, bool p_dumb) {
+Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_debug, int p_flags) {
String src_apk;
@@ -1035,6 +1062,8 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
char fname[16384];
ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+ bool skip=false;
+
String file=fname;
Vector<uint8_t> data;
@@ -1049,7 +1078,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
if (file=="AndroidManifest.xml") {
- _fix_manifest(data);
+ _fix_manifest(data,p_flags&(EXPORT_DUMB_CLIENT|EXPORT_REMOTE_DEBUG));
}
if (file=="resources.arsc") {
@@ -1087,20 +1116,35 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
}
}
+ if (file=="lib/x86/libgodot_android.so" && !export_x86) {
+ skip=true;
+ }
+
+ if (file=="lib/armeabi/libgodot_android.so" && !export_arm) {
+ skip=true;
+ }
+
+ if (file.begins_with("META-INF") && _signed) {
+ skip=true;
+ }
+
print_line("ADDING: "+file);
- zipOpenNewFileInZip(apk,
- file.utf8().get_data(),
- NULL,
- NULL,
- 0,
- NULL,
- 0,
- NULL,
- Z_DEFLATED,
- Z_DEFAULT_COMPRESSION);
- zipWriteInFileInZip(apk,data.ptr(),data.size());
- zipCloseFileInZip(apk);
+ if (!skip) {
+ zipOpenNewFileInZip(apk,
+ file.utf8().get_data(),
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(apk,data.ptr(),data.size());
+ zipCloseFileInZip(apk);
+ }
ret = unzGoToNextFile(pkg);
}
@@ -1116,9 +1160,11 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
}
}
- if (p_dumb) {
+ gen_export_flags(cl,p_flags);
+
+ if (p_flags) {
- String host = EditorSettings::get_singleton()->get("file_server/host");
+ /*String host = EditorSettings::get_singleton()->get("file_server/host");
int port = EditorSettings::get_singleton()->get("file_server/post");
String passwd = EditorSettings::get_singleton()->get("file_server/password");
cl.push_back("-rfs");
@@ -1126,7 +1172,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
if (passwd!="") {
cl.push_back("-rfs_pass");
cl.push_back(passwd);
- }
+ }*/
} else {
@@ -1134,7 +1180,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
if (apk_expansion) {
- String apkfname="main."+itos(version_code)+"."+package+".obb";
+ String apkfname="main."+itos(version_code)+"."+get_package_name()+".obb";
String fullpath=p_path.get_base_dir().plus_file(apkfname);
FileAccess *pf = FileAccess::open(fullpath,FileAccess::WRITE);
if (!pf) {
@@ -1158,8 +1204,16 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
err = export_project_files(save_apk_file,&ed,false);
}
+
+
}
+ if (use_32_fb)
+ cl.push_back("-use_depth_32");
+
+ if (immersive)
+ cl.push_back("-use_immersive");
+
if (cl.size()) {
//add comandline
Vector<uint8_t> clf;
@@ -1435,7 +1489,7 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
}
-Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) {
+Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
ERR_FAIL_INDEX_V(p_device,devices.size(),ERR_INVALID_PARAMETER);
device_lock->lock();
@@ -1454,7 +1508,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) {
ep.step("Exporting APK",0);
String export_to=EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmpexport.apk";
- Error err = export_project(export_to,true,p_dumb);
+ Error err = export_project(export_to,true,p_flags);
if (err) {
device_lock->unlock();
return err;
@@ -1471,7 +1525,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) {
args.push_back("-s");
args.push_back(devices[p_device].id);
args.push_back("uninstall");
- args.push_back(package);
+ args.push_back(get_package_name());
err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv);
#if 0
@@ -1509,7 +1563,7 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) {
args.push_back("-a");
args.push_back("android.intent.action.MAIN");
args.push_back("-n");
- args.push_back(package+"/com.android.godot.Godot");
+ args.push_back(get_package_name()+"/com.android.godot.Godot");
err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv);
if (err || rv!=0) {
@@ -1521,12 +1575,37 @@ Error EditorExportPlatformAndroid::run(int p_device, bool p_dumb) {
return OK;
}
+String EditorExportPlatformAndroid::get_package_name() {
+
+ String pname = package;
+ String basename = Globals::get_singleton()->get("application/name");
+ basename=basename.to_lower();
+
+ String name;
+ bool first=true;
+ for(int i=0;i<basename.length();i++) {
+ CharType c = basename[i];
+ if (c>='0' && c<='9' && first) {
+ continue;
+ }
+ if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9')) {
+ name+=String::chr(c);
+ first=false;
+ }
+ }
+ if (name=="")
+ name="noname";
+
+ pname=pname.replace("$genname",name);
+ return pname;
+
+}
EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
version_code=1;
version_name="1.0";
- package="com.android.noname";
+ package="org.godotengine.$genname";
name="";
_signed=true;
apk_expansion=false;
@@ -1534,6 +1613,12 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
quit_request=false;
orientation=0;
remove_prev=true;
+ use_32_fb=true;
+ immersive=true;
+
+ export_arm=true;
+ export_x86=false;
+
device_thread=Thread::create(_device_poll_thread,this);
devices_changed=true;
@@ -1613,8 +1698,11 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const {
EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
+
quit_request=true;
Thread::wait_to_finish(device_thread);
+ memdelete(device_lock);
+ memdelete(device_thread);
}
diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp
index f1a2bf5882..ff70d5ae76 100644
--- a/platform/android/file_access_android.cpp
+++ b/platform/android/file_access_android.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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 080ab1a6ce..506c2c023f 100644
--- a/platform/android/file_access_android.h
+++ b/platform/android/file_access_android.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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 e1dec4f601..be38d806b2 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -62,14 +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/file_access_jandroid.h b/platform/android/file_access_jandroid.h
index 3cbeab5ffc..13ac4e17b8 100644
--- a/platform/android/file_access_jandroid.h
+++ b/platform/android/file_access_jandroid.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp
index 84a586d22d..824a4e3606 100644
--- a/platform/android/globals/global_defaults.cpp
+++ b/platform/android/globals/global_defaults.cpp
@@ -10,5 +10,5 @@ void register_android_global_defaults() {
GLOBAL_DEF("display.Android/driver","GLES2");
// GLOBAL_DEF("rasterizer.Android/trilinear_mipmap_filter",false);
- Globals::get_singleton()->set_custom_property_info("display.Android/driver",PropertyInfo(Variant::STRING,"display.Android/driver",PROPERTY_HINT_ENUM,"GLES1,GLES2"));
+ Globals::get_singleton()->set_custom_property_info("display.Android/driver",PropertyInfo(Variant::STRING,"display.Android/driver",PROPERTY_HINT_ENUM,"GLES2"));
}
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index 673ff91641..388ff06c10 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png
index 050a1cf930..013632ddf1 100644
--- a/platform/android/java/res/drawable/icon.png
+++ b/platform/android/java/res/drawable/icon.png
Binary files differ
diff --git a/platform/android/java/res/values-fa/strings.xml b/platform/android/java/res/values-fa/strings.xml
new file mode 100644
index 0000000000..450f9fe212
--- /dev/null
+++ b/platform/android/java/res/values-fa/strings.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="godot_project_name_string">godot-project-name-fa</string>
+ <string name="testuf8">سلام</string>
+ <string name="text_paused_cellular">آیا می خواهید بر روی اتصال داده همراه دانلود را شروع کنید؟ بر اساس نوع سطح داده شما این ممکن است برای شما هزینه مالی داشته باشد.</string>
+ <string name="text_paused_cellular_2">اگر نمی خواهید بر روی اتصال داده همراه دانلود را شروع کنید ، دانلود به صورت خودکار در زمان دسترسی به وای-فای شروع می شود.</string>
+ <string name="text_button_resume_cellular">ادامه دانلود</string>
+ <string name="text_button_wifi_settings">تنظیمات وای-فای</string>
+ <string name="text_verifying_download">درحال تایید دانلود</string>
+ <string name="text_validation_complete">تایید فایل XAPK تکمیل شد. برای خروج تایید کنید.</string>
+ <string name="text_validation_failed">اعتبارسنجی فایل XAPK ناموق.</string>
+ <string name="text_button_pause">توقف دانلود</string>
+ <string name="text_button_resume">ادامه دانلود</string>
+ <string name="text_button_cancel">انصراف</string>
+ <string name="text_button_cancel_verify">انصراف از تایید شدن</string>
+</resources>
diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java
index f6cd57f4f3..4c5a313576 100644
--- a/platform/android/java/src/com/android/godot/Godot.java
+++ b/platform/android/java/src/com/android/godot/Godot.java
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -109,6 +109,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private Button mPauseButton;
private Button mWiFiSettingsButton;
+ private boolean use_32_bits=false;
+ private boolean use_immersive=false;
private boolean mStatePaused;
private int mState;
@@ -255,7 +257,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
// ...add to FrameLayout
layout.addView(edittext);
- mView = new GodotView(getApplication(),io,use_gl2, this);
+ mView = new GodotView(getApplication(),io,use_gl2,use_32_bits, this);
layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
mView.setKeepScreenOn(true);
@@ -355,10 +357,10 @@ 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_NORMAL);
+ mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
result_callback = null;
@@ -373,6 +375,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger());
}
+
+
@Override
protected void onCreate(Bundle icicle) {
@@ -399,7 +403,22 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
for(int i=0;i<command_line.length;i++) {
boolean has_extra = i< command_line.length -1;
- if (command_line[i].equals("-use_apk_expansion")) {
+ if (command_line[i].equals("-use_depth_32")) {
+ use_32_bits=true;
+ } else if (command_line[i].equals("-use_immersive")) {
+ use_immersive=true;
+ if(Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+
+ window.getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
+ | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+
+ UiChangeListener();
+ }
+ } else if (command_line[i].equals("-use_apk_expansion")) {
use_apk_expansion=true;
} else if (has_extra && command_line[i].equals("-apk_expansion_md5")) {
main_pack_md5=command_line[i+1];
@@ -557,6 +576,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mView.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
GodotLib.focusin();
+ if(use_immersive && Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+
+ Window window = getWindow();
+ window.getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
+ | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
for(int i=0;i<singleton_count;i++) {
@@ -567,10 +596,43 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
+ public void UiChangeListener() {
+ final View decorView = getWindow().getDecorView();
+ decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() {
+ @Override
+ public void onSystemUiVisibilityChange(int visibility) {
+ if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
+ decorView.setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
+ }
+ }
+ });
+ }
+
@Override public void onSensorChanged(SensorEvent event) {
- float x = event.values[0];
- float y = event.values[1];
- float z = event.values[2];
+ Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
+ int displayRotation = display.getRotation();
+
+ float[] adjustedValues = new float[3];
+ final int axisSwap[][] = {
+ { 1, -1, 0, 1 }, // ROTATION_0
+ {-1, -1, 1, 0 }, // ROTATION_90
+ {-1, 1, 0, 1 }, // ROTATION_180
+ { 1, 1, 1, 0 } }; // ROTATION_270
+
+ final int[] as = axisSwap[displayRotation];
+ adjustedValues[0] = (float)as[0] * event.values[ as[2] ];
+ adjustedValues[1] = (float)as[1] * event.values[ as[3] ];
+ adjustedValues[2] = event.values[2];
+
+ float x = adjustedValues[0];
+ float y = adjustedValues[1];
+ float z = adjustedValues[2];
GodotLib.accelerometer(x,y,z);
}
@@ -685,7 +747,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
//}
} break;
case MotionEvent.ACTION_POINTER_UP: {
- int pointer_idx = event.getActionIndex();
+ final int indexPointUp = event.getActionIndex();
+ final int pointer_idx = event.getPointerId(indexPointUp);
GodotLib.touch(4,pointer_idx,evcount,arr);
//System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java
index ff0eb5edcc..a7dc0c2f75 100644
--- a/platform/android/java/src/com/android/godot/GodotIO.java
+++ b/platform/android/java/src/com/android/godot/GodotIO.java
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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;
}
@@ -271,6 +272,7 @@ public class GodotIO {
public String[] files;
public int current;
+ public String path;
}
public int last_dir_id=1;
@@ -281,6 +283,7 @@ public class GodotIO {
AssetDir ad = new AssetDir();
ad.current=0;
+ ad.path=path;
try {
ad.files = am.list(path);
@@ -290,6 +293,7 @@ public class GodotIO {
return -1;
}
+ //System.out.printf("Opened dir: %s\n",path);
++last_dir_id;
dirs.put(last_dir_id,ad);
@@ -297,6 +301,32 @@ public class GodotIO {
}
+ public boolean dir_is_dir(int id) {
+ if (!dirs.containsKey(id)) {
+ System.out.printf("dir_next: invalid dir id: %d\n",id);
+ return false;
+ }
+ AssetDir ad = dirs.get(id);
+ //System.out.printf("go next: %d,%d\n",ad.current,ad.files.length);
+ int idx = ad.current;
+ if (idx>0)
+ idx--;
+
+ if (idx>=ad.files.length)
+ return false;
+ String fname = ad.files[idx];
+
+ try {
+ if (ad.path.equals(""))
+ am.open(fname);
+ else
+ am.open(ad.path+"/"+fname);
+ return false;
+ } catch (Exception e) {
+ return true;
+ }
+ }
+
public String dir_next(int id) {
if (!dirs.containsKey(id)) {
@@ -305,8 +335,12 @@ public class GodotIO {
}
AssetDir ad = dirs.get(id);
- if (ad.current>=ad.files.length)
+ //System.out.printf("go next: %d,%d\n",ad.current,ad.files.length);
+
+ if (ad.current>=ad.files.length) {
+ ad.current++;
return "";
+ }
String r = ad.files[ad.current];
ad.current++;
return r;
diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java
index 6e2462b4f1..f099e0feff 100644
--- a/platform/android/java/src/com/android/godot/GodotLib.java
+++ b/platform/android/java/src/com/android/godot/GodotLib.java
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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/src/com/android/godot/GodotPaymentV3.java b/platform/android/java/src/com/android/godot/GodotPaymentV3.java
index 0fd102ac55..0799e1e83d 100644
--- a/platform/android/java/src/com/android/godot/GodotPaymentV3.java
+++ b/platform/android/java/src/com/android/godot/GodotPaymentV3.java
@@ -27,7 +27,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
activity.getPaymentsManager().requestPurchase(sku, transactionId);
}
});
- };
+ }
/* public string requestPurchasedTicket(){
activity.getPaymentsManager()
@@ -42,7 +42,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
public GodotPaymentV3(Activity p_activity) {
- registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases"});
+ registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume"});
activity=(Godot) p_activity;
}
@@ -54,7 +54,6 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
activity.getPaymentsManager().consumeUnconsumedPurchases();
}
});
-
}
private String signature;
@@ -63,25 +62,26 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
}
- public void callbackSuccess(String ticket, String signature){
-// Log.d(this.getClass().getName(), "PRE-Send callback to purchase success");
- GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature});
-// Log.d(this.getClass().getName(), "POST-Send callback to purchase success");
+ public void callbackSuccess(String ticket, String signature, String sku){
+// Log.d(this.getClass().getName(), "PRE-Send callback to purchase success");
+ GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature, sku});
+// Log.d(this.getClass().getName(), "POST-Send callback to purchase success");
}
public void callbackSuccessProductMassConsumed(String ticket, String signature, String sku){
-// Log.d(this.getClass().getName(), "PRE-Send callback to consume success");
- GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku});
-// Log.d(this.getClass().getName(), "POST-Send callback to consume success");
+// Log.d(this.getClass().getName(), "PRE-Send callback to consume success");
+ Log.d(this.getClass().getName(), "callbackSuccessProductMassConsumed > "+ticket+","+signature+","+sku);
+ GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku});
+// Log.d(this.getClass().getName(), "POST-Send callback to consume success");
}
public void callbackSuccessNoUnconsumedPurchases(){
- GodotLib.calldeferred(purchaseCallbackId, "no_validation_required", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "no_validation_required", new Object[]{});
}
public void callbackFail(){
- GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
-// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
+// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
}
public void callbackCancel(){
@@ -89,6 +89,10 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
// GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{});
}
+ public void callbackAlreadyOwned(String sku){
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_owned", new Object[]{sku});
+ }
+
public int getPurchaseCallbackId() {
return purchaseCallbackId;
}
@@ -97,8 +101,6 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
this.purchaseCallbackId = purchaseCallbackId;
}
-
-
public String getPurchaseValidationUrlPrefix(){
return this.purchaseValidationUrlPrefix ;
}
@@ -107,12 +109,10 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
this.purchaseValidationUrlPrefix = url;
}
-
public String getAccessToken() {
return accessToken;
}
-
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
@@ -125,4 +125,30 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
return this.transactionId;
}
+ // request purchased items are not consumed
+ public void requestPurchased(){
+ activity.getPaymentsManager().setBaseSingleton(this);
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ activity.getPaymentsManager().requestPurchased();
+ }
+ });
+ }
+
+ // callback for requestPurchased()
+ public void callbackPurchased(String receipt, String signature, String sku){
+ GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[]{receipt, signature, sku});
+ }
+
+ // consume item automatically after purchase. default is true.
+ public void setAutoConsume(boolean autoConsume){
+ activity.getPaymentsManager().setAutoConsume(autoConsume);
+ }
+
+ // consume a specific item
+ public void consume(String sku){
+ activity.getPaymentsManager().consume(sku);
+ }
}
+
diff --git a/platform/android/java/src/com/android/godot/GodotView.java b/platform/android/java/src/com/android/godot/GodotView.java
index f62431b94b..1a84923065 100644
--- a/platform/android/java/src/com/android/godot/GodotView.java
+++ b/platform/android/java/src/com/android/godot/GodotView.java
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -71,14 +71,16 @@ public class GodotView extends GLSurfaceView {
private static GodotIO io;
private static boolean firsttime=true;
private static boolean use_gl2=false;
+ private static boolean use_32=false;
private Godot activity;
- public GodotView(Context context,GodotIO p_io,boolean p_use_gl2, Godot p_activity) {
+ public GodotView(Context context,GodotIO p_io,boolean p_use_gl2, boolean p_use_32_bits, Godot p_activity) {
super(context);
ctx=context;
io=p_io;
use_gl2=p_use_gl2;
+ use_32=p_use_32_bits;
activity = p_activity;
@@ -366,9 +368,17 @@ public class GodotView extends GLSurfaceView {
* custom config chooser. See ConfigChooser class definition
* below.
*/
- setEGLConfigChooser( translucent ?
- new ConfigChooser(8, 8, 8, 8, depth, stencil) :
- new ConfigChooser(5, 6, 5, 0, depth, stencil) );
+
+ if (use_32) {
+ setEGLConfigChooser( translucent ?
+ new FallbackConfigChooser(8, 8, 8, 8, 24, stencil, new ConfigChooser(8, 8, 8, 8, 16, stencil)) :
+ new FallbackConfigChooser(8, 8, 8, 8, 24, stencil, new ConfigChooser(5, 6, 5, 0, 16, stencil)) );
+
+ } else {
+ setEGLConfigChooser( translucent ?
+ new ConfigChooser(8, 8, 8, 8, 16, stencil) :
+ new ConfigChooser(5, 6, 5, 0, 16, stencil) );
+ }
/* Set the renderer responsible for frame rendering */
setRenderer(new Renderer());
@@ -400,6 +410,25 @@ public class GodotView extends GLSurfaceView {
Log.e(TAG, String.format("%s: EGL error: 0x%x", prompt, error));
}
}
+ /* Fallback if 32bit View is not supported*/
+ private static class FallbackConfigChooser extends ConfigChooser {
+ private ConfigChooser fallback;
+
+ public FallbackConfigChooser(int r, int g, int b, int a, int depth, int stencil, ConfigChooser fallback) {
+ super(r, g, b, a, depth, stencil);
+ this.fallback = fallback;
+ }
+
+ @Override
+ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
+ EGLConfig ec = super.chooseConfig(egl, display, configs);
+ if (ec == null) {
+ Log.w(TAG, "Trying ConfigChooser fallback");
+ ec = fallback.chooseConfig(egl, display, configs);
+ }
+ return ec;
+ }
+ }
private static class ConfigChooser implements GLSurfaceView.EGLConfigChooser {
diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
index fd1a62738a..189f7108c1 100644
--- a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
@@ -25,10 +25,8 @@ import com.android.vending.billing.IInAppBillingService;
public class PaymentsManager {
public static final int BILLING_RESPONSE_RESULT_OK = 0;
-
-
public static final int REQUEST_CODE_FOR_PURCHASE = 0x1001;
-
+ private static boolean auto_consume = true;
private Activity activity;
IInAppBillingService mService;
@@ -47,8 +45,10 @@ public class PaymentsManager {
}
public PaymentsManager initService(){
+ Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
+ intent.setPackage("com.android.vending");
activity.bindService(
- new Intent("com.android.vending.billing.InAppBillingService.BIND"),
+ intent,
mServiceConn,
Context.BIND_AUTO_CREATE);
return this;
@@ -67,13 +67,12 @@ public class PaymentsManager {
}
@Override
- public void onServiceConnected(ComponentName name,
- IBinder service) {
- mService = IInAppBillingService.Stub.asInterface(service);
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mService = IInAppBillingService.Stub.asInterface(service);
}
};
- public void requestPurchase(String sku, String transactionId){
+ public void requestPurchase(final String sku, String transactionId){
new PurchaseTask(mService, Godot.getInstance()) {
@Override
@@ -86,6 +85,12 @@ public class PaymentsManager {
protected void canceled() {
godotPaymentV3.callbackCancel();
}
+
+ @Override
+ protected void alreadyOwned() {
+ godotPaymentV3.callbackAlreadyOwned(sku);
+ }
+
}.purchase(sku, transactionId);
}
@@ -112,26 +117,82 @@ public class PaymentsManager {
}.consumeItAll();
}
+ public void requestPurchased(){
+ try{
+ PaymentsCache pc = new PaymentsCache(Godot.getInstance());
+
+// Log.d("godot", "requestPurchased for " + activity.getPackageName());
+ Bundle bundle = mService.getPurchases(3, activity.getPackageName(), "inapp",null);
+
+/*
+ for (String key : bundle.keySet()) {
+ Object value = bundle.get(key);
+ Log.d("godot", String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
+ }
+*/
+
+ if (bundle.getInt("RESPONSE_CODE") == 0){
+
+ final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
+ final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
+
+
+ if (myPurchases == null || myPurchases.size() == 0){
+// Log.d("godot", "No purchases!");
+ godotPaymentV3.callbackPurchased("", "", "");
+ return;
+ }
+
+// Log.d("godot", "# products are purchased:" + myPurchases.size());
+ for (int i=0;i<myPurchases.size();i++)
+ {
+
+ try{
+ String receipt = myPurchases.get(i);
+ JSONObject inappPurchaseData = new JSONObject(receipt);
+ String sku = inappPurchaseData.getString("productId");
+ String token = inappPurchaseData.getString("purchaseToken");
+ String signature = mySignatures.get(i);
+// Log.d("godot", "purchased item:" + token + "\n" + receipt);
+
+ pc.setConsumableValue("ticket_signautre", sku, signature);
+ pc.setConsumableValue("ticket", sku, receipt);
+ pc.setConsumableFlag("block", sku, true);
+ pc.setConsumableValue("token", sku, token);
+
+ godotPaymentV3.callbackPurchased(receipt, signature, sku);
+ } catch (JSONException e) {
+ }
+ }
+
+ }
+ }catch(Exception e){
+ Log.d("godot", "Error requesting purchased products:" + e.getClass().getName() + ":" + e.getMessage());
+ }
+ }
+
public void processPurchaseResponse(int resultCode, Intent data) {
new HandlePurchaseTask(activity){
@Override
protected void success(final String sku, final String signature, final String ticket) {
- godotPaymentV3.callbackSuccess(ticket, signature);
- new ConsumeTask(mService, activity) {
+ godotPaymentV3.callbackSuccess(ticket, signature, sku);
+
+ if (auto_consume){
+ new ConsumeTask(mService, activity) {
- @Override
- protected void success(String ticket) {
-// godotPaymentV3.callbackSuccess("");
- }
+ @Override
+ protected void success(String ticket) {
+// godotPaymentV3.callbackSuccess("");
+ }
- @Override
- protected void error(String message) {
- godotPaymentV3.callbackFail();
+ @Override
+ protected void error(String message) {
+ godotPaymentV3.callbackFail();
- }
- }.consume(sku);
-
+ }
+ }.consume(sku);
+ }
// godotPaymentV3.callbackSuccess(new PaymentsCache(activity).getConsumableValue("ticket", sku),signature);
// godotPaymentV3.callbackSuccess(ticket);
@@ -149,7 +210,7 @@ public class PaymentsManager {
godotPaymentV3.callbackCancel();
}
- }.handlePurchaseRequest(resultCode, data);
+ }.handlePurchaseRequest(resultCode, data);
}
public void validatePurchase(String purchaseToken, final String sku){
@@ -163,7 +224,7 @@ public class PaymentsManager {
@Override
protected void success(String ticket) {
- godotPaymentV3.callbackSuccess(ticket, null);
+ godotPaymentV3.callbackSuccess(ticket, null, sku);
}
@@ -190,11 +251,31 @@ public class PaymentsManager {
}.validatePurchase(sku);
}
+ public void setAutoConsume(boolean autoConsume){
+ auto_consume = autoConsume;
+ }
+
+ public void consume(final String sku){
+ new ConsumeTask(mService, activity) {
+
+ @Override
+ protected void success(String ticket) {
+ godotPaymentV3.callbackSuccessProductMassConsumed(ticket, "", sku);
+
+ }
+
+ @Override
+ protected void error(String message) {
+ godotPaymentV3.callbackFail();
+
+ }
+ }.consume(sku);
+ }
+
private GodotPaymentV3 godotPaymentV3;
public void setBaseSingleton(GodotPaymentV3 godotPaymentV3) {
this.godotPaymentV3 = godotPaymentV3;
-
}
}
diff --git a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java
index 75662a442e..c1f9d164a1 100644
--- a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java
+++ b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java
@@ -62,7 +62,11 @@ abstract public class PurchaseTask {
// Log.d("XXX", "Buy intent response code: " + responseCode);
if(responseCode == 1 || responseCode == 3 || responseCode == 4){
canceled();
- return ;
+ return;
+ }
+ if(responseCode == 7){
+ alreadyOwned();
+ return;
}
@@ -92,6 +96,6 @@ abstract public class PurchaseTask {
abstract protected void error(String message);
abstract protected void canceled();
-
+ abstract protected void alreadyOwned();
}
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 3d3ba5d276..d001cface2 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,21 +33,31 @@
#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;
-jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_arg, bool force_jobject = false) {
+struct jvalret {
+
+ jobject obj;
+ jvalue val;
+ jvalret() { obj=NULL; }
+
+
+};
+
+jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_arg, bool force_jobject = false) {
- jvalue v;
+ jvalret v;
switch(p_type) {
@@ -59,9 +69,12 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
jvalue val;
val.z = (bool)(*p_arg);
jobject obj = env->NewObjectA(bclass, ctor, &val);
- v.l = obj;
+ v.val.l = obj;
+ v.obj=obj;
+ env->DeleteLocalRef(bclass);
} else {
- v.z=*p_arg;
+ v.val.z=*p_arg;
+
};
} break;
case Variant::INT: {
@@ -73,10 +86,13 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
jvalue val;
val.i = (int)(*p_arg);
jobject obj = env->NewObjectA(bclass, ctor, &val);
- v.l = obj;
+ v.val.l = obj;
+ v.obj=obj;
+ env->DeleteLocalRef(bclass);
} else {
- v.i=*p_arg;
+ v.val.i=*p_arg;
+
};
} break;
case Variant::REAL: {
@@ -88,17 +104,20 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
jvalue val;
val.d = (double)(*p_arg);
jobject obj = env->NewObjectA(bclass, ctor, &val);
- v.l = obj;
+ v.val.l = obj;
+ v.obj=obj;
+ env->DeleteLocalRef(bclass);
} else {
- v.f=*p_arg;
+ v.val.f=*p_arg;
};
} break;
case Variant::STRING: {
String s = *p_arg;
jstring jStr = env->NewStringUTF(s.utf8().get_data());
- v.l=jStr;
+ v.val.l=jStr;
+ v.obj=jStr;
} break;
case Variant::STRING_ARRAY: {
@@ -107,9 +126,12 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
for(int j=0;j<sarray.size();j++) {
- env->SetObjectArrayElement(arr,j,env->NewStringUTF( sarray[j].utf8().get_data() ));
+ jstring str = env->NewStringUTF( sarray[j].utf8().get_data() );
+ env->SetObjectArrayElement(arr,j,str);
+ env->DeleteLocalRef(str);
}
- v.l=arr;
+ v.val.l=arr;
+ v.obj=arr;
} break;
@@ -124,27 +146,36 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
jobjectArray jkeys = env->NewObjectArray(keys.size(), env->FindClass("java/lang/String"), env->NewStringUTF(""));
for (int j=0; j<keys.size(); j++) {
- env->SetObjectArrayElement(jkeys, j, env->NewStringUTF(String(keys[j]).utf8().get_data()));
+ jstring str = env->NewStringUTF(String(keys[j]).utf8().get_data());
+ env->SetObjectArrayElement(jkeys, j, str);
+ env->DeleteLocalRef(str);
};
jmethodID set_keys = env->GetMethodID(dclass, "set_keys", "([Ljava/lang/String;)V");
jvalue val;
val.l = jkeys;
env->CallVoidMethodA(jdict, set_keys, &val);
+ env->DeleteLocalRef(jkeys);
jobjectArray jvalues = env->NewObjectArray(keys.size(), env->FindClass("java/lang/Object"), NULL);
for (int j=0; j<keys.size(); j++) {
Variant var = dict[keys[j]];
- val = _variant_to_jvalue(env, var.get_type(), &var, true);
- env->SetObjectArrayElement(jvalues, j, val.l);
+ jvalret v = _variant_to_jvalue(env, var.get_type(), &var, true);
+ env->SetObjectArrayElement(jvalues, j, v.val.l);
+ if (v.obj) {
+ env->DeleteLocalRef(v.obj);
+ }
};
jmethodID set_values = env->GetMethodID(dclass, "set_values", "([Ljava/lang/Object;)V");
val.l = jvalues;
env->CallVoidMethodA(jdict, set_values, &val);
+ env->DeleteLocalRef(jvalues);
+ env->DeleteLocalRef(dclass);
- v.l = jdict;
+ v.val.l = jdict;
+ v.obj=jdict;
} break;
case Variant::INT_ARRAY: {
@@ -153,7 +184,8 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
jintArray arr = env->NewIntArray(array.size());
DVector<int>::Read r = array.read();
env->SetIntArrayRegion(arr,0,array.size(),r.ptr());
- v.l=arr;
+ v.val.l=arr;
+ v.obj=arr;
} break;
case Variant::RAW_ARRAY: {
@@ -161,7 +193,8 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
jbyteArray arr = env->NewByteArray(array.size());
DVector<uint8_t>::Read r = array.read();
env->SetByteArrayRegion(arr,0,array.size(),reinterpret_cast<const signed char*>(r.ptr()));
- v.l=arr;
+ v.val.l=arr;
+ v.obj=arr;
} break;
case Variant::REAL_ARRAY: {
@@ -170,12 +203,13 @@ jvalue _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_ar
jfloatArray arr = env->NewFloatArray(array.size());
DVector<float>::Read r = array.read();
env->SetFloatArrayRegion(arr,0,array.size(),r.ptr());
- v.l=arr;
+ v.val.l=arr;
+ v.obj=arr;
} break;
default: {
- v.i = 0;
+ v.val.i = 0;
} break;
}
@@ -193,8 +227,11 @@ String _get_class_name(JNIEnv * env, jclass cls, bool* array) {
jboolean isarr = env->CallBooleanMethod(cls, isArray);
(*array) = isarr ? true : false;
}
+ String name = env->GetStringUTFChars( clsName, NULL );
+ env->DeleteLocalRef(clsName);
+
+ return name;
- return env->GetStringUTFChars( clsName, NULL );
};
@@ -205,6 +242,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
String name = _get_class_name(env, c, &array);
//print_line("name is " + name + ", array "+Variant(array));
+ print_line("ARGNAME: "+name);
if (name == "java.lang.String") {
return String::utf8(env->GetStringUTFChars( (jstring)obj, NULL ));
@@ -222,6 +260,8 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
const char *rawString = env->GetStringUTFChars(string, 0);
sarr.push_back(String(rawString));
+ env->DeleteLocalRef(string);
+
}
return sarr;
@@ -320,30 +360,34 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
jobjectArray arr = (jobjectArray)obj;
int objCount = env->GetArrayLength(arr);
- Array varr;
+ Array varr(true);
for (int i=0; i<objCount; i++) {
jobject jobj = env->GetObjectArrayElement(arr, i);
Variant v = _jobject_to_variant(env, jobj);
varr.push_back(v);
+ env->DeleteLocalRef(jobj);
+
}
return varr;
};
- if (name == "com.android.godot.Dictionary") {
+ if (name == "java.util.HashMap" || name == "com.android.godot.Dictionary") {
- Dictionary ret;
+ Dictionary ret(true);
jclass oclass = c;
jmethodID get_keys = env->GetMethodID(oclass, "get_keys", "()[Ljava/lang/String;");
jobjectArray arr = (jobjectArray)env->CallObjectMethod(obj, get_keys);
StringArray keys = _jobject_to_variant(env, arr);
+ env->DeleteLocalRef(arr);
jmethodID get_values = env->GetMethodID(oclass, "get_values", "()[Ljava/lang/Object;");
arr = (jobjectArray)env->CallObjectMethod(obj, get_values);
Array vals = _jobject_to_variant(env, arr);
+ env->DeleteLocalRef(arr);
//print_line("adding " + String::num(keys.size()) + " to Dictionary!");
for (int i=0; i<keys.size(); i++) {
@@ -351,9 +395,12 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
ret[keys[i]] = vals[i];
};
+
return ret;
};
+ env->DeleteLocalRef(c);
+
return Variant();
};
@@ -391,6 +438,7 @@ public:
}
+
int ac = E->get().argtypes.size();
if (ac<p_argcount) {
@@ -409,7 +457,6 @@ public:
}
-
for(int i=0;i<p_argcount;i++) {
if (!Variant::can_convert(p_args[i]->get_type(),E->get().argtypes[i])) {
@@ -430,10 +477,18 @@ public:
JNIEnv *env = ThreadAndroid::get_env();
+ int res = env->PushLocalFrame(16);
+
+ ERR_FAIL_COND_V(res!=0,Variant());
+
//print_line("argcount "+String::num(p_argcount));
+ List<jobject> to_erase;
for(int i=0;i<p_argcount;i++) {
- v[i] = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
+ jvalret vr = _variant_to_jvalue(env, E->get().argtypes[i], p_args[i]);
+ v[i] = vr.val;
+ if (vr.obj)
+ to_erase.push_back(vr.obj);
}
//print_line("calling method!!");
@@ -467,6 +522,7 @@ public:
jobject o = env->CallObjectMethodA(instance,E->get().method,v);
String str = env->GetStringUTFChars((jstring)o, NULL );
ret=str;
+ env->DeleteLocalRef(o);
} break;
case Variant::STRING_ARRAY: {
@@ -474,6 +530,7 @@ public:
ret = _jobject_to_variant(env, arr);
+ env->DeleteLocalRef(arr);
} break;
case Variant::INT_ARRAY: {
@@ -487,6 +544,7 @@ public:
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
w = DVector<int>::Write();
ret=sarr;
+ env->DeleteLocalRef(arr);
} break;
case Variant::REAL_ARRAY: {
@@ -500,6 +558,7 @@ public:
env->GetFloatArrayRegion(arr,0,fCount,w.ptr());
w = DVector<float>::Write();
ret=sarr;
+ env->DeleteLocalRef(arr);
} break;
case Variant::DICTIONARY: {
@@ -507,16 +566,24 @@ public:
//print_line("call dictionary");
jobject obj = env->CallObjectMethodA(instance, E->get().method, v);
ret = _jobject_to_variant(env, obj);
+ env->DeleteLocalRef(obj);
} break;
default: {
print_line("failure..");
+ env->PopLocalFrame(NULL);
ERR_FAIL_V(Variant());
} break;
}
+ while (to_erase.size()) {
+ env->DeleteLocalRef(to_erase.front()->get());
+ to_erase.pop_front();
+ }
+
+ env->PopLocalFrame(NULL);
//print_line("success");
return ret;
@@ -698,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);
@@ -754,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);
}
@@ -821,10 +895,7 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env,
String vd = Globals::get_singleton()->get("display/driver");
- if (vd.to_upper()=="GLES1")
- env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean)false);
- else
- env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean)true);
+ env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean)true);
__android_log_print(ANDROID_LOG_INFO,"godot","**START");
@@ -874,6 +945,7 @@ static void _initialize_java_modules() {
String modules = Globals::get_singleton()->get("android/modules");
Vector<String> mods = modules.split(",",false);
+ print_line("ANDROID MODULES : " + modules);
__android_log_print(ANDROID_LOG_INFO,"godot","mod count: %i",mods.size());
if (mods.size()) {
@@ -1556,11 +1628,15 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_method(JNIEnv * env, jobj
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_callobject(JNIEnv * env, jobject p_obj, jint ID, jstring method, jobjectArray params) {
- String str_method = env->GetStringUTFChars( method, NULL );
-
Object* obj = ObjectDB::get_instance(ID);
ERR_FAIL_COND(!obj);
+ int res = env->PushLocalFrame(16);
+ ERR_FAIL_COND(res!=0);
+
+ String str_method = env->GetStringUTFChars( method, NULL );
+
+
int count = env->GetArrayLength(params);
Variant* vlist = (Variant*)alloca(sizeof(Variant) * count);
Variant** vptr = (Variant**)alloca(sizeof(Variant*) * count);
@@ -1573,30 +1649,41 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_callobject(JNIEnv * env,
memnew_placement(&vlist[i], Variant);
vlist[i] = v;
vptr[i] = &vlist[i];
+ env->DeleteLocalRef(obj);
+
};
Variant::CallError err;
obj->call(str_method, (const Variant**)vptr, count, err);
// something
+
+ env->PopLocalFrame(NULL);
+
};
JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_calldeferred(JNIEnv * env, jobject p_obj, jint ID, jstring method, jobjectArray params) {
- String str_method = env->GetStringUTFChars( method, NULL );
Object* obj = ObjectDB::get_instance(ID);
ERR_FAIL_COND(!obj);
+ int res = env->PushLocalFrame(16);
+ ERR_FAIL_COND(res!=0);
+
+ String str_method = env->GetStringUTFChars( method, NULL );
+
int count = env->GetArrayLength(params);
Variant args[VARIANT_ARG_MAX];
-// print_line("Java->GD call: "+obj->get_type()+"::"+str_method+" argc "+itos(count));
+ //print_line("Java->GD call: "+obj->get_type()+"::"+str_method+" argc "+itos(count));
for (int i=0; i<MIN(count,VARIANT_ARG_MAX); i++) {
jobject obj = env->GetObjectArrayElement(params, i);
if (obj)
args[i] = _jobject_to_variant(env, obj);
+ env->DeleteLocalRef(obj);
+
// print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type()));
};
@@ -1605,6 +1692,8 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_calldeferred(JNIEnv * env
obj->call_deferred(str_method, args[0],args[1],args[2],args[3],args[4]);
// something
+ env->PopLocalFrame(NULL);
+
};
//Main::cleanup();
diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h
index 379718a23e..9410fe7132 100644
--- a/platform/android/java_glue.h
+++ b/platform/android/java_glue.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -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/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java b/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java
deleted file mode 100644
index 77ebb4b780..0000000000
--- a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package com.android.vending.expansion.downloader;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-} \ No newline at end of file
diff --git a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java b/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java
deleted file mode 100644
index 330aed1856..0000000000
--- a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/R.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package com.android.vending.expansion.downloader;
-
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static int notify_panel_notification_icon_bg=0x7f020000;
- }
- public static final class id {
- public static int appIcon=0x7f060001;
- public static int description=0x7f060007;
- public static int notificationLayout=0x7f060000;
- public static int progress_bar=0x7f060006;
- public static int progress_bar_frame=0x7f060005;
- public static int progress_text=0x7f060002;
- public static int time_remaining=0x7f060004;
- public static int title=0x7f060003;
- }
- public static final class layout {
- public static int status_bar_ongoing_event_progress_bar=0x7f030000;
- }
- public static final class string {
- public static int kilobytes_per_second=0x7f040014;
- /** When a download completes, a notification is displayed, and this
- string is used to indicate that the download successfully completed.
- Note that such a download could have been initiated by a variety of
- applications, including (but not limited to) the browser, an email
- application, a content marketplace.
- */
- public static int notification_download_complete=0x7f040000;
- /** When a download completes, a notification is displayed, and this
- string is used to indicate that the download failed.
- Note that such a download could have been initiated by a variety of
- applications, including (but not limited to) the browser, an email
- application, a content marketplace.
- */
- public static int notification_download_failed=0x7f040001;
- public static int state_completed=0x7f040007;
- public static int state_connecting=0x7f040005;
- public static int state_downloading=0x7f040006;
- public static int state_failed=0x7f040013;
- public static int state_failed_cancelled=0x7f040012;
- public static int state_failed_fetching_url=0x7f040010;
- public static int state_failed_sdcard_full=0x7f040011;
- public static int state_failed_unlicensed=0x7f04000f;
- public static int state_fetching_url=0x7f040004;
- public static int state_idle=0x7f040003;
- public static int state_paused_by_request=0x7f04000a;
- public static int state_paused_network_setup_failure=0x7f040009;
- public static int state_paused_network_unavailable=0x7f040008;
- public static int state_paused_roaming=0x7f04000d;
- public static int state_paused_sdcard_unavailable=0x7f04000e;
- public static int state_paused_wifi_disabled=0x7f04000c;
- public static int state_paused_wifi_unavailable=0x7f04000b;
- public static int state_unknown=0x7f040002;
- public static int time_remaining=0x7f040015;
- public static int time_remaining_notification=0x7f040016;
- }
- public static final class style {
- public static int ButtonBackground=0x7f050003;
- public static int NotificationText=0x7f050000;
- public static int NotificationTextSecondary=0x7f050004;
- public static int NotificationTextShadow=0x7f050001;
- public static int NotificationTitle=0x7f050002;
- }
-}
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 833de059f7..e2ff128f0d 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "os_android.h"
#include "drivers/gles2/rasterizer_gles2.h"
-#include "drivers/gles1/rasterizer_gles1.h"
+
#include "core/io/file_access_buffered_fa.h"
#include "drivers/unix/file_access_unix.h"
#include "drivers/unix/dir_access_unix.h"
@@ -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
@@ -49,11 +51,11 @@
int OS_Android::get_video_driver_count() const {
- return 2;
+ return 1;
}
const char * OS_Android::get_video_driver_name(int p_driver) const {
- return p_driver==0?"GLES2":"GLES1";
+ return "GLES2";
}
OS::VideoMode OS_Android::get_default_video_mode() const {
@@ -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();
@@ -123,13 +131,13 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
AudioDriverManagerSW::add_driver(&audio_driver_android);
- if (use_gl2) {
+ if (true) {
RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) );
if (gl_extensions)
rasterizer_gles22->set_extensions(gl_extensions);
rasterizer = rasterizer_gles22;
} else {
- rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) );
+ //rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) );
}
@@ -151,7 +159,7 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
sample_manager = memnew( SampleManagerMallocSW );
audio_server = memnew( AudioServerSW(sample_manager) );
- audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,false);
+ audio_server->set_mixer_params(AudioMixerSW::INTERPOLATION_LINEAR,true);
audio_server->init();
spatial_sound_server = memnew( SpatialSoundServerSW );
@@ -163,7 +171,8 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
//
physics_server = memnew( PhysicsServerSW );
physics_server->init();
- physics_2d_server = memnew( Physics2DServerSW );
+ //physics_2d_server = memnew( Physics2DServerSW );
+ physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
input = memnew( InputDefault );
@@ -291,6 +300,11 @@ void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen)
p_list->push_back(default_videomode);
}
+Size2 OS_Android::get_window_size() const {
+
+ return Vector2(default_videomode.width,default_videomode.height);
+}
+
String OS_Android::get_name() {
return "Android";
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 26dbf4a509..dcaa1db654 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,11 @@
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "servers/audio/audio_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
+#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "servers/visual/rasterizer.h"
+#include "main/input_default.h"
+
+//#ifdef USE_JAVA_FILE_ACCESS
#ifdef ANDROID_NATIVE_ACTIVITY
@@ -170,6 +174,8 @@ public:
virtual VideoMode get_video_mode(int p_screen=0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
+ virtual Size2 get_window_size() const;
+
virtual String get_name();
virtual MainLoop *get_main_loop() const;
diff --git a/platform/android/platform_config.h b/platform/android/platform_config.h
index 38fc934ae4..1e7d066bb9 100644
--- a/platform/android/platform_config.h
+++ b/platform/android/platform_config.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/project.properties.template b/platform/android/project.properties.template
index d81b72b525..00cacd72bc 100644
--- a/platform/android/project.properties.template
+++ b/platform/android/project.properties.template
@@ -12,4 +12,4 @@
# Project target.
#android.library=true
-target=android-15
+target=android-19
diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp
index ec6bef89a0..9314a1c013 100644
--- a/platform/android/thread_jandroid.cpp
+++ b/platform/android/thread_jandroid.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/platform/android/thread_jandroid.h b/platform/android/thread_jandroid.h
index 38b4be01ec..051f4e2c3d 100644
--- a/platform/android/thread_jandroid.h
+++ b/platform/android/thread_jandroid.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */