summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/AndroidManifest.xml.template4
-rw-r--r--platform/android/SCsub32
-rw-r--r--platform/android/android_native_app_glue.h31
-rw-r--r--platform/android/audio_driver_jandroid.cpp12
-rw-r--r--platform/android/audio_driver_opensl.cpp6
-rw-r--r--platform/android/build.gradle.template47
-rw-r--r--platform/android/detect.py27
-rw-r--r--platform/android/dir_access_android.cpp5
-rw-r--r--platform/android/dir_access_jandroid.cpp3
-rw-r--r--platform/android/export/export.cpp427
-rw-r--r--platform/android/export/export.h30
-rw-r--r--platform/android/file_access_android.cpp5
-rw-r--r--platform/android/file_access_jandroid.cpp17
-rw-r--r--platform/android/globals/global_defaults.cpp29
-rw-r--r--platform/android/globals/global_defaults.h32
-rw-r--r--platform/android/godot_android.cpp55
-rw-r--r--platform/android/ifaddrs_android.cpp11
-rw-r--r--platform/android/java/gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--platform/android/java/res/drawable-hdpi/notify_panel_notification_icon_bg.pngbin1027 -> 715 bytes
-rw-r--r--platform/android/java/res/drawable-mdpi/notify_panel_notification_icon_bg.pngbin1125 -> 361 bytes
-rw-r--r--platform/android/java/res/drawable/icon.pngbin12574 -> 12675 bytes
-rw-r--r--platform/android/java/res/layout/downloading_expansion.xml2
-rw-r--r--platform/android/java/res/values-fa/strings.xml1
-rw-r--r--platform/android/java/res/values-in/strings.xml (renamed from platform/android/java/res/values-id/strings.xml)0
-rw-r--r--platform/android/java/res/values-iw/strings.xml (renamed from platform/android/java/res/values-he/strings.xml)0
-rw-r--r--platform/android/java/res/values-zh-rCN/strings.xml (renamed from platform/android/java/res/values-zh/strings.xml)2
-rw-r--r--platform/android/java/res/values-zh-rHK/strings.xml4
-rw-r--r--platform/android/java/res/values-zh-rTW/strings.xml4
-rw-r--r--platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl144
-rw-r--r--platform/android/java/src/com/android/vending/licensing/LicenseChecker.java6
-rw-r--r--platform/android/java/src/com/google/android/vending/expansion/downloader/Constants.java6
-rw-r--r--platform/android/java/src/com/google/android/vending/expansion/downloader/Helpers.java5
-rw-r--r--platform/android/java/src/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java2
-rw-r--r--platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java45
-rw-r--r--platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java10
-rw-r--r--platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V3CustomNotification.java116
-rw-r--r--platform/android/java/src/org/godotengine/godot/Dictionary.java2
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java38
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotIO.java6
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotLib.java2
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java200
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotEditText.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java363
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/Crypt.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java30
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java28
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/RequestParams.java28
-rw-r--r--platform/android/java_bind.cpp5
-rw-r--r--platform/android/java_bind.h10
-rw-r--r--platform/android/java_class_wrapper.cpp33
-rw-r--r--platform/android/java_class_wrapper.h28
-rw-r--r--platform/android/java_glue.cpp74
-rw-r--r--platform/android/java_glue.h4
-rw-r--r--platform/android/logo.pngbin1474 -> 1742 bytes
-rw-r--r--platform/android/os_android.cpp71
-rw-r--r--platform/android/os_android.h9
-rw-r--r--platform/android/thread_jandroid.cpp5
67 files changed, 1602 insertions, 792 deletions
diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template
index 37dee4a9a5..2a24c7cdc2 100644
--- a/platform/android/AndroidManifest.xml.template
+++ b/platform/android/AndroidManifest.xml.template
@@ -7,7 +7,7 @@
>
<supports-screens android:smallScreens="true"
android:normalScreens="true"
- android:largeScreens="false"
+ android:largeScreens="true"
android:xlargeScreens="true"/>
<application android:label="@string/godot_project_name_string" android:icon="@drawable/icon" android:allowBackup="false" $$ADD_APPATTRIBUTE_CHUNKS$$ >
@@ -200,6 +200,6 @@ $$ADD_PERMISSION_CHUNKS$$
<uses-permission android:name="godot.custom.18"/>
<uses-permission android:name="godot.custom.19"/>
-<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19"/>
+<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="23"/>
</manifest>
diff --git a/platform/android/SCsub b/platform/android/SCsub
index fab8458b26..60bb4bd613 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -65,20 +65,25 @@ for x in env.android_java_dirs:
gradle_res_dirs_text=""
for x in env.android_res_dirs:
- gradle_res_dirs_text+=",'"+x+"'"
+ gradle_res_dirs_text+=",'"+x.replace("\\","/")+"'"
gradle_aidl_dirs_text=""
for x in env.android_aidl_dirs:
- gradle_aidl_dirs_text+=",'"+x+"'"
+ gradle_aidl_dirs_text+=",'"+x.replace("\\","/")+"'"
gradle_jni_dirs_text=""
for x in env.android_jni_dirs:
- gradle_jni_dirs_text+=",'"+x+"'"
+ gradle_jni_dirs_text+=",'"+x.replace("\\","/")+"'"
gradle_asset_dirs_text=""
+gradle_default_config_text=""
+
+for x in env.android_default_config:
+ gradle_default_config_text+=x+"\n\t\t"
+
gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$",gradle_maven_repos_text)
gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$",gradle_maven_dependencies_text)
gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$",gradle_java_dirs_text)
@@ -86,6 +91,7 @@ gradle_text = gradle_text.replace("$$GRADLE_RES_DIRS$$",gradle_res_dirs_text)
gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$",gradle_asset_dirs_text)
gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$",gradle_aidl_dirs_text)
gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$",gradle_jni_dirs_text)
+gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$",gradle_default_config_text)
gradle_baseout.write( gradle_text )
@@ -103,4 +109,22 @@ pp_baseout.write( manifest )
env_android.SharedLibrary("#bin/libgodot",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"])
-#env.Command('#bin/libgodot_android.so', '#platform/android/libgodot_android.so', Copy('bin/libgodot_android.so', 'platform/android/libgodot_android.so'))
+
+lib_arch_dir = ''
+if env['android_arch'] == 'armv6':
+ lib_arch_dir = 'armeabi'
+elif env['android_arch'] == 'armv7':
+ lib_arch_dir = 'armeabi-v7a'
+elif env['android_arch'] == 'x86':
+ lib_arch_dir = 'x86'
+else:
+ print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin'
+
+if lib_arch_dir != '':
+ if env['target'] == 'release':
+ lib_type_dir = 'release'
+ else: # release_debug, debug
+ lib_type_dir = 'debug'
+
+ out_dir = '#platform/android/java/libs/'+lib_type_dir+'/'+lib_arch_dir
+ env_android.Command(out_dir+'/libgodot_android.so', '#bin/libgodot'+env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE"))
diff --git a/platform/android/android_native_app_glue.h b/platform/android/android_native_app_glue.h
index 3e7a4ea7a0..36278d4c66 100644
--- a/platform/android/android_native_app_glue.h
+++ b/platform/android/android_native_app_glue.h
@@ -1,32 +1,5 @@
-/*************************************************************************/
-/* android_native_app_glue.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 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 */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* 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 6d428e3fe5..419ed977b5 100644
--- a/platform/android/audio_driver_jandroid.cpp
+++ b/platform/android/audio_driver_jandroid.cpp
@@ -192,29 +192,31 @@ void AudioDriverAndroid::thread_func(JNIEnv *env) {
env->CallVoidMethod(gob, _write_buffer, (jshortArray)audioBuffer);
}
-
-
}
int AudioDriverAndroid::get_mix_rate() const {
return mix_rate;
}
+
AudioDriverSW::OutputFormat AudioDriverAndroid::get_output_format() const{
return OUTPUT_STEREO;
}
+
void AudioDriverAndroid::lock(){
if (mutex)
mutex->lock();
}
+
void AudioDriverAndroid::unlock() {
if (mutex)
mutex->unlock();
}
+
void AudioDriverAndroid::finish(){
JNIEnv *env = ThreadAndroid::get_env();
@@ -236,13 +238,11 @@ void AudioDriverAndroid::set_pause(bool p_pause) {
}
-AudioDriverAndroid::AudioDriverAndroid()
-{
+AudioDriverAndroid::AudioDriverAndroid() {
+
s_ad=this;
active=false;
-
-
}
#endif
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index a908f6193e..b7ef1424e5 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -207,6 +207,7 @@ Error AudioDriverOpenSL::init(){
return OK;
}
+
void AudioDriverOpenSL::start(){
@@ -366,26 +367,31 @@ void AudioDriverOpenSL::start(){
active=true;
}
+
int AudioDriverOpenSL::get_mix_rate() const {
return 44100;
}
+
AudioDriverSW::OutputFormat AudioDriverOpenSL::get_output_format() const{
return OUTPUT_STEREO;
}
+
void AudioDriverOpenSL::lock(){
if (active && mutex)
mutex->lock();
}
+
void AudioDriverOpenSL::unlock() {
if (active && mutex)
mutex->unlock();
}
+
void AudioDriverOpenSL::finish(){
(*sl)->Destroy(sl);
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index 9461cd2e99..24951b921b 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.2.0'
+ classpath 'com.android.tools.build:gradle:2.1.0'
}
}
@@ -17,18 +17,20 @@ allprojects {
}
dependencies {
-
- $$GRADLE_DEPENDENCIES$$
+ compile 'com.android.support:support-v4:23.+' // can be removed if minSdkVersion 16 and modify DownloadNotification.java & V14CustomNotification.java
+ $$GRADLE_DEPENDENCIES$$
}
android {
lintOptions {
abortOnError false
+ disable 'MissingTranslation'
}
- compileSdkVersion 19
- buildToolsVersion "19.1"
+ compileSdkVersion 23
+ buildToolsVersion "23.0.3"
+ useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/LICENSE'
@@ -36,35 +38,50 @@ android {
}
defaultConfig {
minSdkVersion 14
- targetSdkVersion 19
+ targetSdkVersion 23
+ $$GRADLE_DEFAULT_CONFIG$$
+ }
+ // Both signing and zip-aligning will be done at export time
+ buildTypes.all { buildType ->
+ buildType.zipAlignEnabled false
+ buildType.signingConfig null
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src'
- $$GRADLE_JAVA_DIRS$$
+ $$GRADLE_JAVA_DIRS$$
]
resources.srcDirs = [
'res'
- $$GRADLE_RES_DIRS$$
+ $$GRADLE_RES_DIRS$$
]
res.srcDirs = ['res']
// libs.srcDirs = ['libs']
aidl.srcDirs = [
'aidl'
- $$GRADLE_AIDL_DIRS$$
+ $$GRADLE_AIDL_DIRS$$
]
assets.srcDirs = [
'assets'
- $$GRADLE_ASSET_DIRS$$
+ $$GRADLE_ASSET_DIRS$$
]
jniLibs.srcDirs = [
'libs'
- $$GRADLE_JNI_DIRS$$
- ]
+ $$GRADLE_JNI_DIRS$$
+ ]
}
-
+ debug.jniLibs.srcDirs = [
+ 'libs/debug'
+ $$GRADLE_JNI_DIRS$$
+ ]
+ release.jniLibs.srcDirs = [
+ 'libs/release'
+ $$GRADLE_JNI_DIRS$$
+ ]
+ }
+ applicationVariants.all { variant ->
+ // ApplicationVariant is undocumented, but this method is widely used; may break with another version of the Android Gradle plugin
+ variant.outputs.get(0).setOutputFile(new File("${projectDir}/../../../bin", "android_${variant.name}.apk"))
}
-
-
}
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 366ec6321d..49ffc86658 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -21,10 +21,9 @@ 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"),
('NDK_TARGET', 'toolchain to use for the NDK',os.environ.get("NDK_TARGET", "arm-linux-androideabi-4.9")),
('NDK_TARGET_X86', 'toolchain to use for the NDK x86',os.environ.get("NDK_TARGET_X86", "x86-4.9")),
- ('ndk_platform', 'compile for platform: (android-<api> , example: android-15)',"android-15"),
+ ('ndk_platform', 'compile for platform: (android-<api> , example: android-14)',"android-14"),
('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")
@@ -102,9 +101,7 @@ def configure(env):
env["x86_opt_gcc"]=True
if env['PLATFORM'] == 'win32':
- import methods
env.Tool('gcc')
- #env['SPAWN'] = methods.win32_spawn
env['SHLIBSUFFIX'] = '.so'
@@ -127,7 +124,6 @@ def configure(env):
gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/";
- import os
if (sys.platform.find("linux")==0):
if (platform.architecture()[0]=='64bit' or os.path.isdir(gcc_path+"linux-x86_64/bin")): # check was not working
gcc_path=gcc_path+"/linux-x86_64/bin"
@@ -136,6 +132,7 @@ def configure(env):
elif (sys.platform=="darwin"):
gcc_path=gcc_path+"/darwin-x86_64/bin" #this may be wrong
env['SHLINKFLAGS'][1] = '-shared'
+ env['SHLIBSUFFIX'] = '.so'
elif (os.name=="nt"):
gcc_path=gcc_path+"/windows-x86_64/bin" #this may be wrong
@@ -171,11 +168,11 @@ def configure(env):
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')
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -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')
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -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')
+ env['CCFLAGS'] = string.split('-DNO_STATVFS -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__'])
@@ -214,16 +211,16 @@ def configure(env):
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.8/include"])
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/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"])
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/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"])
+ env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/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(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include"])
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a"])
env.Append(LIBS=["gnustl_static","supc++"])
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp
index 85df5dc37a..79ba83b3ee 100644
--- a/platform/android/dir_access_android.cpp
+++ b/platform/android/dir_access_android.cpp
@@ -61,6 +61,7 @@ String DirAccessAndroid::get_next(){
}
+
bool DirAccessAndroid::current_is_dir() const{
String sd;
@@ -79,9 +80,11 @@ 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)
@@ -96,6 +99,7 @@ int DirAccessAndroid::get_drive_count(){
return 0;
}
+
String DirAccessAndroid::get_drive(int p_drive){
return "";
@@ -164,6 +168,7 @@ Error DirAccessAndroid::rename(String p_from, String p_to){
ERR_FAIL_V(ERR_UNAVAILABLE);
}
+
Error DirAccessAndroid::remove(String p_name){
ERR_FAIL_V(ERR_UNAVAILABLE);
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index 8b7cb992d9..be2ffde2cd 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -76,6 +76,7 @@ String DirAccessJAndroid::get_next(){
return ret;
}
+
bool DirAccessJAndroid::current_is_dir() const{
@@ -106,6 +107,7 @@ int DirAccessJAndroid::get_drive_count(){
return 0;
}
+
String DirAccessJAndroid::get_drive(int p_drive){
return "";
@@ -215,6 +217,7 @@ Error DirAccessJAndroid::rename(String p_from, String p_to){
ERR_FAIL_V(ERR_UNAVAILABLE);
}
+
Error DirAccessJAndroid::remove(String p_name){
ERR_FAIL_V(ERR_UNAVAILABLE);
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 60f4e61c68..10d77aba6c 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* export.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "version.h"
#include "export.h"
#include "tools/editor/editor_settings.h"
@@ -9,6 +37,7 @@
#include "os/file_access.h"
#include "os/os.h"
#include "platform/android/logo.h"
+#include <string.h>
static const char* android_perms[]={
@@ -231,6 +260,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
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);
+ static bool _should_compress_asset(const String& p_path, const Vector<uint8_t>& p_data);
protected:
@@ -251,7 +281,7 @@ public:
virtual String get_device_info(int p_device) const;
virtual Error run(int p_device,int p_flags=0);
- virtual bool requieres_password(bool p_debug) const { return !p_debug; }
+ virtual bool requires_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, int p_flags=0);
@@ -792,40 +822,6 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
}*/
}
- 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 (but you can ignore this).")
- } else {
-
- String aname = get_project_name();
- string_table[attr_value]=aname;
- }
- }
- if (tname=="activity" && /*nspace=="android" &&*/ attrname=="label") {
-
- print_line("FOUND activity name");
- if (attr_value==0xFFFFFFFF) {
- WARN_PRINT("Activity name in a resource, should be plaintext (but you can ignore this)")
- } else {
- String aname;
- if (this->name!="") {
- aname=this->name;
- } else {
- aname = Globals::get_singleton()->get("application/name");
-
- }
-
- if (aname=="") {
- aname=_MKSTR(VERSION_NAME);
- }
-
- print_line("APP NAME IS..."+aname);
- string_table[attr_value]=aname;
- }
- }
-
if (tname=="uses-permission" && /*nspace=="android" &&*/ attrname=="name") {
if (value.begins_with("godot.custom")) {
@@ -850,13 +846,11 @@ void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool
if (tname=="supports-screens" ) {
- if (attr_value==0xFFFFFFFF) {
- WARN_PRINT("Screen res name in a resource, should be plaintext")
- } else if (attrname=="smallScreens") {
+ if (attrname=="smallScreens") {
encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
- } else if (attrname=="mediumScreens") {
+ } else if (attrname=="normalScreens") {
encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]);
@@ -1001,7 +995,7 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String&
NULL,
0,
NULL,
- Z_DEFLATED,
+ _should_compress_asset(p_path,p_data) ? Z_DEFLATED : 0,
Z_DEFAULT_COMPRESSION);
@@ -1012,13 +1006,58 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String&
}
+bool EditorExportPlatformAndroid::_should_compress_asset(const String& p_path, const Vector<uint8_t>& p_data) {
+
+ /*
+ * By not compressing files with little or not benefit in doing so,
+ * a performance gain is expected at runtime. Moreover, if the APK is
+ * zip-aligned, assets stored as they are can be efficiently read by
+ * Android by memory-mapping them.
+ */
+
+ // -- Unconditional uncompress to mimic AAPT plus some other
+
+ static const char* unconditional_compress_ext[] = {
+ // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp
+ // These formats are already compressed, or don't compress well:
+ ".jpg", ".jpeg", ".png", ".gif",
+ ".wav", ".mp2", ".mp3", ".ogg", ".aac",
+ ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
+ ".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
+ ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
+ ".amr", ".awb", ".wma", ".wmv",
+ // Godot-specific:
+ ".webp", // Same reasoning as .png
+ ".cfb", // Don't let small config files slow-down startup
+ // Trailer for easier processing
+ NULL
+ };
+
+ for (const char** ext=unconditional_compress_ext; *ext; ++ext) {
+ if (p_path.to_lower().ends_with(String(*ext))) {
+ return false;
+ }
+ }
+
+ // -- Compressed resource?
+
+ if (p_data.size() >= 4 && p_data[0]=='R' && p_data[1]=='S' && p_data[2]=='C' && p_data[3]=='C') {
+ // Already compressed
+ return false;
+ }
+
+ // --- TODO: Decide on texture resources according to their image compression setting
+
+ return true;
+}
+
Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_debug, int p_flags) {
String src_apk;
- EditorProgress ep("export","Exporting for Android",104);
+ EditorProgress ep("export","Exporting for Android",105);
if (p_debug)
src_apk=custom_debug_package;
@@ -1058,7 +1097,8 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
zlib_filefunc_def io2=io;
FileAccess *dst_f=NULL;
io2.opaque=&dst_f;
- zipFile apk=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2);
+ String unaligned_path=EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmpexport-unaligned.apk";
+ zipFile unaligned_apk=zipOpen2(unaligned_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2);
while(ret==UNZ_OK) {
@@ -1126,7 +1166,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
skip=true;
}
- if (file=="lib/armeabi/libgodot_android.so" && !export_arm) {
+ if (file.match("lib/armeabi*/libgodot_android.so") && !export_arm) {
skip=true;
}
@@ -1137,7 +1177,11 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
print_line("ADDING: "+file);
if (!skip) {
- zipOpenNewFileInZip(apk,
+
+ // Respect decision on compression made by AAPT for the export template
+ const bool uncompressed = info.compression_method == 0;
+
+ zipOpenNewFileInZip(unaligned_apk,
file.utf8().get_data(),
NULL,
NULL,
@@ -1145,11 +1189,11 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
NULL,
0,
NULL,
- Z_DEFLATED,
+ uncompressed ? 0 : Z_DEFLATED,
Z_DEFAULT_COMPRESSION);
- zipWriteInFileInZip(apk,data.ptr(),data.size());
- zipCloseFileInZip(apk);
+ zipWriteInFileInZip(unaligned_apk,data.ptr(),data.size());
+ zipCloseFileInZip(unaligned_apk);
}
ret = unzGoToNextFile(pkg);
@@ -1206,7 +1250,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
APKExportData ed;
ed.ep=&ep;
- ed.apk=apk;
+ ed.apk=unaligned_apk;
err = export_project_files(save_apk_file,&ed,false);
}
@@ -1235,7 +1279,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
print_line(itos(i)+" param: "+cl[i]);
}
- zipOpenNewFileInZip(apk,
+ zipOpenNewFileInZip(unaligned_apk,
"assets/_cl_",
NULL,
NULL,
@@ -1243,15 +1287,15 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
NULL,
0,
NULL,
- Z_DEFLATED,
+ 0, // No compress (little size gain and potentially slower startup)
Z_DEFAULT_COMPRESSION);
- zipWriteInFileInZip(apk,clf.ptr(),clf.size());
- zipCloseFileInZip(apk);
+ zipWriteInFileInZip(unaligned_apk,clf.ptr(),clf.size());
+ zipCloseFileInZip(unaligned_apk);
}
- zipClose(apk,NULL);
+ zipClose(unaligned_apk,NULL);
unzClose(pkg);
if (err) {
@@ -1308,7 +1352,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
args.push_back(keystore);
args.push_back("-storepass");
args.push_back(password);
- args.push_back(p_path);
+ args.push_back(unaligned_path);
args.push_back(user);
int retval;
int err = OS::get_singleton()->execute(jarsigner,args,true,NULL,NULL,&retval);
@@ -1321,16 +1365,102 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
args.clear();
args.push_back("-verify");
- args.push_back(p_path);
+ args.push_back(unaligned_path);
args.push_back("-verbose");
err = OS::get_singleton()->execute(jarsigner,args,true,NULL,NULL,&retval);
if (retval) {
- EditorNode::add_io_error("'jarsigner' verificaiton of APK failed. Make sure to use jarsigner from Java 6.");
+ EditorNode::add_io_error("'jarsigner' verification of APK failed. Make sure to use jarsigner from Java 6.");
return ERR_CANT_CREATE;
}
}
+
+
+
+ // Let's zip-align (must be done after signing)
+
+ static const int ZIP_ALIGNMENT = 4;
+
+ ep.step("Aligning APK..",105);
+
+ unzFile tmp_unaligned = unzOpen2(unaligned_path.utf8().get_data(), &io);
+ if (!tmp_unaligned) {
+
+ EditorNode::add_io_error("Could not find temp unaligned APK.");
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ ERR_FAIL_COND_V(!tmp_unaligned, ERR_CANT_OPEN);
+ ret = unzGoToFirstFile(tmp_unaligned);
+
+ io2=io;
+ dst_f=NULL;
+ io2.opaque=&dst_f;
+ zipFile final_apk=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2);
+
+ // Take files from the unaligned APK and write them out to the aligned one
+ // in raw mode, i.e. not uncompressing and recompressing, aligning them as needed,
+ // following what is done in https://github.com/android/platform_build/blob/master/tools/zipalign/ZipAlign.cpp
+ int bias = 0;
+ while(ret==UNZ_OK) {
+
+ unz_file_info info;
+ memset(&info, 0, sizeof(info));
+
+ char fname[16384];
+ char extra[16384];
+ ret = unzGetCurrentFileInfo(tmp_unaligned,&info,fname,16384,extra,16384-ZIP_ALIGNMENT,NULL,0);
+
+ String file=fname;
+
+ Vector<uint8_t> data;
+ data.resize(info.compressed_size);
+
+ // read
+ int method, level;
+ unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read
+ long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned);
+ unzReadCurrentFile(tmp_unaligned,data.ptr(),data.size());
+ unzCloseCurrentFile(tmp_unaligned);
+
+ // align
+ int padding = 0;
+ if (!info.compression_method) {
+ // Uncompressed file => Align
+ long new_offset = file_offset + bias;
+ padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT;
+ }
+
+ memset(extra + info.size_file_extra, 0, padding);
+
+ // write
+ zipOpenNewFileInZip2(final_apk,
+ file.utf8().get_data(),
+ NULL,
+ extra,
+ info.size_file_extra + padding,
+ NULL,
+ 0,
+ NULL,
+ method,
+ level,
+ 1); // raw write
+ zipWriteInFileInZip(final_apk,data.ptr(),data.size());
+ zipCloseFileInZipRaw(final_apk,info.uncompressed_size,info.crc);
+
+ bias += padding;
+
+ ret = unzGoToNextFile(tmp_unaligned);
+ }
+
+ zipClose(final_apk,NULL);
+ unzClose(tmp_unaligned);
+
+ if (err) {
+ return err;
+ }
+
return OK;
}
@@ -1352,6 +1482,7 @@ int EditorExportPlatformAndroid::get_device_count() const {
return dc;
}
+
String EditorExportPlatformAndroid::get_device_name(int p_device) const {
ERR_FAIL_INDEX_V(p_device,devices.size(),"");
@@ -1360,6 +1491,7 @@ String EditorExportPlatformAndroid::get_device_name(int p_device) const {
device_lock->unlock();
return s;
}
+
String EditorExportPlatformAndroid::get_device_info(int p_device) const {
ERR_FAIL_INDEX_V(p_device,devices.size(),"");
@@ -1377,120 +1509,125 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
while(!ea->quit_request) {
String adb=EditorSettings::get_singleton()->get("android/adb");
- if (!FileAccess::exists(adb)) {
- OS::get_singleton()->delay_usec(3000000);
- continue; //adb not configured
- }
-
- String devices;
- List<String> args;
- args.push_back("devices");
- int ec;
- Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec);
- Vector<String> ds = devices.split("\n");
- Vector<String> ldevices;
- for(int i=1;i<ds.size();i++) {
-
- String d = ds[i];
- int dpos = d.find("device");
- if (dpos==-1)
- continue;
- d=d.substr(0,dpos).strip_edges();
-// print_line("found devuce: "+d);
- ldevices.push_back(d);
- }
+ if (FileAccess::exists(adb)) {
+
+ String devices;
+ List<String> args;
+ args.push_back("devices");
+ int ec;
+ Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec);
+ Vector<String> ds = devices.split("\n");
+ Vector<String> ldevices;
+ for(int i=1;i<ds.size();i++) {
+
+ String d = ds[i];
+ int dpos = d.find("device");
+ if (dpos==-1)
+ continue;
+ d=d.substr(0,dpos).strip_edges();
+ // print_line("found devuce: "+d);
+ ldevices.push_back(d);
+ }
- ea->device_lock->lock();
+ ea->device_lock->lock();
- bool different=false;
+ bool different=false;
- if (devices.size()!=ldevices.size()) {
+ if (devices.size()!=ldevices.size()) {
- different=true;
- } else {
+ different=true;
+ } else {
- for(int i=0;i<ea->devices.size();i++) {
+ for(int i=0;i<ea->devices.size();i++) {
- if (ea->devices[i].id!=ldevices[i]) {
- different=true;
- break;
+ if (ea->devices[i].id!=ldevices[i]) {
+ different=true;
+ break;
+ }
}
}
- }
- if (different) {
+ if (different) {
- Vector<Device> ndevices;
+ Vector<Device> ndevices;
- for(int i=0;i<ldevices.size();i++) {
+ for(int i=0;i<ldevices.size();i++) {
- Device d;
- d.id=ldevices[i];
- for(int j=0;j<ea->devices.size();j++) {
- if (ea->devices[j].id==ldevices[i]) {
- d.description=ea->devices[j].description;
- d.name=ea->devices[j].name;
+ Device d;
+ d.id=ldevices[i];
+ for(int j=0;j<ea->devices.size();j++) {
+ if (ea->devices[j].id==ldevices[i]) {
+ d.description=ea->devices[j].description;
+ d.name=ea->devices[j].name;
+ }
}
- }
- if (d.description=="") {
- //in the oven, request!
- args.clear();
- args.push_back("-s");
- args.push_back(d.id);
- args.push_back("shell");
- args.push_back("cat");
- args.push_back("/system/build.prop");
- int ec;
- String dp;
-
- Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec);
- print_line("RV: "+itos(ec));
- Vector<String> props = dp.split("\n");
- String vendor;
- String device;
- d.description+"Device ID: "+d.id+"\n";
- for(int j=0;j<props.size();j++) {
-
- String p = props[j];
- if (p.begins_with("ro.product.model=")) {
- device=p.get_slice("=",1).strip_edges();
- } else if (p.begins_with("ro.product.brand=")) {
- vendor=p.get_slice("=",1).strip_edges().capitalize();
- } else if (p.begins_with("ro.build.display.id=")) {
- d.description+="Build: "+p.get_slice("=",1).strip_edges()+"\n";
- } else if (p.begins_with("ro.build.version.release=")) {
- d.description+="Release: "+p.get_slice("=",1).strip_edges()+"\n";
- } else if (p.begins_with("ro.product.cpu.abi=")) {
- d.description+="CPU: "+p.get_slice("=",1).strip_edges()+"\n";
- } else if (p.begins_with("ro.product.manufacturer=")) {
- d.description+="Manufacturer: "+p.get_slice("=",1).strip_edges()+"\n";
- } else if (p.begins_with("ro.board.platform=")) {
- d.description+="Chipset: "+p.get_slice("=",1).strip_edges()+"\n";
- } else if (p.begins_with("ro.opengles.version=")) {
- uint32_t opengl = p.get_slice("=",1).to_int();
- d.description+="OpenGL: "+itos(opengl>>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n";
+ if (d.description=="") {
+ //in the oven, request!
+ args.clear();
+ args.push_back("-s");
+ args.push_back(d.id);
+ args.push_back("shell");
+ args.push_back("cat");
+ args.push_back("/system/build.prop");
+ int ec;
+ String dp;
+
+ Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec);
+
+ Vector<String> props = dp.split("\n");
+ String vendor;
+ String device;
+ d.description+"Device ID: "+d.id+"\n";
+ for(int j=0;j<props.size();j++) {
+
+ String p = props[j];
+ if (p.begins_with("ro.product.model=")) {
+ device=p.get_slice("=",1).strip_edges();
+ } else if (p.begins_with("ro.product.brand=")) {
+ vendor=p.get_slice("=",1).strip_edges().capitalize();
+ } else if (p.begins_with("ro.build.display.id=")) {
+ d.description+="Build: "+p.get_slice("=",1).strip_edges()+"\n";
+ } else if (p.begins_with("ro.build.version.release=")) {
+ d.description+="Release: "+p.get_slice("=",1).strip_edges()+"\n";
+ } else if (p.begins_with("ro.product.cpu.abi=")) {
+ d.description+="CPU: "+p.get_slice("=",1).strip_edges()+"\n";
+ } else if (p.begins_with("ro.product.manufacturer=")) {
+ d.description+="Manufacturer: "+p.get_slice("=",1).strip_edges()+"\n";
+ } else if (p.begins_with("ro.board.platform=")) {
+ d.description+="Chipset: "+p.get_slice("=",1).strip_edges()+"\n";
+ } else if (p.begins_with("ro.opengles.version=")) {
+ uint32_t opengl = p.get_slice("=",1).to_int();
+ d.description+="OpenGL: "+itos(opengl>>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n";
+ }
}
+
+ d.name=vendor+" "+device;
+ // print_line("name: "+d.name);
+ // print_line("description: "+d.description);
+
}
- d.name=vendor+" "+device;
-// print_line("name: "+d.name);
-// print_line("description: "+d.description);
+ ndevices.push_back(d);
}
- ndevices.push_back(d);
-
+ ea->devices=ndevices;
+ ea->devices_changed=true;
}
- ea->devices=ndevices;
- ea->devices_changed=true;
+ ea->device_lock->unlock();
}
- ea->device_lock->unlock();
+ uint64_t wait = 3000000;
+ uint64_t time = OS::get_singleton()->get_ticks_usec();
+ while(OS::get_singleton()->get_ticks_usec() - time < wait ) {
+ OS::get_singleton()->delay_usec(1000);
+ if (ea->quit_request)
+ break;
+ }
- OS::get_singleton()->delay_usec(3000000);
}
if (EditorSettings::get_singleton()->get("android/shutdown_adb_on_exit")) {
@@ -1748,7 +1885,6 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const {
EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
-
quit_request=true;
Thread::wait_to_finish(device_thread);
memdelete(device_lock);
@@ -1777,6 +1913,5 @@ void register_android_exporter() {
Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>( memnew(EditorExportPlatformAndroid) );
EditorImportExport::get_singleton()->add_export_platform(exporter);
-
}
diff --git a/platform/android/export/export.h b/platform/android/export/export.h
index 88581802b8..a9421e692e 100644
--- a/platform/android/export/export.h
+++ b/platform/android/export/export.h
@@ -1,3 +1,29 @@
-
-
+/*************************************************************************/
+/* export.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
void register_android_exporter();
diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp
index 334d32de0c..aefa16ca9c 100644
--- a/platform/android/file_access_android.cpp
+++ b/platform/android/file_access_android.cpp
@@ -74,6 +74,7 @@ void FileAccessAndroid::close() {
AAsset_close(a);
a=NULL;
}
+
bool FileAccessAndroid::is_open() const {
return a!=NULL;
@@ -92,6 +93,7 @@ void FileAccessAndroid::seek(size_t p_position) {
}
}
+
void FileAccessAndroid::seek_end(int64_t p_position) {
ERR_FAIL_COND(!a);
@@ -99,10 +101,12 @@ void FileAccessAndroid::seek_end(int64_t p_position) {
pos=len+p_position;
}
+
size_t FileAccessAndroid::get_pos() const {
return pos;
}
+
size_t FileAccessAndroid::get_len() const {
return len;
@@ -128,6 +132,7 @@ uint8_t FileAccessAndroid::get_8() const {
return byte;
}
+
int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
index da8ceaff14..3d2e525bbc 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -90,6 +90,7 @@ void FileAccessJAndroid::close() {
id=0;
}
+
bool FileAccessJAndroid::is_open() const {
return id!=0;
@@ -102,6 +103,7 @@ void FileAccessJAndroid::seek(size_t p_position) {
ERR_FAIL_COND(!is_open());
env->CallVoidMethod(io,_file_seek,id,p_position);
}
+
void FileAccessJAndroid::seek_end(int64_t p_position) {
ERR_FAIL_COND(!is_open());
@@ -109,6 +111,7 @@ void FileAccessJAndroid::seek_end(int64_t p_position) {
seek(get_len());
}
+
size_t FileAccessJAndroid::get_pos() const {
JNIEnv *env = ThreadAndroid::get_env();
@@ -116,13 +119,13 @@ size_t FileAccessJAndroid::get_pos() const {
return env->CallIntMethod(io,_file_tell,id);
}
+
size_t FileAccessJAndroid::get_len() const {
JNIEnv *env = ThreadAndroid::get_env();
ERR_FAIL_COND_V(!is_open(),0);
return env->CallIntMethod(io,_file_get_size,id);
-
}
bool FileAccessJAndroid::eof_reached() const {
@@ -167,7 +170,6 @@ Error FileAccessJAndroid::get_error() const {
void FileAccessJAndroid::store_8(uint8_t p_dest) {
-
}
bool FileAccessJAndroid::file_exists(const String& p_path) {
@@ -182,8 +184,10 @@ bool FileAccessJAndroid::file_exists(const String& p_path) {
jstring js = env->NewStringUTF(path.utf8().get_data());
int res = env->CallIntMethod(io,_file_open,js,false);
- if (res<=0)
+ if (res<=0) {
+ env->DeleteLocalRef(js);
return false;
+ }
env->CallVoidMethod(io,_file_close,res);
env->DeleteLocalRef(js);
return true;
@@ -193,7 +197,6 @@ bool FileAccessJAndroid::file_exists(const String& p_path) {
void FileAccessJAndroid::setup( jobject p_io) {
-
io=p_io;
JNIEnv *env = ThreadAndroid::get_env();
@@ -237,14 +240,12 @@ void FileAccessJAndroid::setup( jobject p_io) {
}
-FileAccessJAndroid::FileAccessJAndroid()
-{
+FileAccessJAndroid::FileAccessJAndroid() {
id=0;
}
-FileAccessJAndroid::~FileAccessJAndroid()
-{
+FileAccessJAndroid::~FileAccessJAndroid() {
if (is_open())
close();
diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp
index 824a4e3606..9a4252bde0 100644
--- a/platform/android/globals/global_defaults.cpp
+++ b/platform/android/globals/global_defaults.cpp
@@ -1,4 +1,31 @@
-
+/*************************************************************************/
+/* global_defaults.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "global_defaults.h"
#include "globals.h"
diff --git a/platform/android/globals/global_defaults.h b/platform/android/globals/global_defaults.h
index 64eb26c482..6f240572d8 100644
--- a/platform/android/globals/global_defaults.h
+++ b/platform/android/globals/global_defaults.h
@@ -1,3 +1,29 @@
-
-
-void register_android_global_defaults(); \ No newline at end of file
+/*************************************************************************/
+/* global_defaults.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+void register_android_global_defaults();
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index f9feb3481f..2371274d9d 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -313,6 +313,8 @@ struct engine {
ASensorManager* sensorManager;
const ASensor* accelerometerSensor;
+ const ASensor* magnetometerSensor;
+ const ASensor* gyroscopeSensor;
ASensorEventQueue* sensorEventQueue;
bool display_active;
@@ -736,15 +738,41 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
engine->accelerometerSensor, (1000L/60)*1000);
}
+ // Also start monitoring the magnetometer.
+ if (engine->magnetometerSensor != NULL) {
+ ASensorEventQueue_enableSensor(engine->sensorEventQueue,
+ engine->magnetometerSensor);
+ // We'd like to get 60 events per second (in us).
+ ASensorEventQueue_setEventRate(engine->sensorEventQueue,
+ engine->magnetometerSensor, (1000L/60)*1000);
+
+ }
+ // And the gyroscope.
+ if (engine->gyroscopeSensor != NULL) {
+ ASensorEventQueue_enableSensor(engine->sensorEventQueue,
+ engine->gyroscopeSensor);
+ // We'd like to get 60 events per second (in us).
+ ASensorEventQueue_setEventRate(engine->sensorEventQueue,
+ engine->gyroscopeSensor, (1000L/60)*1000);
+
+ }
engine->animating = 1;
break;
case APP_CMD_LOST_FOCUS:
- // When our app loses focus, we stop monitoring the accelerometer.
+ // When our app loses focus, we stop monitoring the sensors.
// This is to avoid consuming battery while not being used.
if (engine->accelerometerSensor != NULL) {
ASensorEventQueue_disableSensor(engine->sensorEventQueue,
engine->accelerometerSensor);
}
+ if (engine->magnetometerSensor != NULL) {
+ ASensorEventQueue_disableSensor(engine->sensorEventQueue,
+ engine->magnetometerSensor);
+ }
+ if (engine->gyroscopeSensor != NULL) {
+ ASensorEventQueue_disableSensor(engine->sensorEventQueue,
+ engine->gyroscopeSensor);
+ }
// Also stop animating.
engine->animating = 0;
engine_draw_frame(engine);
@@ -768,10 +796,14 @@ void android_main(struct android_app* state) {
FileAccessAndroid::asset_manager=state->activity->assetManager;
- // Prepare to monitor accelerometer
+ // Prepare to monitor sensors
engine.sensorManager = ASensorManager_getInstance();
engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
- ASENSOR_TYPE_ACCELEROMETER);
+ ASENSOR_TYPE_ACCELEROMETER);
+ engine.magnetometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
+ ASENSOR_TYPE_MAGNETIC_FIELD);
+ engine.gyroscopeSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
+ ASENSOR_TYPE_GYROSCOPE);
engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager,
state->looper, LOOPER_ID_USER, NULL, NULL);
@@ -812,16 +844,25 @@ void android_main(struct android_app* state) {
// If a sensor has data, process it now.
// LOGI("events\n");
if (ident == LOOPER_ID_USER) {
- if (engine.accelerometerSensor != NULL) {
+ if (engine.accelerometerSensor != NULL || engine.magnetometerSensor != NULL || engine.gyroscopeSensor != NULL) {
ASensorEvent event;
while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
&event, 1) > 0) {
if (engine.os) {
+ if (event.acceleration != NULL) {
engine.os->process_accelerometer(Vector3(event.acceleration.x, event.acceleration.y,
event.acceleration.z));
-
+ }
+ if (event.magnetic != NULL) {
+ engine.os->process_magnetometer(Vector3(event.magnetic.x, event.magnetic.y,
+ event.magnetic.z));
+ }
+ if (event.vector != NULL) {
+ engine.os->process_gyroscope(Vector3(event.vector.x, event.vector.y,
+ event.vector.z));
+ }
}
}
@@ -889,7 +930,7 @@ static Variant::Type get_jni_type(const String& p_type) {
{"java.lang.String",Variant::STRING},
{"[I",Variant::INT_ARRAY},
{"[F",Variant::REAL_ARRAY},
- {"[java.lang.String",Variant::STRING_ARRAY},
+ {"[Ljava.lang.String;",Variant::STRING_ARRAY},
{NULL,Variant::NIL}
};
@@ -920,7 +961,7 @@ static const char* get_jni_sig(const String& p_type) {
{"java.lang.String","Ljava/lang/String;"},
{"[I","[I"},
{"[F","[F"},
- {"[java.lang.String","[Ljava/lang/String;"},
+ {"[Ljava.lang.String;","[Ljava/lang/String;"},
{NULL,"V"}
};
diff --git a/platform/android/ifaddrs_android.cpp b/platform/android/ifaddrs_android.cpp
index c1e9eb3584..f6d5cdbe77 100644
--- a/platform/android/ifaddrs_android.cpp
+++ b/platform/android/ifaddrs_android.cpp
@@ -38,13 +38,16 @@
#include <errno.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+
struct netlinkrequest {
nlmsghdr header;
ifaddrmsg msg;
};
+
namespace {
const int kMaxReadSize = 4096;
-};
+}
+
static int set_ifname(struct ifaddrs* ifaddr, int interface) {
char buf[IFNAMSIZ] = {0};
char* name = if_indextoname(interface, buf);
@@ -55,6 +58,7 @@ static int set_ifname(struct ifaddrs* ifaddr, int interface) {
strncpy(ifaddr->ifa_name, name, strlen(name) + 1);
return 0;
}
+
static int set_flags(struct ifaddrs* ifaddr) {
int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd == -1) {
@@ -71,6 +75,7 @@ static int set_flags(struct ifaddrs* ifaddr) {
ifaddr->ifa_flags = ifr.ifr_flags;
return 0;
}
+
static int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data,
size_t len) {
if (msg->ifa_family == AF_INET) {
@@ -89,6 +94,7 @@ static int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data,
}
return 0;
}
+
static int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) {
char* prefix = NULL;
if (family == AF_INET) {
@@ -120,6 +126,7 @@ static int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) {
*prefix = remainder;
return 0;
}
+
static int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes,
size_t len) {
if (set_ifname(ifaddr, msg->ifa_index) != 0) {
@@ -136,6 +143,7 @@ static int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes,
}
return 0;
}
+
int getifaddrs(struct ifaddrs** result) {
int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (fd < 0) {
@@ -207,6 +215,7 @@ int getifaddrs(struct ifaddrs** result) {
freeifaddrs(start);
return -1;
}
+
void freeifaddrs(struct ifaddrs* addrs) {
struct ifaddrs* last = NULL;
struct ifaddrs* cursor = addrs;
diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.properties b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
index 0c71e760dc..d57051703e 100644
--- a/platform/android/java/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
diff --git a/platform/android/java/res/drawable-hdpi/notify_panel_notification_icon_bg.png b/platform/android/java/res/drawable-hdpi/notify_panel_notification_icon_bg.png
index f5b762ecf3..94bc406416 100644
--- a/platform/android/java/res/drawable-hdpi/notify_panel_notification_icon_bg.png
+++ b/platform/android/java/res/drawable-hdpi/notify_panel_notification_icon_bg.png
Binary files differ
diff --git a/platform/android/java/res/drawable-mdpi/notify_panel_notification_icon_bg.png b/platform/android/java/res/drawable-mdpi/notify_panel_notification_icon_bg.png
index 9ecb8af06c..ef6fe4e836 100644
--- a/platform/android/java/res/drawable-mdpi/notify_panel_notification_icon_bg.png
+++ b/platform/android/java/res/drawable-mdpi/notify_panel_notification_icon_bg.png
Binary files differ
diff --git a/platform/android/java/res/drawable/icon.png b/platform/android/java/res/drawable/icon.png
index 013632ddf1..a0a0f4af25 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/layout/downloading_expansion.xml b/platform/android/java/res/layout/downloading_expansion.xml
index 553155dcd3..d678d94eac 100644
--- a/platform/android/java/res/layout/downloading_expansion.xml
+++ b/platform/android/java/res/layout/downloading_expansion.xml
@@ -80,7 +80,7 @@
</RelativeLayout>
<LinearLayout
- android:id="@+id/downloaderDashboard"
+ android:id="@+id/downloadButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
diff --git a/platform/android/java/res/values-fa/strings.xml b/platform/android/java/res/values-fa/strings.xml
index 450f9fe212..f1e29013c4 100644
--- a/platform/android/java/res/values-fa/strings.xml
+++ b/platform/android/java/res/values-fa/strings.xml
@@ -1,7 +1,6 @@
<?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>
diff --git a/platform/android/java/res/values-id/strings.xml b/platform/android/java/res/values-in/strings.xml
index 9e9a8b0c03..9e9a8b0c03 100644
--- a/platform/android/java/res/values-id/strings.xml
+++ b/platform/android/java/res/values-in/strings.xml
diff --git a/platform/android/java/res/values-he/strings.xml b/platform/android/java/res/values-iw/strings.xml
index f52ede2085..f52ede2085 100644
--- a/platform/android/java/res/values-he/strings.xml
+++ b/platform/android/java/res/values-iw/strings.xml
diff --git a/platform/android/java/res/values-zh/strings.xml b/platform/android/java/res/values-zh-rCN/strings.xml
index 397e662851..6668c56bd9 100644
--- a/platform/android/java/res/values-zh/strings.xml
+++ b/platform/android/java/res/values-zh-rCN/strings.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="godot_project_name_string">godot-project-name-zh</string>
-</resources> \ No newline at end of file
+</resources>
diff --git a/platform/android/java/res/values-zh-rHK/strings.xml b/platform/android/java/res/values-zh-rHK/strings.xml
new file mode 100644
index 0000000000..8a6269da0f
--- /dev/null
+++ b/platform/android/java/res/values-zh-rHK/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="godot_project_name_string">godot-project-name-zh_HK</string>
+</resources>
diff --git a/platform/android/java/res/values-zh-rTW/strings.xml b/platform/android/java/res/values-zh-rTW/strings.xml
new file mode 100644
index 0000000000..b1bb39d5d6
--- /dev/null
+++ b/platform/android/java/res/values-zh-rTW/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="godot_project_name_string">godot-project-name-zh_TW</string>
+</resources>
diff --git a/platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl b/platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl
deleted file mode 100644
index 2a492f7845..0000000000
--- a/platform/android/java/src/com/android/vending/billing/IInAppBillingService.aidl
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.vending.billing;
-
-import android.os.Bundle;
-
-/**
- * InAppBillingService is the service that provides in-app billing version 3 and beyond.
- * This service provides the following features:
- * 1. Provides a new API to get details of in-app items published for the app including
- * price, type, title and description.
- * 2. The purchase flow is synchronous and purchase information is available immediately
- * after it completes.
- * 3. Purchase information of in-app purchases is maintained within the Google Play system
- * till the purchase is consumed.
- * 4. An API to consume a purchase of an inapp item. All purchases of one-time
- * in-app items are consumable and thereafter can be purchased again.
- * 5. An API to get current purchases of the user immediately. This will not contain any
- * consumed purchases.
- *
- * All calls will give a response code with the following possible values
- * RESULT_OK = 0 - success
- * RESULT_USER_CANCELED = 1 - user pressed back or canceled a dialog
- * RESULT_BILLING_UNAVAILABLE = 3 - this billing API version is not supported for the type requested
- * RESULT_ITEM_UNAVAILABLE = 4 - requested SKU is not available for purchase
- * RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API
- * RESULT_ERROR = 6 - Fatal error during the API action
- * RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned
- * RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned
- */
-interface IInAppBillingService {
- /**
- * Checks support for the requested billing API version, package and in-app type.
- * Minimum API version supported by this interface is 3.
- * @param apiVersion the billing version which the app is using
- * @param packageName the package name of the calling app
- * @param type type of the in-app item being purchased "inapp" for one-time purchases
- * and "subs" for subscription.
- * @return RESULT_OK(0) on success, corresponding result code on failures
- */
- int isBillingSupported(int apiVersion, String packageName, String type);
-
- /**
- * Provides details of a list of SKUs
- * Given a list of SKUs of a valid type in the skusBundle, this returns a bundle
- * with a list JSON strings containing the productId, price, title and description.
- * This API can be called with a maximum of 20 SKUs.
- * @param apiVersion billing API version that the Third-party is using
- * @param packageName the package name of the calling app
- * @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST"
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
- * failure as listed above.
- * "DETAILS_LIST" with a StringArrayList containing purchase information
- * in JSON format similar to:
- * '{ "productId" : "exampleSku", "type" : "inapp", "price" : "$5.00",
- * "title : "Example Title", "description" : "This is an example description" }'
- */
- Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
-
- /**
- * Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU,
- * the type, a unique purchase token and an optional developer payload.
- * @param apiVersion billing API version that the app is using
- * @param packageName package name of the calling app
- * @param sku the SKU of the in-app item as published in the developer console
- * @param type the type of the in-app item ("inapp" for one-time purchases
- * and "subs" for subscription).
- * @param developerPayload optional argument to be sent back with the purchase information
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
- * failure as listed above.
- * "BUY_INTENT" - PendingIntent to start the purchase flow
- *
- * The Pending intent should be launched with startIntentSenderForResult. When purchase flow
- * has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
- * If the purchase is successful, the result data will contain the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
- * failure as listed above.
- * "INAPP_PURCHASE_DATA" - String in JSON format similar to
- * '{"orderId":"12999763169054705758.1371079406387615",
- * "packageName":"com.example.app",
- * "productId":"exampleSku",
- * "purchaseTime":1345678900000,
- * "purchaseToken" : "122333444455555",
- * "developerPayload":"example developer payload" }'
- * "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
- * was signed with the private key of the developer
- * TODO: change this to app-specific keys.
- */
- Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type,
- String developerPayload);
-
- /**
- * Returns the current SKUs owned by the user of the type and package name specified along with
- * purchase information and a signature of the data to be validated.
- * This will return all SKUs that have been purchased in V3 and managed items purchased using
- * V1 and V2 that have not been consumed.
- * @param apiVersion billing API version that the app is using
- * @param packageName package name of the calling app
- * @param type the type of the in-app items being requested
- * ("inapp" for one-time purchases and "subs" for subscription).
- * @param continuationToken to be set as null for the first call, if the number of owned
- * skus are too many, a continuationToken is returned in the response bundle.
- * This method can be called again with the continuation token to get the next set of
- * owned skus.
- * @return Bundle containing the following key-value pairs
- * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
- * failure as listed above.
- * "INAPP_PURCHASE_ITEM_LIST" - StringArrayList containing the list of SKUs
- * "INAPP_PURCHASE_DATA_LIST" - StringArrayList containing the purchase information
- * "INAPP_DATA_SIGNATURE_LIST"- StringArrayList containing the signatures
- * of the purchase information
- * "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the
- * next set of in-app purchases. Only set if the
- * user has more owned skus than the current list.
- */
- Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken);
-
- /**
- * Consume the last purchase of the given SKU. This will result in this item being removed
- * from all subsequent responses to getPurchases() and allow re-purchase of this item.
- * @param apiVersion billing API version that the app is using
- * @param packageName package name of the calling app
- * @param purchaseToken token in the purchase information JSON that identifies the purchase
- * to be consumed
- * @return 0 if consumption succeeded. Appropriate error values for failures.
- */
- int consumePurchase(int apiVersion, String packageName, String purchaseToken);
-}
diff --git a/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java b/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java
index 0b1c4b6cca..531cb22f8c 100644
--- a/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java
+++ b/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java
@@ -146,11 +146,11 @@ public class LicenseChecker implements ServiceConnection {
if (mService == null) {
Log.i(TAG, "Binding to licensing service.");
try {
+ Intent serviceIntent = new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=")));
+ serviceIntent.setPackage("com.android.vending");
boolean bindResult = mContext
.bindService(
- new Intent(
- new String(
- Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
+ serviceIntent,
this, // ServiceConnection.
Context.BIND_AUTO_CREATE);
diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/Constants.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/Constants.java
index ff2c6f535a..2af33b96b9 100644
--- a/platform/android/java/src/com/google/android/vending/expansion/downloader/Constants.java
+++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/Constants.java
@@ -33,6 +33,10 @@ public class Constants {
public static final String EXP_PATH = File.separator + "Android"
+ File.separator + "obb" + File.separator;
+ // save to private app's data on Android 6.0 to skip requesting permission.
+ public static final String EXP_PATH_API23 = File.separator + "Android"
+ + File.separator + "data" + File.separator;
+
/** The intent that gets sent when the service must wake up for a retry */
public static final String ACTION_RETRY = "android.intent.action.DOWNLOAD_WAKEUP";
@@ -70,7 +74,7 @@ public class Constants {
* The number of times that the download manager will retry its network
* operations when no progress is happening before it gives up.
*/
- public static final int MAX_RETRIES = 5;
+ public static final int MAX_RETRIES = 10;
/**
* The minimum amount of time that the download manager accepts for
diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/Helpers.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/Helpers.java
index b4c28d36e7..ae3fe957cb 100644
--- a/platform/android/java/src/com/google/android/vending/expansion/downloader/Helpers.java
+++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/Helpers.java
@@ -19,6 +19,7 @@ package com.google.android.vending.expansion.downloader;
import com.godot.game.R;
import android.content.Context;
+import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.os.SystemClock;
@@ -220,8 +221,8 @@ public class Helpers {
static public String getSaveFilePath(Context c) {
File root = Environment.getExternalStorageDirectory();
- String path = root.toString() + Constants.EXP_PATH + c.getPackageName();
- return path;
+ String path = Build.VERSION.SDK_INT >= 23 ? Constants.EXP_PATH_API23 : Constants.EXP_PATH;
+ return root.toString() + path + c.getPackageName();
}
/**
diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java
index 9a0ca02122..e2673a9dd7 100644
--- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java
+++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java
@@ -25,6 +25,6 @@ public class CustomNotificationFactory {
if (android.os.Build.VERSION.SDK_INT > 13)
return new V14CustomNotification();
else
- return new V3CustomNotification();
+ throw new RuntimeException();
}
}
diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java
index d82b658bc3..73e6f83bec 100644
--- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java
+++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java
@@ -27,6 +27,7 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.os.Messenger;
+import android.support.v4.app.NotificationCompat;
/**
* This class handles displaying the notification associated with the download
@@ -48,8 +49,9 @@ public class DownloadNotification implements IDownloaderClient {
private IDownloaderClient mClientProxy;
final ICustomNotification mCustomNotification;
- private Notification mNotification;
- private Notification mCurrentNotification;
+ // NotificationCompat.Builder is used to support API < 16. This can be changed to Notification.Builder if minimum API >= 16.
+ private NotificationCompat.Builder mNotificationBuilder;
+ private NotificationCompat.Builder mCurrentNotificationBuilder;
private CharSequence mLabel;
private String mCurrentText;
private PendingIntent mContentIntent;
@@ -132,17 +134,14 @@ public class DownloadNotification implements IDownloaderClient {
}
mCurrentText = mContext.getString(stringDownloadID);
mCurrentTitle = mLabel.toString();
- mCurrentNotification.tickerText = mLabel + ": " + mCurrentText;
- mCurrentNotification.icon = iconResource;
- mCurrentNotification.setLatestEventInfo(mContext, mCurrentTitle, mCurrentText,
- mContentIntent);
- if (ongoingEvent) {
- mCurrentNotification.flags |= Notification.FLAG_ONGOING_EVENT;
- } else {
- mCurrentNotification.flags &= ~Notification.FLAG_ONGOING_EVENT;
- mCurrentNotification.flags |= Notification.FLAG_AUTO_CANCEL;
- }
- mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotification);
+ mCurrentNotificationBuilder.setTicker(mLabel + ": " + mCurrentText);
+ mCurrentNotificationBuilder.setSmallIcon(iconResource);
+ mCurrentNotificationBuilder.setContentTitle(mCurrentTitle);
+ mCurrentNotificationBuilder.setContentText(mCurrentText);
+ mCurrentNotificationBuilder.setContentIntent(mContentIntent);
+ mCurrentNotificationBuilder.setOngoing(ongoingEvent);
+ mCurrentNotificationBuilder.setAutoCancel(!ongoingEvent);
+ mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotificationBuilder.build());
}
}
@@ -154,10 +153,12 @@ public class DownloadNotification implements IDownloaderClient {
}
if (progress.mOverallTotal <= 0) {
// we just show the text
- mNotification.tickerText = mCurrentTitle;
- mNotification.icon = android.R.drawable.stat_sys_download;
- mNotification.setLatestEventInfo(mContext, mLabel, mCurrentText, mContentIntent);
- mCurrentNotification = mNotification;
+ mNotificationBuilder.setTicker(mCurrentTitle);
+ mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
+ mNotificationBuilder.setContentTitle(mCurrentTitle);
+ mNotificationBuilder.setContentText(mCurrentText);
+ mNotificationBuilder.setContentIntent(mContentIntent);
+ mCurrentNotificationBuilder = mNotificationBuilder;
} else {
mCustomNotification.setCurrentBytes(progress.mOverallProgress);
mCustomNotification.setTotalBytes(progress.mOverallTotal);
@@ -166,9 +167,9 @@ public class DownloadNotification implements IDownloaderClient {
mCustomNotification.setTicker(mLabel + ": " + mCurrentText);
mCustomNotification.setTitle(mLabel);
mCustomNotification.setTimeRemaining(progress.mTimeRemaining);
- mCurrentNotification = mCustomNotification.updateNotification(mContext);
+ mCurrentNotificationBuilder = mCustomNotification.updateNotification(mContext);
}
- mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotification);
+ mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotificationBuilder.build());
}
public interface ICustomNotification {
@@ -186,7 +187,7 @@ public class DownloadNotification implements IDownloaderClient {
void setTimeRemaining(long timeRemaining);
- Notification updateNotification(Context c);
+ NotificationCompat.Builder updateNotification(Context c);
}
/**
@@ -219,8 +220,8 @@ public class DownloadNotification implements IDownloaderClient {
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mCustomNotification = CustomNotificationFactory
.createCustomNotification();
- mNotification = new Notification();
- mCurrentNotification = mNotification;
+ mNotificationBuilder = new NotificationCompat.Builder(ctx);
+ mCurrentNotificationBuilder = mNotificationBuilder;
}
diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java
index 2e049a4d47..390bde96e9 100644
--- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java
+++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java
@@ -22,6 +22,7 @@ import com.google.android.vending.expansion.downloader.Helpers;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
+import android.support.v4.app.NotificationCompat;
public class V14CustomNotification implements DownloadNotification.ICustomNotification {
@@ -53,13 +54,14 @@ public class V14CustomNotification implements DownloadNotification.ICustomNotifi
mCurrentKB = currentBytes;
}
- void setProgress(Notification.Builder builder) {
+ void setProgress(NotificationCompat.Builder builder) {
}
@Override
- public Notification updateNotification(Context c) {
- Notification.Builder builder = new Notification.Builder(c);
+ public NotificationCompat.Builder updateNotification(Context c) {
+ // NotificationCompat.Builder is used to support API < 16. This can be changed to Notification.Builder if minimum API >= 16.
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(c);
builder.setContentTitle(mTitle);
if (mTotalKB > 0 && -1 != mCurrentKB) {
builder.setProgress((int) (mTotalKB >> 8), (int) (mCurrentKB >> 8), false);
@@ -80,7 +82,7 @@ public class V14CustomNotification implements DownloadNotification.ICustomNotifi
builder.setContentIntent(mPendingIntent);
builder.setOnlyAlertOnce(true);
- return builder.getNotification();
+ return builder;
}
@Override
diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V3CustomNotification.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V3CustomNotification.java
deleted file mode 100644
index 94e21de7ca..0000000000
--- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V3CustomNotification.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.vending.expansion.downloader.impl;
-
-import com.godot.game.R;
-import com.google.android.vending.expansion.downloader.Helpers;
-
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.graphics.BitmapFactory;
-import android.view.View;
-import android.widget.RemoteViews;
-
-public class V3CustomNotification implements DownloadNotification.ICustomNotification {
-
- CharSequence mTitle;
- CharSequence mTicker;
- int mIcon;
- long mTotalBytes = -1;
- long mCurrentBytes = -1;
- long mTimeRemaining;
- PendingIntent mPendingIntent;
- Notification mNotification = new Notification();
-
- @Override
- public void setIcon(int icon) {
- mIcon = icon;
- }
-
- @Override
- public void setTitle(CharSequence title) {
- mTitle = title;
- }
-
- @Override
- public void setTotalBytes(long totalBytes) {
- mTotalBytes = totalBytes;
- }
-
- @Override
- public void setCurrentBytes(long currentBytes) {
- mCurrentBytes = currentBytes;
- }
-
- @Override
- public Notification updateNotification(Context c) {
- Notification n = mNotification;
-
- n.icon = mIcon;
-
- n.flags |= Notification.FLAG_ONGOING_EVENT;
-
- if (android.os.Build.VERSION.SDK_INT > 10) {
- n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; // only matters for
- // Honeycomb
- }
-
- // Build the RemoteView object
- RemoteViews expandedView = new RemoteViews(
- c.getPackageName(),
- R.layout.status_bar_ongoing_event_progress_bar);
-
- expandedView.setTextViewText(R.id.title, mTitle);
- // look at strings
- expandedView.setViewVisibility(R.id.description, View.VISIBLE);
- expandedView.setTextViewText(R.id.description,
- Helpers.getDownloadProgressString(mCurrentBytes, mTotalBytes));
- expandedView.setViewVisibility(R.id.progress_bar_frame, View.VISIBLE);
- expandedView.setProgressBar(R.id.progress_bar,
- (int) (mTotalBytes >> 8),
- (int) (mCurrentBytes >> 8),
- mTotalBytes <= 0);
- expandedView.setViewVisibility(R.id.time_remaining, View.VISIBLE);
- expandedView.setTextViewText(
- R.id.time_remaining,
- c.getString(R.string.time_remaining_notification,
- Helpers.getTimeRemaining(mTimeRemaining)));
- expandedView.setTextViewText(R.id.progress_text,
- Helpers.getDownloadProgressPercent(mCurrentBytes, mTotalBytes));
- expandedView.setImageViewResource(R.id.appIcon, mIcon);
- n.contentView = expandedView;
- n.contentIntent = mPendingIntent;
- return n;
- }
-
- @Override
- public void setPendingIntent(PendingIntent contentIntent) {
- mPendingIntent = contentIntent;
- }
-
- @Override
- public void setTicker(CharSequence ticker) {
- mTicker = ticker;
- }
-
- @Override
- public void setTimeRemaining(long timeRemaining) {
- mTimeRemaining = timeRemaining;
- }
-
-}
diff --git a/platform/android/java/src/org/godotengine/godot/Dictionary.java b/platform/android/java/src/org/godotengine/godot/Dictionary.java
index 34051c4bb8..e003c245bb 100644
--- a/platform/android/java/src/org/godotengine/godot/Dictionary.java
+++ b/platform/android/java/src/org/godotengine/godot/Dictionary.java
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 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/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 1f208f8fb6..4b80db7e33 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -115,7 +115,17 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private int mState;
private boolean keep_screen_on=true;
- private void setState(int newState) {
+ static private Intent mCurrentIntent;
+
+ @Override public void onNewIntent(Intent intent) {
+ mCurrentIntent = intent;
+ }
+
+ static public Intent getCurrentIntent() {
+ return mCurrentIntent;
+ }
+
+ private void setState(int newState) {
if (mState != newState) {
mState = newState;
mStatusText.setText(Helpers.getDownloaderStringResourceIDFromState(newState));
@@ -206,6 +216,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private SensorManager mSensorManager;
private Sensor mAccelerometer;
+ private Sensor mMagnetometer;
+ private Sensor mGyroscope;
public FrameLayout layout;
public RelativeLayout adLayout;
@@ -374,6 +386,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
+ mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
+ mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME);
+ mGyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
+ mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_GAME);
result_callback = null;
@@ -464,7 +480,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
// Build the full path to the app's expansion files
try {
- expansion_pack_path = Environment.getExternalStorageDirectory().toString() + "/Android/obb/"+this.getPackageName();
+ expansion_pack_path = Helpers.getSaveFilePath(getApplicationContext());
expansion_pack_path+="/"+"main."+getPackageManager().getPackageInfo(getPackageName(), 0).versionCode+"."+this.getPackageName()+".obb";
} catch (Exception e) {
e.printStackTrace();
@@ -542,6 +558,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
}
+ mCurrentIntent = getIntent();
+
initializeGodot();
@@ -587,7 +605,9 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
mView.onResume();
- mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
+ mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
+ mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME);
+ mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_GAME);
GodotLib.focusin();
if(use_immersive && Build.VERSION.SDK_INT >= 19.0){ // check if the application runs on an android 4.4+
Window window = getWindow();
@@ -646,7 +666,17 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
float x = adjustedValues[0];
float y = adjustedValues[1];
float z = adjustedValues[2];
- GodotLib.accelerometer(x,y,z);
+
+ int typeOfSensor = event.sensor.getType();
+ if (typeOfSensor == event.sensor.TYPE_ACCELEROMETER) {
+ GodotLib.accelerometer(x,y,z);
+ }
+ if (typeOfSensor == event.sensor.TYPE_MAGNETIC_FIELD) {
+ GodotLib.magnetometer(x,y,z);
+ }
+ if (typeOfSensor == event.sensor.TYPE_GYROSCOPE) {
+ GodotLib.gyroscope(x,y,z);
+ }
}
@Override public final void onAccuracyChanged(Sensor sensor, int accuracy) {
diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
index b602f4757c..ea6c070fae 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* GodotDownloaderAlarmReceiver.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot;
import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
index 6735d387f3..4ea3f13021 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* GodotDownloaderService.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot;
import android.content.Context;
diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java
index 3e6919c2ad..55e330924a 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java
@@ -40,6 +40,7 @@ import android.view.*;
import android.view.inputmethod.InputMethodManager;
import android.os.*;
import android.util.Log;
+import android.util.DisplayMetrics;
import android.graphics.*;
import android.text.method.*;
import android.text.*;
@@ -513,6 +514,11 @@ public class GodotIO {
return Build.MODEL;
}
+ public int getScreenDPI() {
+ DisplayMetrics metrics = applicationContext.getResources().getDisplayMetrics();
+ return (int)(metrics.density * 160f);
+ }
+
public boolean needsReloadHooks() {
return android.os.Build.VERSION.SDK_INT < 11;
diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java
index 7c5ac33c85..9a2ea7df10 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java
@@ -51,6 +51,8 @@ public class GodotLib {
public static native void step();
public static native void touch(int what,int pointer,int howmany, int[] arr);
public static native void accelerometer(float x, float y, float z);
+ public static native void magnetometer(float x, float y, float z);
+ public static native void gyroscope(float x, float y, float z);
public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed);
public static native void joybutton(int p_device, int p_but, boolean p_pressed);
public static native void joyaxis(int p_device, int p_axis, float p_value);
diff --git a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
index 6bec49410d..b7de31ada3 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
@@ -1,98 +1,121 @@
+/*************************************************************************/
+/* GodotPaymentV3.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot;
-import org.godotengine.godot.Dictionary;
import android.app.Activity;
import android.util.Log;
+import org.godotengine.godot.payments.PaymentsManager;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
public class GodotPaymentV3 extends Godot.SingletonBase {
private Godot activity;
-
private Integer purchaseCallbackId = 0;
-
private String accessToken;
-
private String purchaseValidationUrlPrefix;
-
private String transactionId;
+ private PaymentsManager mPaymentManager;
+ private Dictionary mSkuDetails = new Dictionary();
- public void purchase( String _sku, String _transactionId) {
- final String sku = _sku;
- final String transactionId = _transactionId;
- activity.getPaymentsManager().setBaseSingleton(this);
+ public void purchase(final String sku, final String transactionId) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
- activity.getPaymentsManager().requestPurchase(sku, transactionId);
+ mPaymentManager.requestPurchase(sku, transactionId);
}
});
}
-
-/* public string requestPurchasedTicket(){
- activity.getPaymentsManager()
- }
-*/
- static public Godot.SingletonBase initialize(Activity p_activity) {
+ static public Godot.SingletonBase initialize(Activity p_activity) {
- return new GodotPaymentV3(p_activity);
- }
+ return new GodotPaymentV3(p_activity);
+ }
-
public GodotPaymentV3(Activity p_activity) {
- registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume"});
- activity=(Godot) p_activity;
+ registerClass("GodotPayments", new String[]{"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume", "querySkuDetails"});
+ activity = (Godot) p_activity;
+ mPaymentManager = activity.getPaymentsManager();
+ mPaymentManager.setBaseSingleton(this);
}
- public void consumeUnconsumedPurchases(){
- activity.getPaymentsManager().setBaseSingleton(this);
+ public void consumeUnconsumedPurchases() {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
- activity.getPaymentsManager().consumeUnconsumedPurchases();
+ mPaymentManager.consumeUnconsumedPurchases();
}
});
}
private String signature;
- public String getSignature(){
- return this.signature;
+
+ public String getSignature() {
+ return this.signature;
}
-
-
- public void callbackSuccess(String ticket, String signature, String sku){
-// Log.d(this.getClass().getName(), "PRE-Send callback to purchase success");
+
+ public void callbackSuccess(String ticket, String signature, String sku) {
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(), "callbackSuccessProductMassConsumed > " + ticket + "," + signature + "," + sku);
+ GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku});
+ }
- public void callbackSuccessProductMassConsumed(String ticket, String signature, String sku){
-// 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, "consume_not_required", new Object[]{});
}
- public void callbackSuccessNoUnconsumedPurchases(){
- GodotLib.calldeferred(purchaseCallbackId, "no_validation_required", new Object[]{});
+ public void callbackFailConsume() {
+ GodotLib.calldeferred(purchaseCallbackId, "consume_fail", new Object[]{});
}
-
- public void callbackFail(){
+
+ public void callbackFail() {
GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
-// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
}
-
- public void callbackCancel(){
+
+ public void callbackCancel() {
GodotLib.calldeferred(purchaseCallbackId, "purchase_cancel", new Object[]{});
-// GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{});
}
-
- public void callbackAlreadyOwned(String sku){
+
+ public void callbackAlreadyOwned(String sku) {
GodotLib.calldeferred(purchaseCallbackId, "purchase_owned", new Object[]{sku});
}
-
+
public int getPurchaseCallbackId() {
return purchaseCallbackId;
}
@@ -101,11 +124,11 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
this.purchaseCallbackId = purchaseCallbackId;
}
- public String getPurchaseValidationUrlPrefix(){
- return this.purchaseValidationUrlPrefix ;
+ public String getPurchaseValidationUrlPrefix() {
+ return this.purchaseValidationUrlPrefix;
}
- public void setPurchaseValidationUrlPrefix(String url){
+ public void setPurchaseValidationUrlPrefix(String url) {
this.purchaseValidationUrlPrefix = url;
}
@@ -116,39 +139,80 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
-
- public void setTransactionId(String transactionId){
+
+ public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
-
- public String getTransactionId(){
+
+ public String getTransactionId() {
return this.transactionId;
}
-
+
// request purchased items are not consumed
- public void requestPurchased(){
- activity.getPaymentsManager().setBaseSingleton(this);
+ public void requestPurchased() {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
- activity.getPaymentsManager().requestPurchased();
+ mPaymentManager.requestPurchased();
}
});
}
-
+
// callback for requestPurchased()
- public void callbackPurchased(String receipt, String signature, String sku){
+ 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);
+ public void setAutoConsume(boolean autoConsume) {
+ mPaymentManager.setAutoConsume(autoConsume);
}
-
+
// consume a specific item
- public void consume(String sku){
- activity.getPaymentsManager().consume(sku);
+ public void consume(String sku) {
+ mPaymentManager.consume(sku);
+ }
+
+ // query in app item detail info
+ public void querySkuDetails(String[] list) {
+ List<String> nKeys = Arrays.asList(list);
+ List<String> cKeys = Arrays.asList(mSkuDetails.get_keys());
+ ArrayList<String> fKeys = new ArrayList<String>();
+ for (String key : nKeys) {
+ if (!cKeys.contains(key)) {
+ fKeys.add(key);
+ }
+ }
+ if (fKeys.size() > 0) {
+ mPaymentManager.querySkuDetails(fKeys.toArray(new String[0]));
+ } else {
+ completeSkuDetail();
+ }
+ }
+
+ public void addSkuDetail(String itemJson) {
+ JSONObject o = null;
+ try {
+ o = new JSONObject(itemJson);
+ Dictionary item = new Dictionary();
+ item.put("type", o.optString("type"));
+ item.put("product_id", o.optString("productId"));
+ item.put("title", o.optString("title"));
+ item.put("description", o.optString("description"));
+ item.put("price", o.optString("price"));
+ item.put("price_currency_code", o.optString("price_currency_code"));
+ item.put("price_amount", 0.000001d * o.optLong("price_amount_micros"));
+ mSkuDetails.put(item.get("product_id").toString(), item);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void completeSkuDetail() {
+ GodotLib.calldeferred(purchaseCallbackId, "sku_details_complete", new Object[]{mSkuDetails});
+ }
+
+ public void errorSkuDetail(String errorMessage) {
+ GodotLib.calldeferred(purchaseCallbackId, "sku_details_error", new Object[]{errorMessage});
}
}
-
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
index c8ffa74ecd..aa92eeae0f 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* GodotEditText.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.input;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
index 64d8826b44..13c8c8b3ec 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* GodotTextInputWrapper.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.input;
import android.content.Context;
import android.text.Editable;
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
index 61ccb97161..16b669fbe8 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* ConsumeTask.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
import com.android.vending.billing.IInAppBillingService;
diff --git a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
index 293e903284..175d401c87 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* GenericConsumeTask.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
import com.android.vending.billing.IInAppBillingService;
diff --git a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
index d120551e4a..e63230c4f8 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* HandlePurchaseTask.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
import org.json.JSONException;
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
index 5f3d931593..0635385f53 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* PaymentsCache.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
import android.content.Context;
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
index effb58aa35..753c0a6f93 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
@@ -1,282 +1,397 @@
+/*************************************************************************/
+/* PaymentsManager.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.os.RemoteException;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.os.Bundle;
import android.os.IBinder;
+import android.os.RemoteException;
+import android.text.TextUtils;
import android.util.Log;
-import android.os.Bundle;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONStringer;
+import com.android.vending.billing.IInAppBillingService;
-import org.godotengine.godot.Dictionary;
import org.godotengine.godot.Godot;
import org.godotengine.godot.GodotPaymentV3;
-import com.android.vending.billing.IInAppBillingService;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Arrays;
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;
- public void setActivity(Activity activity){
+ public void setActivity(Activity activity) {
this.activity = activity;
}
- public static PaymentsManager createManager(Activity activity){
+ public static PaymentsManager createManager(Activity activity) {
PaymentsManager manager = new PaymentsManager(activity);
return manager;
}
-
- private PaymentsManager(Activity activity){
+
+ private PaymentsManager(Activity activity) {
this.activity = activity;
}
-
- public PaymentsManager initService(){
+
+ public PaymentsManager initService() {
Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
intent.setPackage("com.android.vending");
activity.bindService(
- intent,
- mServiceConn,
+ intent,
+ mServiceConn,
Context.BIND_AUTO_CREATE);
return this;
}
- public void destroy(){
+ public void destroy() {
if (mService != null) {
- activity.unbindService(mServiceConn);
- }
+ activity.unbindService(mServiceConn);
+ }
}
-
+
ServiceConnection mServiceConn = new ServiceConnection() {
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mService = null;
- }
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ mService = null;
+ }
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
- }
+ }
};
-
- public void requestPurchase(final String sku, String transactionId){
+
+ public void requestPurchase(final String sku, String transactionId) {
new PurchaseTask(mService, Godot.getInstance()) {
-
+
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
-
+
}
-
+
@Override
protected void canceled() {
godotPaymentV3.callbackCancel();
}
-
+
@Override
protected void alreadyOwned() {
godotPaymentV3.callbackAlreadyOwned(sku);
}
-
+
}.purchase(sku, transactionId);
}
- public void consumeUnconsumedPurchases(){
+ public void consumeUnconsumedPurchases() {
new ReleaseAllConsumablesTask(mService, activity) {
-
+
@Override
protected void success(String sku, String receipt, String signature, String token) {
godotPaymentV3.callbackSuccessProductMassConsumed(receipt, signature, sku);
}
-
+
@Override
protected void error(String message) {
- godotPaymentV3.callbackFail();
-
+ Log.d("godot", "consumeUnconsumedPurchases :" + message);
+ godotPaymentV3.callbackFailConsume();
+
}
@Override
protected void notRequired() {
+ Log.d("godot", "callbackSuccessNoUnconsumedPurchases :");
godotPaymentV3.callbackSuccessNoUnconsumedPurchases();
-
+
}
}.consumeItAll();
}
-
- public void requestPurchased(){
- try{
+
+ 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);
+ String continueToken = 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){
+ do {
+ Bundle bundle = mService.getPurchases(3, activity.getPackageName(), "inapp", continueToken);
- final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
- final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
-
+ if (bundle.getInt("RESPONSE_CODE") == 0) {
- 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) {
+ 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) {
+ godotPaymentV3.callbackPurchased("", "", "");
+ return;
}
- }
- }
- }catch(Exception e){
+ 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);
+
+ 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) {
+ }
+ }
+ }
+ continueToken = bundle.getString("INAPP_CONTINUATION_TOKEN");
+ Log.d("godot", "continue token = " + continueToken);
+ } while (!TextUtils.isEmpty(continueToken));
+ } 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){
+ new HandlePurchaseTask(activity) {
@Override
protected void success(final String sku, final String signature, final String ticket) {
godotPaymentV3.callbackSuccess(ticket, signature, sku);
- if (auto_consume){
+ if (auto_consume) {
new ConsumeTask(mService, activity) {
-
+
@Override
protected void success(String ticket) {
-// godotPaymentV3.callbackSuccess("");
}
-
+
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
-
+
}
}.consume(sku);
}
-
-// godotPaymentV3.callbackSuccess(new PaymentsCache(activity).getConsumableValue("ticket", sku),signature);
-// godotPaymentV3.callbackSuccess(ticket);
- //validatePurchase(purchaseToken, sku);
}
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
-
}
@Override
protected void canceled() {
godotPaymentV3.callbackCancel();
-
}
}.handlePurchaseRequest(resultCode, data);
}
-
- public void validatePurchase(String purchaseToken, final String sku){
-
- new ValidateTask(activity, godotPaymentV3){
+
+ public void validatePurchase(String purchaseToken, final String sku) {
+
+ new ValidateTask(activity, godotPaymentV3) {
@Override
protected void success() {
-
+
new ConsumeTask(mService, activity) {
-
+
@Override
protected void success(String ticket) {
godotPaymentV3.callbackSuccess(ticket, null, sku);
-
}
-
+
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
-
}
}.consume(sku);
-
+
}
@Override
protected void error(String message) {
godotPaymentV3.callbackFail();
-
}
@Override
protected void canceled() {
godotPaymentV3.callbackCancel();
-
}
}.validatePurchase(sku);
}
-
- public void setAutoConsume(boolean autoConsume){
+
+ public void setAutoConsume(boolean autoConsume) {
auto_consume = autoConsume;
}
-
- public void consume(final String sku){
+
+ 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();
-
+ godotPaymentV3.callbackFailConsume();
}
}.consume(sku);
}
-
+
+ // Workaround to bug where sometimes response codes come as Long instead of Integer
+ int getResponseCodeFromBundle(Bundle b) {
+ Object o = b.get("RESPONSE_CODE");
+ if (o == null) {
+ //logDebug("Bundle with null response code, assuming OK (known issue)");
+ return BILLING_RESPONSE_RESULT_OK;
+ } else if (o instanceof Integer) return ((Integer) o).intValue();
+ else if (o instanceof Long) return (int) ((Long) o).longValue();
+ else {
+ //logError("Unexpected type for bundle response code.");
+ //logError(o.getClass().getName());
+ throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
+ }
+ }
+
+ /**
+ * Returns a human-readable description for the given response code.
+ *
+ * @param code The response code
+ * @return A human-readable string explaining the result code.
+ * It also includes the result code numerically.
+ */
+ public static String getResponseDesc(int code) {
+ String[] iab_msgs = ("0:OK/1:User Canceled/2:Unknown/" +
+ "3:Billing Unavailable/4:Item unavailable/" +
+ "5:Developer Error/6:Error/7:Item Already Owned/" +
+ "8:Item not owned").split("/");
+ String[] iabhelper_msgs = ("0:OK/-1001:Remote exception during initialization/" +
+ "-1002:Bad response received/" +
+ "-1003:Purchase signature verification failed/" +
+ "-1004:Send intent failed/" +
+ "-1005:User cancelled/" +
+ "-1006:Unknown purchase response/" +
+ "-1007:Missing token/" +
+ "-1008:Unknown error/" +
+ "-1009:Subscriptions not available/" +
+ "-1010:Invalid consumption attempt").split("/");
+
+ if (code <= -1000) {
+ int index = -1000 - code;
+ if (index >= 0 && index < iabhelper_msgs.length) return iabhelper_msgs[index];
+ else return String.valueOf(code) + ":Unknown IAB Helper Error";
+ } else if (code < 0 || code >= iab_msgs.length)
+ return String.valueOf(code) + ":Unknown";
+ else
+ return iab_msgs[code];
+ }
+
+ public void querySkuDetails(final String[] list) {
+ (new Thread(new Runnable() {
+ @Override
+ public void run() {
+ ArrayList<String> skuList = new ArrayList<String>(Arrays.asList(list));
+ if (skuList.size() == 0) {
+ return;
+ }
+ // Split the sku list in blocks of no more than 20 elements.
+ ArrayList<ArrayList<String>> packs = new ArrayList<ArrayList<String>>();
+ ArrayList<String> tempList;
+ int n = skuList.size() / 20;
+ int mod = skuList.size() % 20;
+ for (int i = 0; i < n; i++) {
+ tempList = new ArrayList<String>();
+ for (String s : skuList.subList(i * 20, i * 20 + 20)) {
+ tempList.add(s);
+ }
+ packs.add(tempList);
+ }
+ if (mod != 0) {
+ tempList = new ArrayList<String>();
+ for (String s : skuList.subList(n * 20, n * 20 + mod)) {
+ tempList.add(s);
+ }
+ packs.add(tempList);
+
+ for (ArrayList<String> skuPartList : packs) {
+ Bundle querySkus = new Bundle();
+ querySkus.putStringArrayList("ITEM_ID_LIST", skuPartList);
+ Bundle skuDetails = null;
+ try {
+ skuDetails = mService.getSkuDetails(3, activity.getPackageName(), "inapp", querySkus);
+ if (!skuDetails.containsKey("DETAILS_LIST")) {
+ int response = getResponseCodeFromBundle(skuDetails);
+ if (response != BILLING_RESPONSE_RESULT_OK) {
+ godotPaymentV3.errorSkuDetail(getResponseDesc(response));
+ } else {
+ godotPaymentV3.errorSkuDetail("No error but no detail list.");
+ }
+ return;
+ }
+
+ ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
+
+ for (String thisResponse : responseList) {
+ Log.d("godot", "response = "+thisResponse);
+ godotPaymentV3.addSkuDetail(thisResponse);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ godotPaymentV3.errorSkuDetail("RemoteException error!");
+ }
+ }
+ godotPaymentV3.completeSkuDetail();
+ }
+ }
+ })).start();
+ }
+
private GodotPaymentV3 godotPaymentV3;
-
+
public void setBaseSingleton(GodotPaymentV3 godotPaymentV3) {
this.godotPaymentV3 = godotPaymentV3;
}
}
-
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
index 8b048d8065..9e92d8b5a5 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* PurchaseTask.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
import org.json.JSONException;
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
index 7bb5131b49..2dc7dcf6b1 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* ReleaseAllConsumablesTask.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
import java.util.ArrayList;
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
index 2fcf7483b4..f3532f311f 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* ValidateTask.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.payments;
import org.json.JSONException;
diff --git a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
index 2fb81cef8c..ef7793c1e6 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* Crypt.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.utils;
import java.security.MessageDigest;
diff --git a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
index 2db88fcc9b..f2b0e8786e 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* CustomSSLSocketFactory.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.utils;
import java.io.IOException;
import java.net.Socket;
@@ -51,4 +79,4 @@ public class CustomSSLSocketFactory extends SSLSocketFactory {
public Socket createSocket() throws IOException {
return sslContext.getSocketFactory().createSocket();
}
-} \ No newline at end of file
+}
diff --git a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
index 14346702cc..5687b3c1e1 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* HttpRequester.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.utils;
import java.io.BufferedReader;
diff --git a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
index 36753e368c..d66dfe9531 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* RequestParams.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
package org.godotengine.godot.utils;
import java.util.ArrayList;
diff --git a/platform/android/java_bind.cpp b/platform/android/java_bind.cpp
deleted file mode 100644
index 33ecfcffb6..0000000000
--- a/platform/android/java_bind.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "java_bind.h"
-
-JavaBind::JavaBind()
-{
-}
diff --git a/platform/android/java_bind.h b/platform/android/java_bind.h
deleted file mode 100644
index ca6b4650d3..0000000000
--- a/platform/android/java_bind.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef JAVA_BIND_H
-#define JAVA_BIND_H
-
-class JavaBind
-{
-public:
- JavaBind();
-};
-
-#endif // JAVA_BIND_H
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index 283ea81152..cc1e5b61d1 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* java_class_wrapper.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "java_class_wrapper.h"
#include "thread_jandroid.h"
@@ -512,25 +540,21 @@ Variant JavaClass::call(const StringName& p_method,const Variant** p_args,int p_
JavaClass::JavaClass() {
-
}
/////////////////////
Variant JavaObject::call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error){
-
return Variant();
}
JavaObject::JavaObject(const Ref<JavaClass>& p_base,jobject *p_instance) {
-
}
JavaObject::~JavaObject(){
-
}
@@ -1328,5 +1352,4 @@ JavaClassWrapper::JavaClassWrapper(jobject p_activity) {
bclass = env->FindClass("java/lang/Double");
Double_doubleValue = env->GetMethodID(bclass, "doubleValue", "()D");
-
}
diff --git a/platform/android/java_class_wrapper.h b/platform/android/java_class_wrapper.h
index d5d8bd5be8..012e7854fe 100644
--- a/platform/android/java_class_wrapper.h
+++ b/platform/android/java_class_wrapper.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* java_class_wrapper.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#ifndef JAVA_CLASS_WRAPPER_H
#define JAVA_CLASS_WRAPPER_H
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index b5beb8fa2c..e5b655e5d5 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -215,7 +215,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a
}
return v;
-};
+}
String _get_class_name(JNIEnv * env, jclass cls, bool* array) {
@@ -233,11 +233,15 @@ String _get_class_name(JNIEnv * env, jclass cls, bool* array) {
return name;
-};
+}
Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
+ if (obj == NULL) {
+ return Variant();
+ }
+
jclass c = env->GetObjectClass(obj);
bool array;
String name = _get_class_name(env, c, &array);
@@ -259,8 +263,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
for (int i=0; i<stringCount; i++) {
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
- const char *rawString = env->GetStringUTFChars(string, 0);
- sarr.push_back(String(rawString));
+ sarr.push_back(String::utf8(env->GetStringUTFChars(string, NULL)));
env->DeleteLocalRef(string);
}
@@ -403,7 +406,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
env->DeleteLocalRef(c);
return Variant();
-};
+}
class JNISingleton : public Object {
@@ -506,7 +509,7 @@ public:
} break;
case Variant::BOOL: {
- ret = env->CallBooleanMethodA(instance,E->get().method,v);
+ ret = env->CallBooleanMethodA(instance,E->get().method,v)==JNI_TRUE;
//print_line("call bool");
} break;
case Variant::INT: {
@@ -521,8 +524,7 @@ public:
case Variant::STRING: {
jobject o = env->CallObjectMethodA(instance,E->get().method,v);
- String str = env->GetStringUTFChars((jstring)o, NULL );
- ret=str;
+ ret = String::utf8(env->GetStringUTFChars((jstring)o, NULL));
env->DeleteLocalRef(o);
} break;
case Variant::STRING_ARRAY: {
@@ -650,6 +652,8 @@ static bool resized_reload=false;
static bool quit_request=false;
static Size2 new_size;
static Vector3 accelerometer;
+static Vector3 magnetometer;
+static Vector3 gyroscope;
static HashMap<String,JNISingleton*> jni_singletons;
static jobject godot_io;
@@ -664,6 +668,7 @@ static jmethodID _openURI=0;
static jmethodID _getDataDir=0;
static jmethodID _getLocale=0;
static jmethodID _getModel=0;
+static jmethodID _getScreenDPI=0;
static jmethodID _showKeyboard=0;
static jmethodID _hideKeyboard=0;
static jmethodID _setScreenOrientation=0;
@@ -708,6 +713,12 @@ static String _get_model() {
return String(env->GetStringUTFChars( s, NULL ));
}
+static int _get_screen_dpi() {
+
+ JNIEnv *env = ThreadAndroid::get_env();
+ return env->CallIntMethod(godot_io,_getScreenDPI);
+}
+
static String _get_unique_id() {
JNIEnv *env = ThreadAndroid::get_env();
@@ -720,27 +731,27 @@ static void _show_vk(const String& p_existing) {
JNIEnv* env = ThreadAndroid::get_env();
jstring jStr = env->NewStringUTF(p_existing.utf8().get_data());
env->CallVoidMethod(godot_io, _showKeyboard, jStr);
-};
+}
static void _set_screen_orient(int p_orient) {
JNIEnv* env = ThreadAndroid::get_env();
env->CallVoidMethod(godot_io, _setScreenOrientation, p_orient );
-};
+}
static String _get_system_dir(int p_dir) {
JNIEnv *env = ThreadAndroid::get_env();
jstring s =(jstring)env->CallObjectMethod(godot_io,_getSystemDir,p_dir);
return String(env->GetStringUTFChars( s, NULL ));
-};
+}
static void _hide_vk() {
JNIEnv* env = ThreadAndroid::get_env();
env->CallVoidMethod(godot_io, _hideKeyboard);
-};
+}
// virtual Error native_video_play(String p_path);
// virtual bool native_video_is_playing();
@@ -817,6 +828,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e
_getDataDir = env->GetMethodID(c,"getDataDir","()Ljava/lang/String;");
_getLocale = env->GetMethodID(c,"getLocale","()Ljava/lang/String;");
_getModel = env->GetMethodID(c,"getModel","()Ljava/lang/String;");
+ _getScreenDPI = env->GetMethodID(c, "getScreenDPI","()I");
_getUniqueID = env->GetMethodID(c,"getUniqueID","()Ljava/lang/String;");
_showKeyboard = env->GetMethodID(c,"showKeyboard","(Ljava/lang/String;)V");
_hideKeyboard = env->GetMethodID(c,"hideKeyboard","()V");
@@ -871,7 +883,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv * e
__android_log_print(ANDROID_LOG_INFO,"godot","CMDLINE LEN %i - APK EXPANSION %I\n",cmdlen,int(use_apk_expansion));
- os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, use_apk_expansion);
+ os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, use_apk_expansion);
os_android->set_need_reload_hooks(p_need_reload_hook);
char wd[500];
@@ -941,7 +953,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv * e
os_android->reload_gfx();
}
-
}
@@ -956,7 +967,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_quit(JNIEnv * env, jo
static void _initialize_java_modules() {
-
String modules = Globals::get_singleton()->get("android/modules");
Vector<String> mods = modules.split(",",false);
print_line("ANDROID MODULES : " + modules);
@@ -1088,6 +1098,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv * env, jo
os_android->process_accelerometer(accelerometer);
+ os_android->process_magnetometer(magnetometer);
+
+ os_android->process_gyroscope(gyroscope);
+
if (os_android->main_loop_iterate()==true) {
jclass cls = env->FindClass("org/godotengine/godot/Godot");
@@ -1401,7 +1415,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv * en
input_mutex->lock();
joy_events.push_back(jevent);
input_mutex->unlock();
-};
+}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env, jobject obj, jint p_device, jint p_axis, jfloat p_value) {
@@ -1414,7 +1428,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env,
input_mutex->lock();
joy_events.push_back(jevent);
input_mutex->unlock();
-};
+}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv * env, jobject obj, jint p_device, jint p_hat_x, jint p_hat_y) {
OS_Android::JoystickEvent jevent;
@@ -1477,7 +1491,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv * env, job
input_mutex->lock();
key_events.push_back(ievent);
input_mutex->unlock();
-};
+}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z) {
@@ -1488,6 +1502,22 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv
}
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z) {
+
+ input_mutex->lock();
+ magnetometer=Vector3(x,y,z);
+ input_mutex->unlock();
+
+}
+
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z) {
+
+ input_mutex->lock();
+ gyroscope=Vector3(x,y,z);
+ input_mutex->unlock();
+
+}
+
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv * env, jobject obj){
if (!suspend_mutex)
@@ -1552,7 +1582,7 @@ static Variant::Type get_jni_type(const String& p_type) {
{"[I",Variant::INT_ARRAY},
{"[B",Variant::RAW_ARRAY},
{"[F",Variant::REAL_ARRAY},
- {"[java.lang.String",Variant::STRING_ARRAY},
+ {"[Ljava.lang.String;",Variant::STRING_ARRAY},
{"org.godotengine.godot.Dictionary", Variant::DICTIONARY},
{NULL,Variant::NIL}
};
@@ -1588,7 +1618,7 @@ static const char* get_jni_sig(const String& p_type) {
{"[I","[I"},
{"[B","[B"},
{"[F","[F"},
- {"[java.lang.String","[Ljava/lang/String;"},
+ {"[Ljava.lang.String;","[Ljava/lang/String;"},
{NULL,"V"}
};
@@ -1690,7 +1720,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv * e
env->PopLocalFrame(NULL);
-};
+}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env, jobject p_obj, jint ID, jstring method, jobjectArray params) {
@@ -1725,7 +1755,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
// something
env->PopLocalFrame(NULL);
-};
+}
//Main::cleanup();
diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h
index 1d65d21251..f1c83f01e8 100644
--- a/platform/android/java_glue.h
+++ b/platform/android/java_glue.h
@@ -49,6 +49,8 @@ extern "C" {
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv * env, jobject obj, jint p_device, jboolean p_connected, jstring p_name);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_audio(JNIEnv * env, jobject obj);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z);
+ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z);
+ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv * env, jobject obj);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusout(JNIEnv * env, jobject obj);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_singleton(JNIEnv * env, jobject obj, jstring name,jobject p_object);
@@ -56,7 +58,7 @@ extern "C" {
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv * env, jobject obj, jstring path);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params);
-};
+}
#endif
diff --git a/platform/android/logo.png b/platform/android/logo.png
index a7e2c6f130..fcf684c026 100644
--- a/platform/android/logo.png
+++ b/platform/android/logo.png
Binary files differ
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 2ef28333be..4e395a6f9f 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -53,6 +53,7 @@ int OS_Android::get_video_driver_count() const {
return 1;
}
+
const char * OS_Android::get_video_driver_name(int p_driver) const {
return "GLES2";
@@ -271,17 +272,18 @@ bool OS_Android::is_mouse_grab_enabled() const {
//*sigh* technology has evolved so much since i was a kid..
return false;
}
+
Point2 OS_Android::get_mouse_pos() const {
return Point2();
}
+
int OS_Android::get_mouse_button_state() const {
return 0;
}
void OS_Android::set_window_title(const String& p_title) {
-
}
//interesting byt not yet
@@ -290,13 +292,13 @@ void OS_Android::set_window_title(const String& p_title) {
void OS_Android::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
-
}
OS::VideoMode OS_Android::get_video_mode(int p_screen) const {
return default_videomode;
}
+
void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
p_list->push_back(default_videomode);
@@ -340,6 +342,7 @@ void OS_Android::main_loop_begin() {
if (main_loop)
main_loop->init();
}
+
bool OS_Android::main_loop_iterate() {
if (!main_loop)
@@ -394,7 +397,7 @@ void OS_Android::process_event(InputEvent p_event) {
p_event.ID = last_id++;
input->parse_input_event(p_event);
-};
+}
void OS_Android::process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points) {
@@ -609,6 +612,16 @@ void OS_Android::process_accelerometer(const Vector3& p_accelerometer) {
input->set_accelerometer(p_accelerometer);
}
+void OS_Android::process_magnetometer(const Vector3& p_magnetometer) {
+
+ input->set_magnetometer(p_magnetometer);
+}
+
+void OS_Android::process_gyroscope(const Vector3& p_gyroscope) {
+
+ input->set_gyroscope(p_gyroscope);
+}
+
bool OS_Android::has_touchscreen_ui_hint() const {
return true;
@@ -617,7 +630,7 @@ bool OS_Android::has_touchscreen_ui_hint() const {
bool OS_Android::has_virtual_keyboard() const {
return true;
-};
+}
void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) {
@@ -627,7 +640,7 @@ void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2
ERR_PRINT("Virtual keyboard not available");
};
-};
+}
void OS_Android::hide_virtual_keyboard() {
@@ -638,7 +651,7 @@ void OS_Android::hide_virtual_keyboard() {
ERR_PRINT("Virtual keyboard not available");
};
-};
+}
void OS_Android::init_video_mode(int p_video_width,int p_video_height) {
@@ -674,7 +687,7 @@ Error OS_Android::shell_open(String p_uri) {
if (open_uri_func)
return open_uri_func(p_uri)?ERR_CANT_OPEN:OK;
return ERR_UNAVAILABLE;
-};
+}
String OS_Android::get_resource_dir() const {
@@ -695,6 +708,13 @@ String OS_Android::get_model_name() const {
return OS_Unix::get_model_name();
}
+int OS_Android::get_screen_dpi(int p_screen) const {
+
+ if (get_screen_dpi_func) {
+ return get_screen_dpi_func();
+ }
+ return 160;
+}
void OS_Android::set_need_reload_hooks(bool p_needs_them) {
@@ -703,16 +723,40 @@ void OS_Android::set_need_reload_hooks(bool p_needs_them) {
String OS_Android::get_data_dir() const {
- if (get_data_dir_func)
- return get_data_dir_func();
+ if (data_dir_cache!=String())
+ return data_dir_cache;
+
+ if (get_data_dir_func) {
+ String data_dir=get_data_dir_func();
+
+ //store current dir
+ char real_current_dir_name[2048];
+ getcwd(real_current_dir_name,2048);
+
+ //go to data dir
+ chdir(data_dir.utf8().get_data());
+
+ //get actual data dir, so we resolve potential symlink (Android 6.0+ seems to use symlink)
+ char data_current_dir_name[2048];
+ getcwd(data_current_dir_name,2048);
+
+ //cache by parsing utf8
+ data_dir_cache.parse_utf8(data_current_dir_name);
+
+ //restore original dir so we don't mess things up
+ chdir(real_current_dir_name);
+
+ return data_dir_cache;
+ }
+
+
return ".";
//return Globals::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir");
-};
+}
void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) {
-
if (set_screen_orientation_func)
set_screen_orientation_func(p_orientation);
}
@@ -773,8 +817,7 @@ String OS_Android::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
-OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion) {
-
+OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion) {
use_apk_expansion=p_use_apk_expansion;
default_videomode.width=800;
@@ -794,6 +837,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu
get_data_dir_func=p_get_data_dir_func;
get_locale_func=p_get_locale_func;
get_model_func=p_get_model_func;
+ get_screen_dpi_func = p_get_screen_dpi_func;
get_unique_id_func=p_get_unique_id;
get_system_dir_func=p_get_sdir_func;
@@ -813,5 +857,4 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu
OS_Android::~OS_Android() {
-
}
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index ec1f4119b4..d383fd2036 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -63,6 +63,7 @@ typedef int (*OpenURIFunc)(const String&);
typedef String (*GetDataDirFunc)();
typedef String (*GetLocaleFunc)();
typedef String (*GetModelFunc)();
+typedef int (*GetScreenDPIFunc)();
typedef String (*GetUniqueIDFunc)();
typedef void (*ShowVirtualKeyboardFunc)(const String&);
typedef void (*HideVirtualKeyboardFunc)();
@@ -123,6 +124,8 @@ private:
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
+ mutable String data_dir_cache;
+
#if 0
AudioDriverAndroid audio_driver_android;
#else
@@ -139,6 +142,7 @@ private:
GetDataDirFunc get_data_dir_func;
GetLocaleFunc get_locale_func;
GetModelFunc get_model_func;
+ GetScreenDPIFunc get_screen_dpi_func;
ShowVirtualKeyboardFunc show_virtual_keyboard_func;
HideVirtualKeyboardFunc hide_virtual_keyboard_func;
SetScreenOrientationFunc set_screen_orientation_func;
@@ -232,6 +236,7 @@ public:
virtual String get_resource_dir() const;
virtual String get_locale() const;
virtual String get_model_name() const;
+ virtual int get_screen_dpi(int p_screen=0) const;
virtual String get_unique_ID() const;
@@ -239,6 +244,8 @@ public:
void process_accelerometer(const Vector3& p_accelerometer);
+ void process_magnetometer(const Vector3& p_magnetometer);
+ void process_gyroscope(const Vector3& p_gyroscope);
void process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points);
void process_joy_event(JoystickEvent p_event);
void process_event(InputEvent p_event);
@@ -253,7 +260,7 @@ public:
virtual String get_joy_guid(int p_device) const;
void joy_connection_changed(int p_device, bool p_connected, String p_name);
- OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion);
+ OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion);
~OS_Android();
};
diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp
index 1425e23c73..73818b282f 100644
--- a/platform/android/thread_jandroid.cpp
+++ b/platform/android/thread_jandroid.cpp
@@ -29,6 +29,7 @@
#include "thread_jandroid.h"
#include "os/memory.h"
+#include "script_language.h"
Thread::ID ThreadAndroid::get_ID() const {
@@ -44,8 +45,10 @@ void *ThreadAndroid::thread_callback(void *userdata) {
ThreadAndroid *t=reinterpret_cast<ThreadAndroid*>(userdata);
setup_thread();
+ ScriptServer::thread_enter(); //scripts may need to attach a stack
t->id=(ID)pthread_self();
t->callback(t->user);
+ ScriptServer::thread_exit();
return NULL;
}
@@ -61,10 +64,12 @@ Thread* ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback,void
return tr;
}
+
Thread::ID ThreadAndroid::get_thread_ID_func_jandroid() {
return (ID)pthread_self();
}
+
void ThreadAndroid::wait_to_finish_func_jandroid(Thread* p_thread) {
ThreadAndroid *tp=static_cast<ThreadAndroid*>(p_thread);