Browse Source

move submodules, delete jni, remove ndkBuild from gradle

Signed-off-by: r4sas <r4sas@i2pmail.org>
pull/82/head
R4SAS 4 months ago
parent
commit
734693ba94
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 17
      .github/workflows/android.yml
  2. 10
      .gitmodules
  3. 17
      app/build.gradle
  4. 80
      app/jni/Android.mk
  5. 23
      app/jni/Application.mk
  6. 138
      app/jni/DaemonAndroid.cpp
  7. 53
      app/jni/DaemonAndroid.h
  8. 1
      app/jni/android-ifaddrs
  9. 1
      app/jni/boost
  10. 80
      app/jni/build_boost.sh
  11. 92
      app/jni/build_miniupnpc.sh
  12. 93
      app/jni/build_openssl.sh
  13. 1
      app/jni/i2pd
  14. 141
      app/jni/i2pd_android.cpp
  15. 1
      app/jni/miniupnp
  16. 1
      app/jni/openssl
  17. 73
      app/jni/org_purplei2p_i2pd_I2PD_JNI.h
  18. 2
      app/src/main/assets/certificates
  19. 1
      binary/jni/android-ifaddrs
  20. 1
      binary/jni/android-ifaddrs
  21. 1
      binary/jni/boost
  22. 1
      binary/jni/boost
  23. 1
      binary/jni/build_boost.sh
  24. 80
      binary/jni/build_boost.sh
  25. 1
      binary/jni/build_miniupnpc.sh
  26. 92
      binary/jni/build_miniupnpc.sh
  27. 1
      binary/jni/build_openssl.sh
  28. 93
      binary/jni/build_openssl.sh
  29. 1
      binary/jni/i2pd
  30. 1
      binary/jni/i2pd
  31. 1
      binary/jni/miniupnp
  32. 1
      binary/jni/miniupnp
  33. 1
      binary/jni/openssl
  34. 1
      binary/jni/openssl
  35. 1
      gradle.properties

17
.github/workflows/android.yml

@ -20,10 +20,8 @@ jobs:
- name: Build required modules - name: Build required modules
run: | run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313 export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313
pushd app/jni pushd binary/jni
./build_boost.sh ./build.sh -md
./build_openssl.sh
./build_miniupnpc.sh
popd popd
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew --no-daemon assembleDebug run: ./gradlew --no-daemon assembleDebug
@ -47,18 +45,11 @@ jobs:
run: export JAVA_HOME=$JAVA_HOME_11_X64 run: export JAVA_HOME=$JAVA_HOME_11_X64
- name: Install required Android SDK packages - name: Install required Android SDK packages
run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "cmake;3.22.1" "ndk;23.2.8568313" run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "cmake;3.22.1" "ndk;23.2.8568313"
- name: Build required modules
run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313
pushd binary/jni
./build_boost.sh
./build_openssl.sh
./build_miniupnpc.sh
popd
- name: Build binaries with NDK - name: Build binaries with NDK
run: | run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.2.8568313
pushd binary/jni pushd binary/jni
$ANDROID_NDK_HOME/ndk-build -j2 NDK_MODULE_PATH=$PWD ./build.sh
popd popd
- name: Create package with built binaries - name: Create package with built binaries
run: | run: |

10
.gitmodules vendored

@ -1,16 +1,16 @@
[submodule "android-ifaddrs"] [submodule "android-ifaddrs"]
path = app/jni/android-ifaddrs path = binary/jni/android-ifaddrs
url = https://github.com/PurpleI2P/android-ifaddrs.git url = https://github.com/PurpleI2P/android-ifaddrs.git
[submodule "i2pd"] [submodule "i2pd"]
path = app/jni/i2pd path = binary/jni/i2pd
url = https://github.com/PurpleI2P/i2pd.git url = https://github.com/PurpleI2P/i2pd.git
branch = openssl branch = openssl
[submodule "miniupnp"] [submodule "miniupnp"]
path = app/jni/miniupnp path = binary/jni/miniupnp
url = https://github.com/miniupnp/miniupnp.git url = https://github.com/miniupnp/miniupnp.git
[submodule "openssl"] [submodule "openssl"]
path = app/jni/openssl path = binary/jni/openssl
url = https://github.com/openssl/openssl.git url = https://github.com/openssl/openssl.git
[submodule "boost"] [submodule "boost"]
path = app/jni/boost path = binary/jni/boost
url = https://github.com/moritz-wundke/Boost-for-Android.git url = https://github.com/moritz-wundke/Boost-for-Android.git

17
app/build.gradle

@ -29,8 +29,8 @@ android {
targetSdkVersion 33 targetSdkVersion 33
// TODO: 24? // TODO: 24?
minSdkVersion 16 minSdkVersion 16
versionCode 2520000 versionCode 2530000
versionName "2.52.0" versionName "2.53.0"
archivesBaseName += "-$versionName" archivesBaseName += "-$versionName"
ndkVersion "23.2.8568313" ndkVersion "23.2.8568313"
@ -40,13 +40,6 @@ android {
abiFilters "arm64-v8a" abiFilters "arm64-v8a"
abiFilters "x86_64" abiFilters "x86_64"
} }
externalNativeBuild {
ndkBuild {
arguments "NDK_MODULE_PATH:=${rootProject.projectDir}/binary/jni"
arguments "-j${Runtime.getRuntime().availableProcessors()}"
}
}
} }
splits { splits {
@ -78,12 +71,6 @@ android {
} }
} }
externalNativeBuild {
ndkBuild {
path "${rootProject.projectDir}/binary/jni/Android.mk"
}
}
sourceSets { sourceSets {
main { main {
jniLibs.srcDir file("${rootProject.projectDir}/binary/libs") jniLibs.srcDir file("${rootProject.projectDir}/binary/libs")

80
app/jni/Android.mk

@ -1,80 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := i2pd
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_C_INCLUDES += $(IFADDRS_PATH) $(LIB_SRC_PATH) $(LIB_CLIENT_SRC_PATH) $(LANG_SRC_PATH) $(DAEMON_SRC_PATH)
LOCAL_STATIC_LIBRARIES := \
boost_system \
boost_date_time \
boost_filesystem \
boost_program_options \
crypto \
ssl \
miniupnpc
LOCAL_LDLIBS := -lz
LOCAL_SRC_FILES := \
DaemonAndroid.cpp \
i2pd_android.cpp \
$(IFADDRS_PATH)/ifaddrs.cpp \
$(IFADDRS_PATH)/bionic_netlink.cpp \
$(wildcard $(LIB_SRC_PATH)/*.cpp) \
$(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp) \
$(wildcard $(LANG_SRC_PATH)/*.cpp) \
$(DAEMON_SRC_PATH)/Daemon.cpp \
$(DAEMON_SRC_PATH)/UPnP.cpp \
$(DAEMON_SRC_PATH)/HTTPServer.cpp \
$(DAEMON_SRC_PATH)/I2PControl.cpp \
$(DAEMON_SRC_PATH)/I2PControlHandlers.cpp
include $(BUILD_SHARED_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := boost_system
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_system.a
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := boost_date_time
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_date_time.a
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := boost_filesystem
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_filesystem.a
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := boost_program_options
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_program_options.a
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := crypto
LOCAL_SRC_FILES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/lib/libcrypto.a
LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ssl
LOCAL_SRC_FILES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/lib/libssl.a
LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/include
LOCAL_STATIC_LIBRARIES := crypto
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := miniupnpc
LOCAL_SRC_FILES := $(MINIUPNP_PATH)/miniupnpc/out/$(TARGET_ARCH_ABI)/lib/libminiupnpc.a
LOCAL_EXPORT_C_INCLUDES := $(MINIUPNP_PATH)/miniupnpc/out/$(TARGET_ARCH_ABI)/include
include $(PREBUILT_STATIC_LIBRARY)

23
app/jni/Application.mk

@ -1,23 +0,0 @@
NDK_TOOLCHAIN_VERSION := clang
APP_STL := c++_static
# Enable c++17 extensions in source code
APP_CPPFLAGS += -std=c++17 -fexceptions -frtti
APP_CPPFLAGS += -DANDROID -D__ANDROID__ -DUSE_UPNP -Wno-deprecated-declarations
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
APP_CPPFLAGS += -DANDROID_ARM7A
endif
IFADDRS_PATH = $(NDK_MODULE_PATH)/android-ifaddrs
BOOST_PATH = $(NDK_MODULE_PATH)/boost
MINIUPNP_PATH = $(NDK_MODULE_PATH)/miniupnp
OPENSSL_PATH = $(NDK_MODULE_PATH)/openssl
# don't change me
I2PD_SRC_PATH = $(NDK_MODULE_PATH)/i2pd
LIB_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd
LIB_CLIENT_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd_client
LANG_SRC_PATH = $(I2PD_SRC_PATH)/i18n
DAEMON_SRC_PATH = $(I2PD_SRC_PATH)/daemon

138
app/jni/DaemonAndroid.cpp

@ -1,138 +0,0 @@
/*
* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
* See full license text in LICENSE file at top of project tree
*/
#include <iostream>
#include <chrono>
#include <thread>
#include <exception>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/exception_ptr.hpp>
//#include "mainwindow.h"
#include "FS.h"
#include "DaemonAndroid.h"
#include "Daemon.h"
#include "I18N.h"
namespace i2p
{
namespace android
{
std::string dataDir = "";
std::string language = "";
DaemonAndroidImpl::DaemonAndroidImpl ()
{
}
DaemonAndroidImpl::~DaemonAndroidImpl ()
{
}
bool DaemonAndroidImpl::init(int argc, char* argv[])
{
return Daemon.init(argc, argv);
}
void DaemonAndroidImpl::start()
{
Daemon.start();
}
void DaemonAndroidImpl::stop()
{
Daemon.stop();
}
void DaemonAndroidImpl::restart()
{
stop();
start();
}
void DaemonAndroidImpl::setDataDir(std::string path)
{
Daemon.setDataDir(path);
}
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[]*/)
{
try
{
{
// 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)
{
return "Daemon init failed";
}
// Set webconsole language from application
i2p::i18n::SetLanguage(language);
daemon.start();
}
}
catch (boost::exception& ex)
{
std::stringstream ss;
ss << boost::diagnostic_information(ex);
return ss.str();
}
catch (std::exception& ex)
{
std::stringstream ss;
ss << ex.what();
return ss.str();
}
catch(...)
{
return "unknown exception";
}
return "ok";
}
void stop()
{
daemon.stop();
}
void SetDataDir(std::string jdataDir)
{
dataDir = jdataDir;
}
std::string GetDataDir(void)
{
return dataDir;
}
void SetLanguage(std::string jlanguage)
{
language = jlanguage;
}
}
}

53
app/jni/DaemonAndroid.h

@ -1,53 +0,0 @@
/*
* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
* See full license text in LICENSE file at top of project tree
*/
#ifndef DAEMON_ANDROID_H
#define DAEMON_ANDROID_H
#include <string>
namespace i2p
{
namespace android
{
class DaemonAndroidImpl
{
public:
DaemonAndroidImpl ();
~DaemonAndroidImpl ();
/**
* @return success
*/
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 ();
void stop ();
// set datadir received from jni
void SetDataDir (std::string jdataDir);
// get datadir
std::string GetDataDir (void);
// set webconsole language
void SetLanguage (std::string jlanguage);
}
}
#endif // DAEMON_ANDROID_H

1
app/jni/android-ifaddrs

@ -1 +0,0 @@
Subproject commit f302cc7ead971d4068661d34c2f3ba06063d8ea2

1
app/jni/boost

@ -1 +0,0 @@
Subproject commit 53e6c16ea80c7dcb2683fd548e0c7a09ddffbfc1

80
app/jni/build_boost.sh

@ -1,80 +0,0 @@
#!/bin/bash
set -e
BOOST_VERSION=1.78.0
BOOST_LIBS=date_time,filesystem,program_options,system
function build_one {
echo "Configuring and building..."
CXXFLAGS="-std=c++14" \
NCPU=$(nproc) \
./build-android.sh \
--boost=$BOOST_VERSION \
--arch=$CPU \
--target-version=$API \
--with-libraries=$BOOST_LIBS \
--layout=system \
$ANDROID_NDK_HOME
}
function checkPreRequisites {
if ! [ -d "boost" ] || ! [ "$(ls -A boost)" ]; then
echo -e "\033[31mFailed! Submodule 'boost' not found!\033[0m"
echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m"
exit
fi
if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m"
exit
fi
}
function build {
for arg in "$@"; do
case "$arg" in
x86_64)
API=21
TARGET=x86_64
build_one
;;
arm64)
API=21
CPU=arm64-v8a
build_one
;;
x86)
API=16
CPU=x86
build_one
;;
arm)
API=16
CPU=armeabi-v7a
build_one
;;
all)
API=16
build_one
;;
*)
;;
esac
done
}
checkPreRequisites
cd boost
# disable verbose output
sed -i -E -e 's/d\+2/d\+0/' build-android.sh
sed -i -E -e 's/\"23\.1\"\|\"25\.0\"/\"23\.1\"\|\"23\.2\"\|\"25\.0\"/' build-android.sh
if (( $# == 0 )); then
build all
else
build $@
fi

92
app/jni/build_miniupnpc.sh

@ -1,92 +0,0 @@
#!/bin/bash
set -e
CMAKE_VERSION=3.22.1
function build_one {
mkdir -p build out/$CPU
cd build
cmake \
-G "Unix Makefiles" \
-DUPNPC_BUILD_SHARED=False \
-DUPNPC_BUILD_TESTS=False \
-DUPNPC_BUILD_SAMPLE=False \
-DANDROID_NATIVE_API_LEVEL=$API \
-DANDROID_ABI=$CPU \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_NDK=$ANDROID_NDK_HOME \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=../out/$CPU \
..
echo "Building..."
cmake --build . -- libminiupnpc-static
make install
cd ..
rm -rf build
}
function checkPreRequisites {
if ! [ -d "miniupnp" ] || ! [ "$(ls -A miniupnp)" ]; then
echo -e "\033[31mFailed! Submodule 'miniupnp' not found!\033[0m"
echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m"
exit
fi
if [ -z "$ANDROID_HOME" -a "$ANDROID_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_HOME is empty. Run 'export ANDROID_HOME=[PATH_TO_SDK]'\033[0m"
exit
fi
if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m"
exit
fi
}
function build {
for arg in "$@"; do
case "$arg" in
x86_64)
API=21
CPU=x86_64
build_one
;;
arm64)
API=21
CPU=arm64-v8a
build_one
;;
arm)
API=16
CPU=armeabi-v7a
build_one
;;
x86)
API=16
CPU=x86
build_one
;;
*)
;;
esac
done
}
checkPreRequisites
cd miniupnp/miniupnpc
rm -rf build out
# add cmake from Android SDK to PATH
PATH=$ANDROID_HOME/cmake/$CMAKE_VERSION/bin:$PATH
if (( $# == 0 )); then
build x86_64 arm64 arm x86
else
build $@
fi

93
app/jni/build_openssl.sh

@ -1,93 +0,0 @@
#!/bin/bash
set -e
HOST_OS=`uname -a`
function build_one {
mkdir -p out/$CPU
echo "Configuring OpenSSL for $CPU..."
./Configure \
--prefix="$PWD/out/$CPU" \
$TARGET \
no-shared \
no-tests \
-D__ANDROID_API__=$API \
-Wno-macro-redefined
echo "Building OpenSSL for $CPU..."
make -j $(nproc) > out/build.log
make install_sw >> out/build.log
make clean
}
function checkPreRequisites {
if ! [ -d "openssl" ] || ! [ "$(ls -A openssl)" ]; then
echo -e "\033[31mFailed! Submodule 'openssl' not found!\033[0m"
echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m"
exit
fi
if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m"
exit
fi
}
function build {
for arg in "$@"; do
case "$arg" in
x86_64)
API=21
CPU=x86_64
TARGET=android-x86_64
build_one
;;
arm64)
API=21
CPU=arm64-v8a
TARGET=android-arm64
build_one
;;
arm)
API=16
CPU=armeabi-v7a
TARGET=android-arm
build_one
;;
x86)
API=16
CPU=x86
TARGET=android-x86
build_one
;;
*)
;;
esac
done
}
checkPreRequisites
cd openssl
rm -rf out
if [[ "$HOST_OS" == *"_NT-"* ]]; then
PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin:$PATH
else
PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
fi
if [[ -f 'Makefile' ]]; then
make clean
fi
if (( $# == 0 )); then
build x86_64 arm64 arm x86
else
build $@
fi

1
app/jni/i2pd

@ -1 +0,0 @@
Subproject commit 9a6654943d9b90687fa474ba0ffbf024851d92f2

141
app/jni/i2pd_android.cpp

@ -1,141 +0,0 @@
/*
* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
* See full license text in LICENSE file at top of project tree
*/
#include <jni.h>
#include "org_purplei2p_i2pd_I2PD_JNI.h"
#include "DaemonAndroid.h"
#include "Config.h"
#include "RouterContext.h"
#include "ClientContext.h"
#include "Transports.h"
#include "Tunnel.h"
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
(JNIEnv *env, jclass clazz) {
#if defined(__arm__)
#if defined(__ARM_ARCH_7A__)
#if defined(__ARM_NEON__)
#if defined(__ARM_PCS_VFP)
#define ABI "armeabi-v7a/NEON (hard-float)"
#else
#define ABI "armeabi-v7a/NEON"
#endif
#else
#if defined(__ARM_PCS_VFP)
#define ABI "armeabi-v7a (hard-float)"
#else
#define ABI "armeabi-v7a"
#endif
#endif
#else
#define ABI "armeabi"
#endif
#elif defined(__i386__)
#define ABI "x86"
#elif defined(__x86_64__)
#define ABI "x86_64"
#elif defined(__mips64) /* mips64el-* toolchain defines __mips__ too */
#define ABI "mips64"
#elif defined(__mips__)
#define ABI "mips"
#elif defined(__aarch64__)
#define ABI "arm64-v8a"
#else
#define ABI "unknown"
#endif
return env->NewStringUTF(ABI);
}
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon
(JNIEnv *env, jclass clazz) {
return env->NewStringUTF(i2p::android::start().c_str());
}
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getDataDir
(JNIEnv *env, jclass clazz) {
return env->NewStringUTF(i2p::android::GetDataDir().c_str());
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon
(JNIEnv *env, jclass clazz) {
i2p::android::stop();
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels
(JNIEnv *env, jclass clazz) {
i2p::context.SetAcceptsTunnels (false);
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startAcceptingTunnels
(JNIEnv *env, jclass clazz) {
i2p::context.SetAcceptsTunnels (true);
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_reloadTunnelsConfigs
(JNIEnv *env, jclass clazz) {
i2p::client::context.ReloadConfig();
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
(JNIEnv *env, jclass clazz, jboolean isConnected) {
bool isConnectedBool = (bool) isConnected;
i2p::transport::transports.SetOnline (isConnectedBool);
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
(JNIEnv *env, jclass clazz, jstring jdataDir) {
auto dataDir = env->GetStringUTFChars(jdataDir, NULL);
i2p::android::SetDataDir(dataDir);
env->ReleaseStringUTFChars(jdataDir, dataDir);
}
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getTransitTunnelsCount
(JNIEnv *env, jclass clazz) {
return i2p::tunnel::tunnels.CountTransitTunnels();
}
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr
(JNIEnv *env, jclass clazz) {
std::string httpAddr; i2p::config::GetOption("http.address", httpAddr);
uint16_t httpPort; i2p::config::GetOption("http.port", httpPort);
std::string result = "http://" + httpAddr + ":" + std::to_string(httpPort) + "/";
return env->NewStringUTF(result.c_str());
}
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setLanguage
(JNIEnv *env, jclass clazz, jstring jlanguage) {
auto language = env->GetStringUTFChars(jlanguage, NULL);
i2p::android::SetLanguage(language);
env->ReleaseStringUTFChars(jlanguage, language);
}
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getHTTPProxyState
(JNIEnv *, jclass) {
return i2p::client::context.GetHttpProxy () ? true : false;
}
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSOCKSProxyState
(JNIEnv *, jclass) {
return i2p::client::context.GetSocksProxy() ? true : false;
}
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getBOBState
(JNIEnv *, jclass) {
return i2p::client::context.GetBOBCommandChannel() ? true : false;
}
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSAMState
(JNIEnv *, jclass) {
return i2p::client::context.GetSAMBridge() ? true : false;
}
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getI2CPState
(JNIEnv *, jclass) {
return i2p::client::context.GetI2CPServer() ? true : false;
}

1
app/jni/miniupnp

@ -1 +0,0 @@
Subproject commit 6576eb611b670c4841cc65095914275d6be008b2

1
app/jni/openssl

@ -1 +0,0 @@
Subproject commit e04bd3433fd84e1861bf258ea37928d9845e6a86

73
app/jni/org_purplei2p_i2pd_I2PD_JNI.h

@ -1,73 +0,0 @@
/*
* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
* See full license text in LICENSE file at top of project tree
*/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_purplei2p_i2pd_I2PD_JNI */
#ifndef _Included_org_purplei2p_i2pd_I2PD_JNI
#define _Included_org_purplei2p_i2pd_I2PD_JNI
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getABICompiledWith
(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startDaemon
(JNIEnv *, jclass);
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopDaemon
(JNIEnv *, jclass);
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_startAcceptingTunnels
(JNIEnv *, jclass);
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_stopAcceptingTunnels
(JNIEnv *, jclass);
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_reloadTunnelsConfigs
(JNIEnv *, jclass);
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setDataDir
(JNIEnv *env, jclass clazz, jstring jdataDir);
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_setLanguage
(JNIEnv *env, jclass clazz, jstring jlanguage);
JNIEXPORT jint JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getTransitTunnelsCount
(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getWebConsAddr
(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getDataDir
(JNIEnv *, jclass);
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getHTTPProxyState
(JNIEnv *, jclass);
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSOCKSProxyState
(JNIEnv *, jclass);
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getBOBState
(JNIEnv *, jclass);
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getSAMState
(JNIEnv *, jclass) ;
JNIEXPORT jboolean JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_getI2CPState
(JNIEnv *, jclass);
JNIEXPORT void JNICALL Java_org_purplei2p_i2pd_I2PD_1JNI_onNetworkStateChanged
(JNIEnv * env, jclass clazz, jboolean isConnected);
#ifdef __cplusplus
}
#endif
#endif

2
app/src/main/assets/certificates

@ -1 +1 @@
../../../jni/i2pd/contrib/certificates ../../../../binary/jni/i2pd/contrib/certificates

1
binary/jni/android-ifaddrs

@ -1 +0,0 @@
../../app/jni/android-ifaddrs

1
binary/jni/android-ifaddrs

@ -0,0 +1 @@
Subproject commit f302cc7ead971d4068661d34c2f3ba06063d8ea2

1
binary/jni/boost

@ -1 +0,0 @@
../../app/jni/boost

1
binary/jni/boost

@ -0,0 +1 @@
Subproject commit 53e6c16ea80c7dcb2683fd548e0c7a09ddffbfc1

1
binary/jni/build_boost.sh

@ -1 +0,0 @@
../../app/jni/build_boost.sh

80
binary/jni/build_boost.sh

@ -0,0 +1,80 @@
#!/bin/bash
set -e
BOOST_VERSION=1.78.0
BOOST_LIBS=date_time,filesystem,program_options,system
function build_one {
echo "Configuring and building..."
CXXFLAGS="-std=c++14" \
NCPU=$(nproc) \
./build-android.sh \
--boost=$BOOST_VERSION \
--arch=$CPU \
--target-version=$API \
--with-libraries=$BOOST_LIBS \
--layout=system \
$ANDROID_NDK_HOME
}
function checkPreRequisites {
if ! [ -d "boost" ] || ! [ "$(ls -A boost)" ]; then
echo -e "\033[31mFailed! Submodule 'boost' not found!\033[0m"
echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m"
exit
fi
if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m"
exit
fi
}
function build {
for arg in "$@"; do
case "$arg" in
x86_64)
API=21
TARGET=x86_64
build_one
;;
arm64)
API=21
CPU=arm64-v8a
build_one
;;
x86)
API=16
CPU=x86
build_one
;;
arm)
API=16
CPU=armeabi-v7a
build_one
;;
all)
API=16
build_one
;;
*)
;;
esac
done
}
checkPreRequisites
cd boost
# disable verbose output
sed -i -E -e 's/d\+2/d\+0/' build-android.sh
sed -i -E -e 's/\"23\.1\"\|\"25\.0\"/\"23\.1\"\|\"23\.2\"\|\"25\.0\"/' build-android.sh
if (( $# == 0 )); then
build all
else
build $@
fi

1
binary/jni/build_miniupnpc.sh

@ -1 +0,0 @@
../../app/jni/build_miniupnpc.sh

92
binary/jni/build_miniupnpc.sh

@ -0,0 +1,92 @@
#!/bin/bash
set -e
CMAKE_VERSION=3.22.1
function build_one {
mkdir -p build out/$CPU
cd build
cmake \
-G "Unix Makefiles" \
-DUPNPC_BUILD_SHARED=False \
-DUPNPC_BUILD_TESTS=False \
-DUPNPC_BUILD_SAMPLE=False \
-DANDROID_NATIVE_API_LEVEL=$API \
-DANDROID_ABI=$CPU \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_NDK=$ANDROID_NDK_HOME \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=../out/$CPU \
..
echo "Building..."
cmake --build . -- libminiupnpc-static
make install
cd ..
rm -rf build
}
function checkPreRequisites {
if ! [ -d "miniupnp" ] || ! [ "$(ls -A miniupnp)" ]; then
echo -e "\033[31mFailed! Submodule 'miniupnp' not found!\033[0m"
echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m"
exit
fi
if [ -z "$ANDROID_HOME" -a "$ANDROID_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_HOME is empty. Run 'export ANDROID_HOME=[PATH_TO_SDK]'\033[0m"
exit
fi
if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m"
exit
fi
}
function build {
for arg in "$@"; do
case "$arg" in
x86_64)
API=21
CPU=x86_64
build_one
;;
arm64)
API=21
CPU=arm64-v8a
build_one
;;
arm)
API=16
CPU=armeabi-v7a
build_one
;;
x86)
API=16
CPU=x86
build_one
;;
*)
;;
esac
done
}
checkPreRequisites
cd miniupnp/miniupnpc
rm -rf build out
# add cmake from Android SDK to PATH
PATH=$ANDROID_HOME/cmake/$CMAKE_VERSION/bin:$PATH
if (( $# == 0 )); then
build x86_64 arm64 arm x86
else
build $@
fi

1
binary/jni/build_openssl.sh

@ -1 +0,0 @@
../../app/jni/build_openssl.sh

93
binary/jni/build_openssl.sh

@ -0,0 +1,93 @@
#!/bin/bash
set -e
HOST_OS=`uname -a`
function build_one {
mkdir -p out/$CPU
echo "Configuring OpenSSL for $CPU..."
./Configure \
--prefix="$PWD/out/$CPU" \
$TARGET \
no-shared \
no-tests \
-D__ANDROID_API__=$API \
-Wno-macro-redefined
echo "Building OpenSSL for $CPU..."
make -j $(nproc) > out/build.log
make install_sw >> out/build.log
make clean
}
function checkPreRequisites {
if ! [ -d "openssl" ] || ! [ "$(ls -A openssl)" ]; then
echo -e "\033[31mFailed! Submodule 'openssl' not found!\033[0m"
echo -e "\033[31mTry to run: 'git submodule update --init'\033[0m"
exit
fi
if [ -z "$ANDROID_NDK_HOME" -a "$ANDROID_NDK_HOME" == "" ]; then
echo -e "\033[31mFailed! ANDROID_NDK_HOME is empty. Run 'export ANDROID_NDK_HOME=[PATH_TO_NDK]'\033[0m"
exit
fi
}
function build {
for arg in "$@"; do
case "$arg" in
x86_64)
API=21
CPU=x86_64
TARGET=android-x86_64
build_one
;;
arm64)
API=21
CPU=arm64-v8a
TARGET=android-arm64
build_one
;;
arm)
API=16
CPU=armeabi-v7a
TARGET=android-arm
build_one
;;
x86)
API=16
CPU=x86
TARGET=android-x86
build_one
;;
*)
;;
esac
done
}
checkPreRequisites
cd openssl
rm -rf out
if [[ "$HOST_OS" == *"_NT-"* ]]; then
PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/windows-x86_64/bin:$PATH
else
PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
fi
if [[ -f 'Makefile' ]]; then
make clean
fi
if (( $# == 0 )); then
build x86_64 arm64 arm x86
else
build $@
fi

1
binary/jni/i2pd

@ -1 +0,0 @@
../../app/jni/i2pd

1
binary/jni/i2pd

@ -0,0 +1 @@
Subproject commit 9a6654943d9b90687fa474ba0ffbf024851d92f2

1
binary/jni/miniupnp

@ -1 +0,0 @@
../../app/jni/miniupnp

1
binary/jni/miniupnp

@ -0,0 +1 @@
Subproject commit 6576eb611b670c4841cc65095914275d6be008b2

1
binary/jni/openssl

@ -1 +0,0 @@
../../app/jni/openssl

1
binary/jni/openssl

@ -0,0 +1 @@
Subproject commit e04bd3433fd84e1861bf258ea37928d9845e6a86

1
gradle.properties

@ -1,4 +1,3 @@
android.enableJetifier=true android.enableJetifier=true
android.useAndroidX=true android.useAndroidX=true
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Loading…
Cancel
Save