summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/build.gradle.template3
-rw-r--r--platform/android/detect.py19
-rw-r--r--platform/android/export/export.cpp28
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java7
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java15
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotView.java2
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java11
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java14
-rw-r--r--platform/android/java_glue.cpp2
-rw-r--r--platform/android/os_android.cpp43
-rw-r--r--platform/android/os_android.h2
11 files changed, 102 insertions, 44 deletions
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index 13b4d3b6c7..7269e658b4 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -15,12 +15,13 @@ allprojects {
repositories {
jcenter()
mavenCentral()
+ google()
$$GRADLE_REPOSITORY_URLS$$
}
}
dependencies {
- compile 'com.android.support:support-v4:23.+' // can be removed if minSdkVersion 16 and modify DownloadNotification.java & V14CustomNotification.java
+ compile 'com.android.support:support-v4:27.+' // can be removed if minSdkVersion 16 and modify DownloadNotification.java & V14CustomNotification.java
$$GRADLE_DEPENDENCIES$$
}
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 892b1b6a85..971368db17 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -14,10 +14,13 @@ def get_name():
def can_build():
-
return ("ANDROID_NDK_ROOT" in os.environ)
+def get_platform(platform):
+ return int(platform.split("-")[1])
+
+
def get_opts():
from SCons.Variables import BoolVariable, EnumVariable
@@ -124,6 +127,9 @@ def configure(env):
else:
env.extra_suffix = ".armv7" + env.extra_suffix
elif env["android_arch"] == "arm64v8":
+ if get_platform(env["ndk_platform"]) < 21:
+ print("WARNING: android_arch=arm64v8 is not supported by ndk_platform lower than andorid-21; setting ndk_platform=android-21")
+ env["ndk_platform"] = "android-21"
env['ARCH'] = 'arch-arm64'
target_subpath = "aarch64-linux-android-4.9"
abi_subpath = "aarch64-linux-android"
@@ -160,12 +166,13 @@ def configure(env):
elif (sys.platform.startswith('win')):
if (platform.machine().endswith('64')):
host_subpath = "windows-x86_64"
- if env["android_arch"] == "arm64v8":
- mt_link = False
else:
mt_link = False
host_subpath = "windows"
+ if env["android_arch"] == "arm64v8":
+ mt_link = False
+
compiler_path = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/" + host_subpath + "/bin"
gcc_toolchain_path = env["ANDROID_NDK_ROOT"] + "/toolchains/" + target_subpath + "/prebuilt/" + host_subpath
tools_path = gcc_toolchain_path + "/" + abi_subpath + "/bin"
@@ -199,7 +206,7 @@ def configure(env):
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"])
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath])
# For unified headers this define has to be set manually
- env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(int(env['ndk_platform'].split("-")[1]))])
+ env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(get_platform(env['ndk_platform']))])
else:
print("Using NDK deprecated headers")
env.Append(CPPFLAGS=["-isystem", lib_sysroot + "/usr/include"])
@@ -254,10 +261,10 @@ def configure(env):
env.Append(LINKFLAGS=target_opts)
env.Append(LINKFLAGS=common_opts)
- env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + '/toolchains/arm-linux-androideabi-4.9/prebuilt/' +
+ env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + '/toolchains/' + target_subpath + '/prebuilt/' +
host_subpath + '/lib/gcc/' + abi_subpath + '/4.9.x'])
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] +
- '/toolchains/arm-linux-androideabi-4.9/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib'])
+ '/toolchains/' + target_subpath + '/prebuilt/' + host_subpath + '/' + abi_subpath + '/lib'])
env.Append(CPPPATH=['#platform/android'])
env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL', '-DMPC_FIXED_POINT'])
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index b26d2a3aa4..2a61f8d873 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -552,6 +552,10 @@ class EditorExportAndroid : public EditorExportPlatform {
return OK;
}
+ static Error ignore_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
+ return OK;
+ }
+
void _fix_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_manifest, bool p_give_internet) {
// Leaving the unused types commented because looking these constants up
@@ -1504,6 +1508,10 @@ public:
cl.push_back(passwd);
}*/
+ APKExportData ed;
+ ed.ep = &ep;
+ ed.apk = unaligned_apk;
+ err = export_project_files(p_preset, ignore_apk_file, &ed, save_apk_so);
} else {
//all files
@@ -1531,17 +1539,17 @@ public:
err = export_project_files(p_preset, save_apk_file, &ed, save_apk_so);
}
+ }
- if (!err) {
- APKExportData ed;
- ed.ep = &ep;
- ed.apk = unaligned_apk;
- for (int i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) {
- String icon_path = String(p_preset->get(launcher_icons[i].option_id)).strip_edges();
- if (icon_path != "" && icon_path.ends_with(".png") && FileAccess::exists(icon_path)) {
- Vector<uint8_t> data = FileAccess::get_file_as_array(icon_path);
- store_in_apk(&ed, launcher_icons[i].export_path, data);
- }
+ if (!err) {
+ APKExportData ed;
+ ed.ep = &ep;
+ ed.apk = unaligned_apk;
+ for (int i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) {
+ String icon_path = String(p_preset->get(launcher_icons[i].option_id)).strip_edges();
+ if (icon_path != "" && icon_path.ends_with(".png") && FileAccess::exists(icon_path)) {
+ Vector<uint8_t> data = FileAccess::get_file_as_array(icon_path);
+ store_in_apk(&ed, launcher_icons[i].export_path, data);
}
}
}
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 37f25cc839..0d14211bd0 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -404,7 +404,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
new_cmdline = new String[2];
}
- new_cmdline[cll] = "--main_pack";
+ new_cmdline[cll] = "--main-pack";
new_cmdline[cll + 1] = expansion_pack_path;
command_line = new_cmdline;
}
@@ -828,7 +828,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
//@Override public boolean dispatchTouchEvent (MotionEvent event) {
public boolean gotTouchEvent(final MotionEvent event) {
- super.onTouchEvent(event);
final int evcount = event.getPointerCount();
if (evcount == 0)
return true;
@@ -842,6 +841,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
arr[i * 3 + 1] = (int)event.getX(i);
arr[i * 3 + 2] = (int)event.getY(i);
}
+ final int pointer_idx = event.getPointerId(event.getActionIndex());
//System.out.printf("gaction: %d\n",event.getAction());
final int action = event.getAction() & MotionEvent.ACTION_MASK;
@@ -862,13 +862,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
*/
} break;
case MotionEvent.ACTION_POINTER_UP: {
- final int indexPointUp = event.getActionIndex();
- final int pointer_idx = event.getPointerId(indexPointUp);
GodotLib.touch(4, pointer_idx, evcount, arr);
//System.out.printf("%d - s.up at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
case MotionEvent.ACTION_POINTER_DOWN: {
- int pointer_idx = event.getActionIndex();
GodotLib.touch(3, pointer_idx, evcount, arr);
//System.out.printf("%d - s.down at: %f,%f\n",pointer_idx, event.getX(pointer_idx),event.getY(pointer_idx));
} break;
diff --git a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
index 6b7f7a283e..d72c590378 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
@@ -67,7 +67,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
public GodotPaymentV3(Activity p_activity) {
- registerClass("GodotPayments", new String[] { "purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume", "querySkuDetails" });
+ registerClass("GodotPayments", new String[] { "purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume", "querySkuDetails", "isConnected" });
activity = (Godot)p_activity;
mPaymentManager = activity.getPaymentsManager();
mPaymentManager.setBaseSingleton(this);
@@ -164,6 +164,19 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[] { receipt, signature, sku });
}
+ public void callbackDisconnected() {
+ GodotLib.calldeferred(purchaseCallbackId, "iap_disconnected", new Object[]{});
+ }
+
+ public void callbackConnected() {
+ GodotLib.calldeferred(purchaseCallbackId, "iap_connected", new Object[]{});
+ }
+
+ // true if connected, false otherwise
+ public boolean isConnected() {
+ return mPaymentManager.isConnected();
+ }
+
// consume item automatically after purchase. default is true.
public void setAutoConsume(boolean autoConsume) {
mPaymentManager.setAutoConsume(autoConsume);
diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java
index ca4895a2be..0222758c2b 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotView.java
@@ -110,7 +110,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
@Override
public boolean onTouchEvent(MotionEvent event) {
-
+ super.onTouchEvent(event);
return activity.gotTouchEvent(event);
};
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 1102ab7450..5d13f17ffb 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
@@ -103,13 +103,16 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene
public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) {
//Log.d(TAG, "onTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",before: " + before);
+ final int[] newChars = new int[count];
+ for (int i = start; i < start + count; ++i) {
+ newChars[i - start] = pCharSequence.charAt(i);
+ }
mView.queueEvent(new Runnable() {
@Override
public void run() {
- for (int i = start; i < start + count; ++i) {
- final int ch = pCharSequence.charAt(i);
- GodotLib.key(0, ch, true);
- GodotLib.key(0, ch, false);
+ for (int i = 0; i < count; ++i) {
+ GodotLib.key(0, newChars[i], true);
+ GodotLib.key(0, newChars[i], false);
}
}
});
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 da6d66ae88..441a311358 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
@@ -93,11 +93,21 @@ public class PaymentsManager {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
+
+ // At this stage, godotPaymentV3 might not have been initialized yet.
+ if (godotPaymentV3 != null) {
+ godotPaymentV3.callbackDisconnected();
+ }
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
+
+ // At this stage, godotPaymentV3 might not have been initialized yet.
+ if (godotPaymentV3 != null) {
+ godotPaymentV3.callbackConnected();
+ }
}
};
@@ -123,6 +133,10 @@ public class PaymentsManager {
.purchase(sku, transactionId);
}
+ public boolean isConnected() {
+ return mService != null;
+ }
+
public void consumeUnconsumedPurchases() {
new ReleaseAllConsumablesTask(mService, activity) {
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 4e9e4f6260..2d81d79bf1 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -926,7 +926,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jo
} else {
//__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString);
- if (strcmp(rawString, "-main_pack") == 0)
+ if (strcmp(rawString, "--main-pack") == 0)
use_apk_expansion = true;
}
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 93272a1000..67ce796279 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -48,6 +48,8 @@
#include "file_access_jandroid.h"
#endif
+#include <dlfcn.h>
+
class AndroidLogger : public Logger {
public:
virtual void logv(const char *p_format, va_list p_list, bool p_err) {
@@ -173,6 +175,15 @@ void OS_Android::alert(const String &p_alert, const String &p_title) {
alert_func(p_alert, p_title);
}
+Error OS_Android::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
+ p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW);
+ if (!p_library_handle) {
+ ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror());
+ ERR_FAIL_V(ERR_CANT_OPEN);
+ }
+ return OK;
+}
+
void OS_Android::set_mouse_show(bool p_show) {
//android has no mouse...
@@ -444,25 +455,27 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
}
touch.clear();
}
-
} break;
- case 3: { // add tuchi
+ case 3: { // add touch
- ERR_FAIL_INDEX(p_pointer, p_points.size());
-
- TouchPos tp = p_points[p_pointer];
- touch.push_back(tp);
+ for (int i = 0; i < p_points.size(); i++) {
+ if (p_points[i].id == p_pointer) {
+ TouchPos tp = p_points[i];
+ touch.push_back(tp);
- Ref<InputEventScreenTouch> ev;
- ev.instance();
+ Ref<InputEventScreenTouch> ev;
+ ev.instance();
- ev->set_index(tp.id);
- ev->set_pressed(true);
- ev->set_position(tp.pos);
- input->parse_input_event(ev);
+ ev->set_index(tp.id);
+ ev->set_pressed(true);
+ ev->set_position(tp.pos);
+ input->parse_input_event(ev);
+ break;
+ }
+ }
} break;
- case 4: {
+ case 4: { // remove touch
for (int i = 0; i < touch.size(); i++) {
if (touch[i].id == p_pointer) {
@@ -474,10 +487,10 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
ev->set_position(touch[i].pos);
input->parse_input_event(ev);
touch.remove(i);
- i--;
+
+ break;
}
}
-
} break;
}
}
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 7ace7b5200..12181b3688 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -159,6 +159,8 @@ public:
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
+ virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
+
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;