fixed android example project
This commit is contained in:
@@ -2,12 +2,19 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.joseph.example_app">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package SDK;
|
||||
package ZeroTier;
|
||||
public class SDK {
|
||||
public native void startOneService();
|
||||
static { System.loadLibrary("ZeroTierOneJNI"); } // Loads JNI code
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Binary file not shown.
@@ -129,19 +129,25 @@ 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";
|
||||
@@ -171,6 +177,8 @@ extern "C" {
|
||||
return NULL;
|
||||
#endif
|
||||
} else {
|
||||
LOGV("constructing path...\n");
|
||||
|
||||
std::vector<std::string> 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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user