Browse Source

netDB and certificates in internal storage

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

6
android/.gitignore vendored

@ -5,4 +5,8 @@ ant.properties @@ -5,4 +5,8 @@ ant.properties
local.properties
build.sh
bin
log*
log*
.gradle*
build
assets
gradle-app.setting

47
android/build.gradle

@ -8,26 +8,32 @@ buildscript { @@ -8,26 +8,32 @@ buildscript {
}
}
task clean(type: Delete,overwrite: true) {
delete 'build'
delete 'assets'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "org.purplei2p.i2pd"
targetSdkVersion 25
minSdkVersion 14
versionCode 1
versionName "2.17.1"
}
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "org.purplei2p.i2pd"
targetSdkVersion 25
minSdkVersion 14
versionCode 1
versionName "2.17.2b"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
}
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
assets.srcDirs = ['assets']
}
}
signingConfigs {
orignal {
storeFile file("i2pdapk.jks")
@ -37,11 +43,18 @@ android { @@ -37,11 +43,18 @@ android {
}
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.orignal
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
release {
minifyEnabled false
signingConfig signingConfigs.orignal
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
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

12
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;
@ -26,7 +33,7 @@ public class I2PD extends Activity { @@ -26,7 +33,7 @@ public class I2PD extends Activity {
private TextView textView;
private final DaemonSingleton daemon = DaemonSingleton.getInstance();
private DaemonSingleton.StateUpdateListener daemonStateUpdatedListener =
new DaemonSingleton.StateUpdateListener() {
@ -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