netDB and certificates in internal storage

This commit is contained in:
unknown542a 2018-01-07 00:08:07 +03:00
parent d41fabbc9f
commit 81d7a832c0
6 changed files with 59 additions and 24 deletions

4
android/.gitignore vendored
View File

@ -6,3 +6,7 @@ local.properties
build.sh
bin
log*
.gradle*
build
assets
gradle-app.setting

View File

@ -8,17 +8,22 @@ buildscript {
}
}
task clean(type: Delete,overwrite: true) {
delete 'build'
delete 'assets'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "org.purplei2p.i2pd"
targetSdkVersion 25
minSdkVersion 14
versionCode 1
versionName "2.17.1"
versionName "2.17.2b"
}
sourceSets {
main {
@ -26,6 +31,7 @@ android {
java.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
assets.srcDirs = ['assets']
}
}
signingConfigs {
@ -45,3 +51,10 @@ android {
}
}
task zipCerts(type: Zip) {
archiveName 'certificates.zip'
destinationDir file('assets')
from (files('../contrib/certificates'))
}
preBuild.dependsOn zipCerts

View File

@ -126,12 +126,11 @@ namespace android
}
*/
static DaemonAndroidImpl daemon;
static char* argv[1]={strdup("tmp")};
/**
* returns error details if failed
* returns "ok" if daemon initialized and started okay
*/
std::string start(/*int argc, char* argv[]*/)
std::string start(int argc, char* argv[])
{
try
{
@ -139,7 +138,7 @@ namespace android
{
//Log.d(TAG"Initialising the daemon...");
bool daemonInitSuccess = daemon.init(1,argv);
bool daemonInitSuccess = daemon.init(argc,argv);
if(!daemonInitSuccess)
{
//QMessageBox::critical(0, "Error", "Daemon init failed");

View File

@ -37,7 +37,7 @@ namespace android
* returns "ok" if daemon init failed
* returns errinfo if daemon initialized and started okay
*/
std::string start();
std::string start(int argc, char* argv[]);
// stops the daemon
void stop();

View File

@ -45,7 +45,16 @@ JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon
(JNIEnv * env, jclass clazz) {
return env->NewStringUTF(i2p::android::start().c_str());
int argc=5;
static char* argv[]={
"i2pd", "--service", "--daemon",
"--conf=/sdcard/i2pd/i2pd.conf",
"--tunconf=/sdcard/i2pd/tunnels.conf",
"--datadir=/data/data/org.purplei2p.i2pd/app_data/"
};
return env->NewStringUTF(i2p::android::start(argc,argv).c_str());
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon

View File

@ -2,6 +2,13 @@ package org.purplei2p.i2pd;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Timer;
import java.util.TimerTask;
@ -58,6 +65,9 @@ public class I2PD extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//install certs every time
Decompress.unzipFromAssets(this, "certificates.zip", "/data/data/org.purplei2p.i2pd/app_data/");
textView = new TextView(this);
setContentView(textView);
DaemonSingleton.getInstance().addStateChangeListener(daemonStateUpdatedListener);