diff --git a/app/jni/DaemonAndroid.cpp b/app/jni/DaemonAndroid.cpp index c249e1e..097e694 100644 --- a/app/jni/DaemonAndroid.cpp +++ b/app/jni/DaemonAndroid.cpp @@ -35,40 +35,30 @@ namespace android bool DaemonAndroidImpl::init(int argc, char* argv[]) { - // make sure assets are ready before proceed - i2p::fs::DetectDataDir(dataDir, false); - int numAttempts = 0; - do - { - if (i2p::fs::Exists (i2p::fs::DataDirPath("assets.ready"))) break; // assets ready - numAttempts++; - std::this_thread::sleep_for (std::chrono::seconds(1)); // otherwise wait for 1 more second - } - while (numAttempts <= 10); // 10 seconds max return Daemon.init(argc, argv); } void DaemonAndroidImpl::start() { - //QMutexLocker locker(mutex); - //setRunning(true); Daemon.start(); } void DaemonAndroidImpl::stop() { - //QMutexLocker locker(mutex); Daemon.stop(); - //setRunning(false); } void DaemonAndroidImpl::restart() { - //QMutexLocker locker(mutex); stop(); start(); } + void DaemonAndroidImpl::setDataDir(std::string path) + { + Daemon.setDataDir(path); + } + static DaemonAndroidImpl daemon; static char* argv[1]={strdup("tmp")}; /** @@ -80,7 +70,20 @@ namespace android try { { - //Log.d(TAG"Initialising the daemon..."); + // make sure assets are ready before proceed + i2p::fs::DetectDataDir(dataDir, false); + int numAttempts = 0; + do + { + if (i2p::fs::Exists (i2p::fs::DataDirPath("assets.ready"))) break; // assets ready + numAttempts++; + std::this_thread::sleep_for (std::chrono::seconds(1)); // otherwise wait for 1 more second + } + while (numAttempts <= 10); // 10 seconds max + + // Set application directory + daemon.setDataDir(dataDir); + bool daemonInitSuccess = daemon.init(1, argv); if(!daemonInitSuccess) { diff --git a/app/jni/DaemonAndroid.h b/app/jni/DaemonAndroid.h index 2c1db83..6dbed75 100644 --- a/app/jni/DaemonAndroid.h +++ b/app/jni/DaemonAndroid.h @@ -25,26 +25,28 @@ namespace android /** * @return success */ - bool init(int argc, char* argv[]); - void start(); - void stop(); - void restart(); + bool init (int argc, char* argv[]); + void start (); + void stop (); + void restart (); + + void setDataDir (std::string path); }; /** * returns "ok" if daemon init failed * returns errinfo if daemon initialized and started okay */ - std::string start(); + std::string start (); - void stop(); + void stop (); // set datadir received from jni - void SetDataDir(std::string jdataDir); + void SetDataDir (std::string jdataDir); // get datadir - std::string GetDataDir(void); + std::string GetDataDir (void); // set webconsole language - void SetLanguage(std::string jlanguage); + void SetLanguage (std::string jlanguage); } } diff --git a/app/jni/i2pd b/app/jni/i2pd index 207b13d..2f10dec 160000 --- a/app/jni/i2pd +++ b/app/jni/i2pd @@ -1 +1 @@ -Subproject commit 207b13dcabbd0e49b26ceddc94d30a51ecb13f52 +Subproject commit 2f10decf567a77cbb5a84fc1c7304eab91a1487f diff --git a/app/src/main/java/org/purplei2p/i2pd/SettingsActivity.java b/app/src/main/java/org/purplei2p/i2pd/SettingsActivity.java index 61d1c06..5bc1f29 100644 --- a/app/src/main/java/org/purplei2p/i2pd/SettingsActivity.java +++ b/app/src/main/java/org/purplei2p/i2pd/SettingsActivity.java @@ -24,7 +24,7 @@ public class SettingsActivity extends Activity { //protected IniEditor iniedit = new IniEditor(); private String TAG = "i2pdSrvcSettings"; private File cacheDir; - public static String onBootFileName="/onBoot"; // just file, empty, if exist the do autostart, if not then no. + public static String onBootFileName = "/onBoot"; // just file, empty, if exist the do autostart, if not then no. //https://gist.github.com/chandruark/3165a5ee3452f2b9ec7736cf1b4c5ea6 private void addAutoStartupSwitch() { @@ -81,11 +81,10 @@ public class SettingsActivity extends Activity { Log.i(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); - Objects.requireNonNull(getActionBar()).setDisplayHomeAsUpEnabled(true); + Switch autostart_switch = findViewById(R.id.autostart_enable); cacheDir = getApplicationContext().getCacheDir(); - Switch autostart_switch = findViewById(R.id.autostart_enable); File onBoot = new File(cacheDir.getAbsolutePath() + onBootFileName); autostart_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {