mirror of
https://github.com/GOSTSec/gostcoin
synced 2025-01-30 08:24:20 +00:00
now builds for android and runs there
This commit is contained in:
parent
c030115d30
commit
b87c8c8b4c
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<manifest package="org.purplei2p.gostcoin" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||
<manifest package="org.purplei2p.gostcoin" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.8.5.8" android:versionCode="1" android:installLocation="auto">
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.STORAGE"/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
@ -23,6 +23,10 @@ OBJECTS_DIR = build
|
||||
MOC_DIR = build
|
||||
UI_DIR = build
|
||||
|
||||
USE_IPV6=0
|
||||
USE_LEVELDB=1
|
||||
USE_ASM=1
|
||||
|
||||
android {
|
||||
message("Using Android settings")
|
||||
|
||||
@ -31,15 +35,15 @@ android {
|
||||
# change to your own Android NDK path
|
||||
NDK_PATH = /home/user/SDKS/ANDROID/NDK/android-ndk-r13b
|
||||
|
||||
# git clone https://github.com/PurpleI2P/OpenSSL-for-Android-Prebuilt.git
|
||||
# git clone https://github.com/PurpleI2P/MiniUPnP-for-Android-Prebuilt.git
|
||||
# git clone git@github.com:hypnosis-i2p/android-ifaddrs-from-android-source.git
|
||||
#boost 53, 62 are not ok
|
||||
BOOST_PATH = /home/user/S2_ATHOME/I2PDF/git/boost_1_57_0_take2/boost_1_57_0
|
||||
OPENSSL_PATH = $$MAIN_PATH/OpenSSL-for-Android-Prebuilt/openssl-1.0.2
|
||||
BOOST_PATH = $$MAIN_PATH/take3/boost_1_57_0
|
||||
#/stage/lib
|
||||
OPENSSL_PATH = $$MAIN_PATH/take3/openssl-1.0.2l
|
||||
#MINIUPNP_PATH = $$MAIN_PATH/MiniUPnP-for-Android-Prebuilt
|
||||
IFADDRS_PATH = $$MAIN_PATH/android-ifaddrs-from-android-source
|
||||
BDB_PATH = $$MAIN_PATH/bdb/db-6.0.20/build_unix
|
||||
BDB_PATH = $$MAIN_PATH/take3/db-6.0.20/build_unix
|
||||
|
||||
DEFINES += ANDROID=1
|
||||
DEFINES += __ANDROID__
|
||||
@ -50,11 +54,14 @@ android {
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/include \
|
||||
$$NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include \
|
||||
$$BOOST_PATH \
|
||||
$$OPENSSL_PATH/include \
|
||||
$$IFADDRS_PATH \
|
||||
$$BDB_PATH \
|
||||
build
|
||||
# $$NDK_PATH/platforms/android-9/arch-arm/usr/include/ \
|
||||
# $$NDK_PATH/sources/cxx-stl/stlport/stlport/ -I $NDK_PATH/sources/cxx-stl/system/include/
|
||||
|
||||
#\
|
||||
# $$MINIUPNP_PATH/miniupnp-2.0/include \
|
||||
@ -82,16 +89,16 @@ android {
|
||||
-lboost_program_options$$BOOST_POSTFIX \
|
||||
-lboost_system$$BOOST_POSTFIX \
|
||||
-lboost_thread$$BOOST_POSTFIX \
|
||||
-L$$OPENSSL_PATH/armeabi-v7a/lib/ -lcrypto -lssl
|
||||
-L$$OPENSSL_PATH -lcrypto -lssl
|
||||
#\
|
||||
# -L$$MINIUPNP_PATH/miniupnp-2.0/armeabi-v7a/lib/ -lminiupnpc
|
||||
|
||||
PRE_TARGETDEPS += $$OPENSSL_PATH/armeabi-v7a/lib/libcrypto.a \
|
||||
$$OPENSSL_PATH/armeabi-v7a/lib/libssl.a
|
||||
PRE_TARGETDEPS += $$OPENSSL_PATH/libcrypto.a \
|
||||
$$OPENSSL_PATH/libssl.a
|
||||
DEPENDPATH += $$OPENSSL_PATH/include
|
||||
|
||||
ANDROID_EXTRA_LIBS += $$OPENSSL_PATH/armeabi-v7a/lib/libcrypto_1_0_0.so \
|
||||
$$OPENSSL_PATH/armeabi-v7a/lib/libssl_1_0_0.so
|
||||
# ANDROID_EXTRA_LIBS += $$OPENSSL_PATH/armeabi-v7a/lib/libcrypto_1_0_0.so \
|
||||
# $$OPENSSL_PATH/armeabi-v7a/lib/libssl_1_0_0.so
|
||||
#\
|
||||
# $$MINIUPNP_PATH/miniupnp-2.0/armeabi-v7a/lib/libminiupnpc.so
|
||||
}
|
||||
@ -462,7 +469,7 @@ LIBS += -lz
|
||||
|
||||
android {
|
||||
CXXFLAGS += -O0 -g
|
||||
LIBS += $$NDK_PATH/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
|
||||
# LIBS += $$NDK_PATH/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
|
||||
LIBS +=$$BDB_PATH/libdb_cxx.a $$BDB_PATH/libdb.a
|
||||
}
|
||||
|
||||
@ -471,14 +478,14 @@ system($$QMAKE_LRELEASE -silent $$TRANSLATIONS)
|
||||
android {
|
||||
DISTFILES += \
|
||||
AndroidManifest.xml \
|
||||
res/values/libs.xml \
|
||||
../docs/gostwallet_android_build_instructions.txt
|
||||
res/values/libs.xml
|
||||
}
|
||||
|
||||
DISTFILES += \
|
||||
../../../S2_ATHOME/git_gostcoin/gostcoin/android/AndroidManifest.xml \
|
||||
../../../S2_ATHOME/git_gostcoin/gostcoin/android/res/values/libs.xml \
|
||||
../../../S2_ATHOME/git_gostcoin/gostcoin/android/build.gradle
|
||||
../../../S2_ATHOME/git_gostcoin/gostcoin/android/build.gradle \
|
||||
../docs/gost_android_take3.txt
|
||||
|
||||
|
||||
|
||||
|
127
docs/gost_android_take3.txt
Normal file
127
docs/gost_android_take3.txt
Normal file
@ -0,0 +1,127 @@
|
||||
ARMV7
|
||||
|
||||
export NDK_PATH=/home/user/SDKS/ANDROID/NDK/android-ndk-r13b
|
||||
export ANDROID_DEV=$NDK_PATH/platforms/android-9/arch-arm/usr
|
||||
export AR=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
|
||||
export AS=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as
|
||||
export CC=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
|
||||
export CFLAGS=--sysroot=$NDK_PATH/platforms/android-9/arch-arm/
|
||||
export CPP=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp
|
||||
export CPPFLAGS=--sysroot=$NDK_PATH/platforms/android-9/arch-arm/
|
||||
export CXX=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
|
||||
export CXXFLAGS="--sysroot=$NDK_PATH/platforms/android-9/arch-arm/ -I$NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/include -I$NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include"
|
||||
export LD=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
|
||||
export NDK_PROJECT_PATH=$NDK_PATH
|
||||
export RANLIB=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib
|
||||
export PATH=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/:$PATH
|
||||
|
||||
|
||||
2. Построение зависимостей.
|
||||
В инструкции все зависимости сохраняются в папку /path/to/libraries/take3/
|
||||
|
||||
2.1 OpenSSL
|
||||
cd /path/to/libraries/take3
|
||||
wget -t0 https://www.openssl.org/source/openssl-1.0.2l.tar.gz
|
||||
tar xzvf openssl-1.0.2l.tar.gz -C .
|
||||
cd openssl-1.0.2l
|
||||
./Configure no-shared no-dso android-armv7
|
||||
make
|
||||
|
||||
2.2 Berkeley DB
|
||||
cd /path/to/libraries/take3
|
||||
wget -t0 http://download.oracle.com/berkeley-db/db-6.0.20.tar.gz
|
||||
tar xzvf db-6.0.20.tar.gz -C .
|
||||
cd db-6.0.20/build_unix
|
||||
../dist/configure --host=arm-linux-androideabi --enable-cxx --enable-shared --disable-replication
|
||||
make
|
||||
|
||||
2.3 Boost
|
||||
-Скачайте http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.7z/download
|
||||
7z x ~/Downloads/boost_1_57_0.7z -o/path/to/libraries/take3/
|
||||
cd /path/to/libraries/take3/boost_1_57_0
|
||||
./bootstrap.sh
|
||||
|
||||
edit boost_1_57_0\project-config.jam в текстовом редакторе, удалите его содержимое, вставьте следующий текст
|
||||
|
||||
import option ;
|
||||
|
||||
using gcc : arm : arm-linux-androideabi-g++ ;
|
||||
|
||||
option.set keep-going : false ;
|
||||
|
||||
и сохраните файл
|
||||
|
||||
Вернитесь в командную строку и введите:
|
||||
|
||||
./b2 --layout=versioned --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc-arm variant=release link=static threading=multi threadapi=pthread target-os=android define=BOOST_MATH_DISABLE_FLOAT128 include=$NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/include include=$NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include include=$NDK_PATH/platforms/android-9/arch-arm/usr/include
|
||||
|
||||
После выполнения этой команды в папке /path/to/libraries/take3/boost_1_57_0/stage/lib должны появиться следующие файлы:
|
||||
libboost_atomic-gcc-mt-s-1_57.a
|
||||
libboost_chrono-gcc-mt-s-1_57.a
|
||||
libboost_filesystem-gcc-mt-s-1_57.a
|
||||
libboost_program_options-gcc-mt-s-1_57.a
|
||||
libboost_system-gcc-mt-s-1_57.a
|
||||
libboost_thread_pthread-gcc-mt-s-1_57.a
|
||||
|
||||
2.4 LevelDB
|
||||
cd git/gostcoin
|
||||
cd src/leveldb
|
||||
TARGET_OS=OS_ANDROID_CROSSCOMPILE make libleveldb.a libmemenv.a
|
||||
|
||||
3. Компиляция
|
||||
3.1 Собираем Qt.pro
|
||||
|
||||
Откройте файл android/gostcoin-qt-android.pro
|
||||
|
||||
Поправьте всё, соберите.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Изменения для Android X86
|
||||
1. Добавить путь C:\Android\android-ndk-r10d\toolchains\x86-4.9\prebuilt\linux-x86_64\bin в переменную PATH
|
||||
2. Изменить системные переменные так:
|
||||
|
||||
ANDROID_DEV /c/Android/android-ndk-r10d/platforms/android-9/arch-x86/usr
|
||||
AR /c/Android/android-ndk-r10d/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-ar
|
||||
AS /c/Android/android-ndk-r10d/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-as
|
||||
CC /c/Android/android-ndk-r10d/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-gcc
|
||||
CFLAGS --sysroot=/c/Android/android-ndk-r10d/platforms/android-9/arch-x86/
|
||||
CPP /c/Android/android-ndk-r10d/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-cpp
|
||||
CPPFLAGS --sysroot=/c/Android/android-ndk-r10d/platforms/android-9/arch-x86/
|
||||
CXX /c/Android/android-ndk-r10d/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-g++
|
||||
CXXFLAGS --sysroot=/c/Android/android-ndk-r10d/platforms/android-9/arch-x86/ -I/c/Android/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/include -I/c/Android/android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include
|
||||
LD /c/Android/android-ndk-r10d/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-ld
|
||||
NDK_PROJECT_PATH C:\Android\android-ndk-r10d
|
||||
RANLIB /c/Android/android-ndk-r10d/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-ranlib
|
||||
|
||||
3. При построении OpenSSL выполнить
|
||||
Configure no-shared no-dso android-x86
|
||||
вместо
|
||||
Configure no-shared no-dso android-armv7
|
||||
|
||||
4. При построении BerkeleyDB выполнить
|
||||
../dist/configure --host=x86-none-linux --enable-cxx --disable-shared --disable-replication
|
||||
вместо
|
||||
../dist/configure --host=arm-none-linux --enable-cxx --disable-shared --disable-replication
|
||||
|
||||
5. При построении Boost вставить
|
||||
using gcc : x86 : i686-linux-android-g++.exe ;
|
||||
вместо
|
||||
using gcc : arm : arm-linux-androideabi-g++.exe ;
|
||||
|
||||
и выполнить
|
||||
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc variant=release link=static threading=multi threadapi=pthread target-os=android define=BOOST_MATH_DISABLE_FLOAT128 include=C:\Android\android-ndk-r10d\sources\cxx-stl\gnu-libstdc++\4.9\include include=C:\Android\android-ndk-r10d\sources\cxx-stl\gnu-libstdc++\4.9\libs\x86\include include=C:\Android\android-ndk-r10d\platforms\android-9\arch-x86\usr\include
|
||||
|
||||
вместо
|
||||
|
||||
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc-arm variant=release link=static threading=multi threadapi=pthread target-os=android define=BOOST_MATH_DISABLE_FLOAT128 include=C:\Android\android-ndk-r10d\sources\cxx-stl\gnu-libstdc++\4.9\include include=C:\Android\android-ndk-r10d\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi\include include=C:\Android\android-ndk-r10d\platforms\android-9\arch-arm\usr\include
|
||||
|
||||
6. В QtCreator выбирать Android для X86 вместо Android для armeabi-v7a
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
see also: https://github.com/novacoin-project/novacoin/blob/master/doc/building%20novacoin-qt%20for%20android%20under%20Windows.txt
|
@ -1,65 +0,0 @@
|
||||
#valid ndk: r13b
|
||||
#necessary sdk: https://dl.google.com/android/repository/tools_r25.2.3-linux.zip
|
||||
#7z x tools_r25.2.3-linux.zip -o/home/user/SDKS/ANDROID/SDK25_2_3/
|
||||
#You just copy the tools folder into the SDK folder. I would also recommend and make a backup of the folder you currently have.
|
||||
|
||||
cd /path/to/libraries/
|
||||
|
||||
mkdir bdb
|
||||
cd bdb
|
||||
wget -t0 http://download.oracle.com/berkeley-db/db-6.0.20.tar.gz
|
||||
tar xvzf db-6.0.20.tar.gz
|
||||
cd db-6.0.20/build_unix
|
||||
#specify your ndk path here:
|
||||
export NDK_PATH=/home/user/SDKS/ANDROID/NDK/android-ndk-r13b
|
||||
export PATH=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/:$PATH
|
||||
export CXX=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-c++
|
||||
export CPPFLAGS="-I $NDK_PATH/platforms/android-9/arch-arm/usr/include/ -I $NDK_PATH/sources/cxx-stl/stlport/stlport/ -I $NDK_PATH/sources/cxx-stl/system/include/ --sysroot=$NDK_PATH/platforms/android-9/arch-arm/ "
|
||||
export CFLAGS="-I $NDK_PATH/platforms/android-9/arch-arm/usr/include/ --sysroot=$NDK_PATH/platforms/android-9/arch-arm/ "
|
||||
export LDFLAGS="-L$NDK_PATH/platforms/android-9/arch-arm/usr/lib/ --sysroot=$NDK_PATH/platforms/android-9/arch-arm/"
|
||||
#-I $NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/include/
|
||||
export AR=$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar
|
||||
../dist/configure --host=arm-linux-androideabi --enable-cxx --enable-shared --disable-replication
|
||||
make
|
||||
|
||||
************************
|
||||
Boost
|
||||
-Скачайте http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.7z/download
|
||||
-Распакуйте boost_1_57_0.7z куда-либо:
|
||||
|
||||
7z x ~/Downloads/boost_1_57_0.7z -o/path/to/libraries/boost_1_57_0_take2/
|
||||
|
||||
-Откройте командную строку, и выполните следующий код:
|
||||
|
||||
cd boost_1_57_0
|
||||
chmod a+x bootstrap.sh
|
||||
./bootstrap.sh
|
||||
|
||||
Не закрывайте командную строку. Откройте файл boost_1_57_0\project-config.jam в текстовом редакторе, удалите его содержимое, вставьте следующий текст:
|
||||
|
||||
import option ;
|
||||
|
||||
using gcc : arm : /home/user/SDKS/ANDROID/NDK/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ ;
|
||||
|
||||
option.set keep-going : false ;
|
||||
|
||||
и сохраните файл. Вернитесь в командную строку и введите:
|
||||
|
||||
./b2 cxxflags="-fstack-protector-all -D_FORTIFY_SOURCE=2 -std=c++11 -O0 -g" linkflags="-fstack-protector-all" --layout=versioned --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc-arm variant=release,debug link=static threading=multi threadapi=pthread target-os=android define=BOOST_MATH_DISABLE_FLOAT128 include=/home/user/SDKS/ANDROID/NDK/android-ndk-r13b/sources/cxx-stl/gnu-libstdc++/4.9/include include=/home/user/SDKS/ANDROID/NDK/android-ndk-r13b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include include=/home/user/SDKS/ANDROID/NDK/android-ndk-r13b/platforms/android-9/arch-arm/usr/include
|
||||
|
||||
see also: http://stackoverflow.com/a/19470480/529442
|
||||
|
||||
********************************
|
||||
|
||||
LevelDB
|
||||
cd gostcoin/src/leveldb
|
||||
export OPT="-I $NDK_PATH/platforms/android-9/arch-arm/usr/include/ -I $NDK_PATH/sources/cxx-stl/stlport/stlport/ -I $NDK_PATH/sources/cxx-stl/system/include/ --sysroot=$NDK_PATH/platforms/android-9/arch-arm/ "
|
||||
TARGET_OS=OS_ANDROID_CROSSCOMPILE make libleveldb.a libmemenv.a
|
||||
|
||||
********************************
|
||||
|
||||
Откройте gostcoin/android/gostcoin-qt-android.pro в Qt Creator из комплекта Qt 5.x
|
||||
|
||||
********************************
|
||||
|
||||
see also: https://github.com/novacoin-project/novacoin/blob/master/doc/building%20novacoin-qt%20for%20android%20under%20Windows.txt#L102
|
@ -11,6 +11,7 @@
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
|
||||
#include "bitcoingui.h"
|
||||
#include "clientmodel.h"
|
||||
@ -25,6 +26,13 @@
|
||||
#include "splashscreen.h"
|
||||
#include "setupdarknet.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
//for setenv("QT_USE_ANDROID_NATIVE_DIALOGS", GOSTCOIN_NO_NATIVE_ANDROID_DIALOGS, GOSTCOIN_SETENV_OVERWRITE);
|
||||
# include <stdlib.h>
|
||||
# define GOSTCOIN_NO_NATIVE_ANDROID_DIALOGS "0"
|
||||
# define GOSTCOIN_SETENV_OVERWRITE 1
|
||||
#endif
|
||||
|
||||
#include <QMessageBox>
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <QTextCodec>
|
||||
@ -171,6 +179,11 @@ int main(int argc, char *argv[])
|
||||
Q_INIT_RESOURCE(bitcoin);
|
||||
QApplication app(argc, argv);
|
||||
|
||||
#ifdef ANDROID
|
||||
//workaround for https://bugreports.qt.io/browse/QTBUG-35545
|
||||
setenv("QT_USE_ANDROID_NATIVE_DIALOGS", GOSTCOIN_NO_NATIVE_ANDROID_DIALOGS, GOSTCOIN_SETENV_OVERWRITE);
|
||||
#endif
|
||||
|
||||
// Register meta types used for QMetaObject::invokeMethod
|
||||
qRegisterMetaType< bool* >();
|
||||
|
||||
@ -377,6 +390,7 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
qDebug() << "error:" << e.what();
|
||||
handleRunawayException(&e);
|
||||
} catch (...) {
|
||||
handleRunawayException(NULL);
|
||||
|
30
src/util.cpp
30
src/util.cpp
@ -13,6 +13,12 @@
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID)
|
||||
#include <QDebug>
|
||||
#include <QtAndroidExtras/QtAndroidExtras>
|
||||
#include <QString>
|
||||
#endif
|
||||
|
||||
#include "base58.h"
|
||||
#include "util.h"
|
||||
#include "sync.h"
|
||||
@ -1073,6 +1079,30 @@ boost::filesystem::path GetDefaultDataDir()
|
||||
return GetSpecialFolderPath(CSIDL_APPDATA) / "Gostcoin";
|
||||
#else
|
||||
fs::path pathRet;
|
||||
|
||||
# if defined(ANDROID)
|
||||
QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
|
||||
QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
|
||||
QString dataAbsPath = mediaPath.toString();
|
||||
QAndroidJniEnvironment env;
|
||||
if (env->ExceptionCheck()) {
|
||||
// Handle exception here.
|
||||
env->ExceptionClear();
|
||||
}
|
||||
std::string ext = dataAbsPath.toStdString();
|
||||
//if (!ext) ext = "/sdcard";
|
||||
if (boost::filesystem::exists(ext))
|
||||
{
|
||||
fs::path canonical = fs::canonical(fs::path(std::string (ext)));
|
||||
pathRet = fs::path(std::string(canonical.c_str()) + "/gostcoin");
|
||||
qDebug()<<"creating dir" << pathRet.c_str();
|
||||
boost::filesystem::path dir=pathRet;
|
||||
boost::filesystem::create_directory(dir);
|
||||
return pathRet;
|
||||
}
|
||||
// otherwise use /data/.../files
|
||||
# endif
|
||||
|
||||
char* pszHome = getenv("HOME");
|
||||
if (pszHome == NULL || strlen(pszHome) == 0)
|
||||
pathRet = fs::path("/");
|
||||
|
Loading…
x
Reference in New Issue
Block a user