diff --git a/integrations/android/example_app/app/src/main/AndroidManifest.xml b/integrations/android/example_app/app/src/main/AndroidManifest.xml index 090b393..cd21495 100644 --- a/integrations/android/example_app/app/src/main/AndroidManifest.xml +++ b/integrations/android/example_app/app/src/main/AndroidManifest.xml @@ -2,12 +2,19 @@ + + + + + + + diff --git a/integrations/android/example_app/app/src/main/java/SDK/SDK.java b/integrations/android/example_app/app/src/main/java/ZeroTier/SDK.java similarity index 88% rename from integrations/android/example_app/app/src/main/java/SDK/SDK.java rename to integrations/android/example_app/app/src/main/java/ZeroTier/SDK.java index 2d354e6..f172041 100644 --- a/integrations/android/example_app/app/src/main/java/SDK/SDK.java +++ b/integrations/android/example_app/app/src/main/java/ZeroTier/SDK.java @@ -1,4 +1,4 @@ -package SDK; +package ZeroTier; public class SDK { public native void startOneService(); static { System.loadLibrary("ZeroTierOneJNI"); } // Loads JNI code diff --git a/integrations/android/example_app/app/src/main/java/com/example/joseph/example_app/MainActivity.java b/integrations/android/example_app/app/src/main/java/com/example/joseph/example_app/MainActivity.java index d44b559..3964d41 100644 --- a/integrations/android/example_app/app/src/main/java/com/example/joseph/example_app/MainActivity.java +++ b/integrations/android/example_app/app/src/main/java/com/example/joseph/example_app/MainActivity.java @@ -3,7 +3,7 @@ package com.example.joseph.example_app; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; -import SDK.SDK; +import ZeroTier.SDK; public class MainActivity extends AppCompatActivity { diff --git a/integrations/apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate b/integrations/apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate index 73a9465..08123fa 100644 Binary files a/integrations/apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate and b/integrations/apple/ZeroTierSDK_Apple/ZeroTierSDK_Apple.xcodeproj/project.xcworkspace/xcuserdata/Joseph.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/src/SDK_ServiceSetup.cpp b/src/SDK_ServiceSetup.cpp index 00de4be..5f39d43 100644 --- a/src/SDK_ServiceSetup.cpp +++ b/src/SDK_ServiceSetup.cpp @@ -129,20 +129,26 @@ extern "C" { * Starts a new service instance */ #if defined(__ANDROID__) - JNIEXPORT void JNICALL Java_ZeroTierSDK_startOneService(JNIEnv *env, jobject thisObj) - //JNIEXPORT void JNICALL Java_Netcon_NetconWrapper_startOneService(JNIEnv *env, jobject thisObj) + // JNI naming convention: Java_PACKAGENAME_CLASSNAME_METHODNAME + /* If you define anything else in this file it *must* follow that convention + and any corresponding Java package/classes in your Android project must match this as well */ + JNIEXPORT void JNICALL Java_ZeroTier_SDK_startOneService(JNIEnv *env, jobject thisObj) { #else void *startOneService(void *thread_id) { set_intercept_status(INTERCEPT_DISABLED); #endif + + +#if defined(__UNITY_3D__) int MAX_DIR_SZ = 256; char current_dir[MAX_DIR_SZ]; getcwd(current_dir, MAX_DIR_SZ); chdir(service_path.c_str()); zt1Service = (ZeroTier::OneService *)0; - +#endif + #if defined(__ANDROID__) homeDir = "/sdcard/zerotier"; #endif @@ -171,6 +177,8 @@ extern "C" { return NULL; #endif } else { + LOGV("constructing path...\n"); + std::vector hpsp(ZeroTier::Utils::split(homeDir.c_str(),ZT_PATH_SEPARATOR_S,"","")); std::string ptmp; if (homeDir[0] == ZT_PATH_SEPARATOR) @@ -189,7 +197,7 @@ extern "C" { } } - chdir(current_dir); // Return to previous current working directory (at the request of Unity3D) + //chdir(current_dir); // Return to previous current working directory (at the request of Unity3D) LOGV("homeDir = %s", homeDir.c_str()); //Debug(homeDir.c_str()); @@ -199,8 +207,13 @@ extern "C" { ZeroTier::Utils::getSecureRandom(&randp,sizeof(randp)); int servicePort = 9000 + (randp % 1000); + LOGV("generated port\n"); + + for(;;) { zt1Service = ZeroTier::OneService::newInstance(homeDir.c_str(),servicePort); + LOGV("created new instance\n"); + switch(zt1Service->run()) { case ZeroTier::OneService::ONE_STILL_RUNNING: // shouldn't happen, run() won't return until done case ZeroTier::OneService::ONE_NORMAL_TERMINATION: diff --git a/src/SDK_ServiceSetup.hpp b/src/SDK_ServiceSetup.hpp index df09916..49b134e 100644 --- a/src/SDK_ServiceSetup.hpp +++ b/src/SDK_ServiceSetup.hpp @@ -40,6 +40,9 @@ extern "C" { #define INTERCEPT_DISABLED 222 #if defined(__ANDROID__) + // JNI naming convention: Java_PACKAGENAME_CLASSNAME_METHODNAME + /* If you define anything else in this file it *must* follow that convention + and any corresponding Java package/classes in your Android project must match this as well */ JNIEXPORT void JNICALL Java_ZeroTier_SDK_startOneService(JNIEnv *env, jobject thisObj); #else void *startOneService(void *thread_id);