diff --git a/demo/addons/godot_ultraleap_plugin/godot_ultraleap_plugin.gdextension b/demo/addons/godot_ultraleap_plugin/godot_ultraleap_plugin.gdextension index b269492..99a5d53 100644 --- a/demo/addons/godot_ultraleap_plugin/godot_ultraleap_plugin.gdextension +++ b/demo/addons/godot_ultraleap_plugin/godot_ultraleap_plugin.gdextension @@ -12,4 +12,10 @@ windows.release.x86_64 = "bin/libgdultraleap.windows.template_release.x86_64.dll linux.debug.x86_64 = "bin/libgdultraleap.linux.template_debug.x86_64.so" linux.release.x86_64 = "bin/libgdultraleap.linux.template_release.x86_64.so" android.debug.arm64 = "bin/libgdultraleap.android.template_debug.arm64.so" -android.release.arm64 = "bin/libgdultraleap.android.template_release.arm64.so" \ No newline at end of file +android.release.arm64 = "bin/libgdultraleap.android.template_release.arm64.so" + +[dependencies] + +android.debug.arm64 = { + "bin/libLeapC.so": "" +} \ No newline at end of file diff --git a/demo/export_presets.cfg b/demo/export_presets.cfg index e29631e..3f336f9 100644 --- a/demo/export_presets.cfg +++ b/demo/export_presets.cfg @@ -90,7 +90,7 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="" +export_path="build/UltraleapPluginDemo.Debug.apk" encryption_include_filters="" encryption_exclude_filters="" encrypt_pck=false @@ -102,8 +102,9 @@ custom_template/debug="" custom_template/release="" gradle_build/use_gradle_build=true gradle_build/export_format=0 -gradle_build/min_sdk="" +gradle_build/min_sdk="29" gradle_build/target_sdk="" +plugins/UltraleapBinder=true architectures/armeabi-v7a=false architectures/arm64-v8a=true architectures/x86=false @@ -140,7 +141,7 @@ permissions/access_coarse_location=false permissions/access_fine_location=false permissions/access_location_extra_commands=false permissions/access_mock_location=false -permissions/access_network_state=false +permissions/access_network_state=true permissions/access_surface_flinger=false permissions/access_wifi_state=false permissions/account_manager=false @@ -201,7 +202,7 @@ permissions/install_location_provider=false permissions/install_packages=false permissions/install_shortcut=false permissions/internal_system_window=false -permissions/internet=false +permissions/internet=true permissions/kill_background_processes=false permissions/location_hardware=false permissions/manage_accounts=false diff --git a/src/binder.cpp b/src/binder.cpp deleted file mode 100644 index bfd9e97..0000000 --- a/src/binder.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "binder.h" - -#ifdef ANDROID_ENABLED -#include - -Binder::Binder(JNIEnv *env) { - class_binder = env->FindClass("com/ultraleap/tracking/service_binder/ServiceBinder"); - - // Really not sure here - jmethodID constructor = env->GetMethodID(class_binder, "", "(Landroid/content/Context;Z)V"); - binder_object = env->NewObject(class_binder, constructor, get_global_context(env), false); - bind_method = env->GetMethodID(class_binder, "bind", "()Z"); - unbind_method = env->GetMethodID(class_binder, "unbind", "()V"); - is_bound_method = env->GetMethodID(class_binder, "isBound", "()I"); -} - -jobject Binder::get_global_context(JNIEnv *env) { - jclass activityThread = env->FindClass("android/app/ActivityThread"); - jmethodID currentActivityThread = env->GetStaticMethodID(activityThread, "currentActivityThread", "()Landroid/app/ActivityThread;"); - jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread); - - jmethodID getApplication = env->GetMethodID(activityThread, "getApplication", "()Landroid/app/Application;"); - jobject context = env->CallObjectMethod(at, getApplication); - return context; -} - -void Binder::bind(JNIEnv *env) { - jobject status = env->CallObjectMethod(binder_object, bind_method); -} - -#endif \ No newline at end of file diff --git a/src/binder.h b/src/binder.h deleted file mode 100644 index 79f4a40..0000000 --- a/src/binder.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef BINDER_HPP -#define BINDER_HPP - -#ifdef ANDROID_ENABLED -#include - -class Binder { -private: - jclass class_binder; - jobject binder_object; - - jmethodID bind_method; - jmethodID unbind_method; - jmethodID is_bound_method; - - static jobject get_global_context(JNIEnv *env); -public: - Binder(JNIEnv* env); - ~Binder() {} - - void bind(JNIEnv *env); -}; - -#endif - -#endif \ No newline at end of file diff --git a/src/ultraleap.cpp b/src/ultraleap.cpp index a34d770..fcbbade 100644 --- a/src/ultraleap.cpp +++ b/src/ultraleap.cpp @@ -17,8 +17,10 @@ #include "allocator.h" #ifdef ANDROID_ENABLED -#include -#include "binder.h" +#include + +#define LOG_TAG "ultraleap.cpp" +#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) #endif using namespace godot; @@ -225,17 +227,14 @@ void UltraleapHandTracking::start() { UtilityFunctions::print("Starting the tracking"); #ifdef ANDROID_ENABLED - // Acquire a pointer to the current JavaVM - jsize jvmBufferLength = 1; // At most vmBufLength number of entries ill be written for the list of returned JavaVMs - jsize jvmTotalNumberFound = 0; // The total number of JavaVMs found - JavaVM jvmBuffer[jvmBufferLength]; // Array of JavaVMs - JavaVM * pjvmBuffer = jvmBuffer; // Pointer to array of JavaVMs - jint result = JNI_GetCreatedJavaVMs(&pjvmBuffer, jvmBufferLength, &jvmTotalNumberFound); // Get all created JavaVMs - - JNIEnv *env; - pjvmBuffer->AttachCurrentThread(&env, 0); - Binder* service_binder = new Binder(env); - service_binder->bind(env); + if (Engine::get_singleton()->has_singleton("UltraleapBinder")) { + ALOGI("We'll try to use the binder"); + Object* binder = Engine::get_singleton()->get_singleton("UltraleapBinder"); + binder->call("Bind"); + while (!binder->call("IsBound")) { + ALOGI("Not bound yet"); + } + } #endif LEAP_CONNECTION_CONFIG config;