mirror of
https://github.com/PurpleI2P/i2pd-android.git
synced 2025-01-12 15:58:01 +00:00
set datadir in daemon before init
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
578a97f549
commit
4be1d99e8f
app
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 207b13dcabbd0e49b26ceddc94d30a51ecb13f52
|
||||
Subproject commit 2f10decf567a77cbb5a84fc1c7304eab91a1487f
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user