Browse Source

netDB and certificates in internal storage

pull/1064/head^2
unknown542a 7 years ago
parent
commit
81d7a832c0
  1. 4
      android/.gitignore
  2. 17
      android/build.gradle
  3. 5
      android/jni/DaemonAndroid.cpp
  4. 2
      android/jni/DaemonAndroid.h
  5. 11
      android/jni/i2pd_android.cpp
  6. 10
      android/src/org/purplei2p/i2pd/I2PD.java

4
android/.gitignore vendored

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

17
android/build.gradle

@ -8,17 +8,22 @@ buildscript { @@ -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 { @@ -26,6 +31,7 @@ android {
java.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
assets.srcDirs = ['assets']
}
}
signingConfigs {
@ -45,3 +51,10 @@ android { @@ -45,3 +51,10 @@ android {
}
}
task zipCerts(type: Zip) {
archiveName 'certificates.zip'
destinationDir file('assets')
from (files('../contrib/certificates'))
}
preBuild.dependsOn zipCerts

5
android/jni/DaemonAndroid.cpp

@ -126,12 +126,11 @@ namespace android @@ -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 @@ -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");

2
android/jni/DaemonAndroid.h

@ -37,7 +37,7 @@ namespace android @@ -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();

11
android/jni/i2pd_android.cpp

@ -45,7 +45,16 @@ JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith @@ -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

10
android/src/org/purplei2p/i2pd/I2PD.java

@ -2,6 +2,13 @@ package org.purplei2p.i2pd; @@ -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 { @@ -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);

Loading…
Cancel
Save