Browse Source

Merge pull request #20 from hypnosis-i2p/master

now builds for android and runs there
pull/21/head
orignal 7 years ago committed by GitHub
parent
commit
caaeb2365f
  1. 3
      .gitignore
  2. 2
      android/.gitignore
  3. 75
      android/AndroidManifest.xml
  4. 57
      android/build.gradle
  5. 491
      android/gostcoin-qt-android.pro
  6. BIN
      android/gradle/wrapper/gradle-wrapper.jar
  7. 6
      android/gradle/wrapper/gradle-wrapper.properties
  8. 164
      android/gradlew
  9. 90
      android/gradlew.bat
  10. 25
      android/res/values/libs.xml
  11. 127
      docs/gost_android_take3.txt
  12. 6
      src/compat.h
  13. 6
      src/netbase.cpp
  14. 14
      src/qt/gostcoin.cpp
  15. 33
      src/util.cpp

3
.gitignore vendored

@ -13,3 +13,6 @@ gostcoind @@ -13,3 +13,6 @@ gostcoind
gostcoin-qt_plugin_import.cpp
object_script.gostcoin-qt.Debug
object_script.gostcoin-qt.Release
.project
.cproject
build*

2
android/.gitignore vendored

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
local.properties
*.pro.user*

75
android/AndroidManifest.xml

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
<?xml version="1.0"?>
<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"/>
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="GostCoin">
<!-- <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
-->
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="GostCoin" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="gostcoin-qt"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!--
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
-->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
</activity>
</application>
<!--
короче временный фикс такой - установить target api в 22
стояло 23, в апи23 появились рантайм пермиссии. и их нужно вызывать вот так:
https://forum.qt.io/topic/72497/android-6-0-sdcard-write-permission/6
https://bugreports.qt.io/browse/QTBUG-50759
если ставишь таргет апи 25 то сегфолт на create_directory(/sdcard/gostcoin)
-->
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
</manifest>

57
android/build.gradle

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}

491
android/gostcoin-qt-android.pro

@ -0,0 +1,491 @@ @@ -0,0 +1,491 @@
TEMPLATE = app
TARGET = gostcoin-qt
VERSION = 0.8.5.8
INCLUDEPATH += ../src ../src/json ../src/qt ../i2psam
QT += core gui network androidextras
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_NO_CXX11_SCOPED_ENUMS
CONFIG += no_include_pwd
CONFIG += thread
QMAKE_CXXFLAGS=-fstack-protector-strong -DANDROID -fno-builtin-memmove --sysroot=/home/user/SDKS/ANDROID/NDK/android-ndk-r13b/platforms/android-9/arch-arm/ -std=c++11
# for boost 1.37, add -mt to the boost libraries
# use: qmake BOOST_LIB_SUFFIX=-mt
# for boost thread win32 with _win32 sufix
# use: BOOST_THREAD_LIB_SUFFIX=_win32-...
# or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8
# Dependency library locations can be customized with:
# BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
# BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively
OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build
USE_IPV6=0
USE_LEVELDB=1
USE_ASM=1
android {
message("Using Android settings")
# change to your own path, where you will store all needed libraries with 'git clone' commands below.
MAIN_PATH = /path/to/libraries
# change to your own Android NDK path
NDK_PATH = /home/user/SDKS/ANDROID/NDK/android-ndk-r13b
# 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 = $$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/take3/db-6.0.20/build_unix
DEFINES += ANDROID=1
DEFINES += __ANDROID__
CONFIG += mobility
MOBILITY =
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 \
DISTFILES += AndroidManifest.xml
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/
SOURCES += $$IFADDRS_PATH/ifaddrs.cpp $$IFADDRS_PATH/bionic_netlink.cpp
HEADERS += $$IFADDRS_PATH/ifaddrs.h $$IFADDRS_PATH/ErrnoRestorer.h $$IFADDRS_PATH/bionic_netlink.h $$IFADDRS_PATH/bionic_macros.h
equals(ANDROID_TARGET_ARCH, armeabi-v7a){
DEFINES += ANDROID_ARM7A
# http://stackoverflow.com/a/30235934/529442
# LIBS += -L$$BOOST_PATH/boost_1_53_0/armeabi-v7a/lib \
# -lboost_system-gcc-mt-1_53 -lboost_atomic-gcc-mt-1_53 \
# -lboost_filesystem-gcc-mt-1_53 -lboost_chrono-gcc-mt-1_53 -lboost_thread-gcc-mt-1_53 -lboost_program_options-gcc-mt-1_53 \
# -L$$OPENSSL_PATH/armeabi-v7a/lib/ -lcrypto -lssl
#\
# -L$$MINIUPNP_PATH/miniupnp-2.0/armeabi-v7a/lib/ -lminiupnpc
BOOST_POSTFIX=-gcc-mt-1_57
LIBS += -L$$BOOST_PATH/stage/lib \
-lboost_atomic$$BOOST_POSTFIX \
-lboost_chrono$$BOOST_POSTFIX \
-lboost_filesystem$$BOOST_POSTFIX \
-lboost_program_options$$BOOST_POSTFIX \
-lboost_system$$BOOST_POSTFIX \
-lboost_thread$$BOOST_POSTFIX \
-L$$OPENSSL_PATH -lcrypto -lssl
#\
# -L$$MINIUPNP_PATH/miniupnp-2.0/armeabi-v7a/lib/ -lminiupnpc
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
#\
# $$MINIUPNP_PATH/miniupnp-2.0/armeabi-v7a/lib/libminiupnpc.so
}
equals(ANDROID_TARGET_ARCH, x86){
error("Android BDB: don't know how to build BDB for Android x86")
# http://stackoverflow.com/a/30235934/529442
LIBS += -L$$BOOST_PATH/boost_1_62_0/x86/lib \
-lboost_system-gcc-mt-1_62 -lboost_date_time-gcc-mt-1_62 \
-lboost_filesystem-gcc-mt-1_62 -lboost_program_options-gcc-mt-1_62 \
-L$$OPENSSL_PATH/openssl-1.1.0/x86/lib/ -lcrypto -lssl
#\
# -L$$MINIUPNP_PATH/miniupnp-2.0/x86/lib/ -lminiupnpc
PRE_TARGETDEPS += $$OPENSSL_PATH/openssl-1.1.0/x86/lib/libcrypto.a \
$$OPENSSL_PATH/openssl-1.1.0/x86/lib/libssl.a
DEPENDPATH += $$OPENSSL_PATH/openssl-1.1.0/include
ANDROID_EXTRA_LIBS += $$OPENSSL_PATH/openssl-1.1.0/x86/lib/libcrypto_1_0_0.so \
$$OPENSSL_PATH/openssl-1.1.0/x86/lib/libssl_1_0_0.so
#\
# $$MINIUPNP_PATH/miniupnp-2.0/x86/lib/libminiupnpc.so
}
}
!win32 {
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
# QMAKE_CXXFLAGS *= -fstack-protector-all
# QMAKE_CFLAGS *= -fstack-protector-all
# QMAKE_LFLAGS *= -fstack-protector-all
# Exclude on Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
}
# for extra security (see: https://wiki.debian.org/Hardening): this flag is GCC compiler-specific
#-D_FORTIFY_SOURCE=2
QMAKE_CXXFLAGS *= -std=c++11
# use: qmake "USE_QRCODE=1"
# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support
contains(USE_QRCODE, 1) {
message(Building with QRCode support)
DEFINES += USE_QRCODE
LIBS += -lqrencode
}
# use: qmake "USE_DBUS=1"
contains(USE_DBUS, 1) {
message(Building with DBUS (Freedesktop notifications) support)
DEFINES += USE_DBUS
QT += dbus
}
# use: qmake "USE_IPV6=1" ( enabled by default; default)
# or: qmake "USE_IPV6=0" (disabled by default)
# or: qmake "USE_IPV6=-" (not supported)
contains(USE_IPV6, -) {
message(Building without IPv6 support)
} else {
count(USE_IPV6, 0) {
USE_IPV6=1
}
DEFINES += USE_IPV6=$$USE_IPV6
}
contains(BITCOIN_NEED_QT_PLUGINS, 1) {
DEFINES += BITCOIN_NEED_QT_PLUGINS
QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
}
INCLUDEPATH += ../src/leveldb/include ../src/leveldb/helpers
LIBS += $$PWD/../src/leveldb/libleveldb.a $$PWD/../src/leveldb/libmemenv.a
!win32 {
# we use QMAKE_CXXFLAGS_RELEASE even without RELEASE=1 because we use RELEASE to indicate linking preferences not -O preferences
!android {
genleveldb.commands = echo "QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS" && cd $$PWD/../src/leveldb && TARGET_OS=OS_ANDROID_CROSSCOMPILE CC=$$QMAKE_CC CXX=$$QMAKE_CXX AR=$$NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar $(MAKE) OPT=\"-I $$NDK_PATH/platforms/android-9/arch-arm/usr/include/ -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/ $$QMAKE_CXXFLAGS \" libleveldb.a libmemenv.a
}
}
genleveldb.target = $$PWD/../src/leveldb/libleveldb.a
genleveldb.depends = FORCE
PRE_TARGETDEPS += $$PWD/../src/leveldb/libleveldb.a
QMAKE_EXTRA_TARGETS += genleveldb
# Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it.
QMAKE_CLEAN += $$PWD/../src/leveldb/libleveldb.a; cd $$PWD/../src/leveldb ; $(MAKE) clean
# regenerate ../src/build.h
#!win32|contains(USE_BUILD_INFO, 1) {
# genbuild.depends = FORCE
# genbuild.commands = cd $$PWD; /bin/sh ../share/genbuild.sh $$OUT_PWD/build/build.h
# genbuild.target = $$OUT_PWD/build/build.h
# PRE_TARGETDEPS += $$OUT_PWD/build/build.h
# QMAKE_EXTRA_TARGETS += genbuild
# DEFINES += HAVE_BUILD_INFO
#}
QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector
# Input
DEPENDPATH += ../src ../src/json ../src/qt
HEADERS += ../src/qt/bitcoingui.h \
../src/qt/transactiontablemodel.h \
../src/qt/addresstablemodel.h \
../src/qt/optionsdialog.h \
../src/qt/sendcoinsdialog.h \
../src/qt/coincontroldialog.h \
../src/qt/coincontroltreewidget.h \
../src/qt/addressbookpage.h \
../src/qt/signverifymessagedialog.h \
../src/qt/aboutdialog.h \
../src/qt/editaddressdialog.h \
../src/qt/bitcoinaddressvalidator.h \
../src/alert.h \
../src/addrman.h \
../src/base58.h \
../src/bignum.h \
../src/checkpoints.h \
../src/coincontrol.h \
../src/compat.h \
../src/sync.h \
../src/util.h \
../src/hash.h \
../src/uint256.h \
../src/serialize.h \
../src/main.h \
../src/net.h \
../src/key.h \
../src/db.h \
../src/walletdb.h \
../src/script.h \
../src/init.h \
../src/bloom.h \
../src/mruset.h \
../src/checkqueue.h \
../src/json/json_spirit_writer_template.h \
../src/json/json_spirit_writer.h \
../src/json/json_spirit_value.h \
../src/json/json_spirit_utils.h \
../src/json/json_spirit_stream_reader.h \
../src/json/json_spirit_reader_template.h \
../src/json/json_spirit_reader.h \
../src/json/json_spirit_error_position.h \
../src/json/json_spirit.h \
../i2psam/i2psam.h \
../src/qt/clientmodel.h \
../src/qt/guiutil.h \
../src/qt/transactionrecord.h \
../src/qt/guiconstants.h \
../src/qt/optionsmodel.h \
../src/qt/monitoreddatamapper.h \
../src/qt/transactiondesc.h \
../src/qt/transactiondescdialog.h \
../src/qt/bitcoinamountfield.h \
../src/wallet.h \
../src/keystore.h \
../src/qt/transactionfilterproxy.h \
../src/qt/transactionview.h \
../src/qt/walletmodel.h \
../src/qt/walletview.h \
../src/qt/walletstack.h \
../src/qt/walletframe.h \
../src/bitcoinrpc.h \
../src/qt/overviewpage.h \
../src/qt/csvmodelwriter.h \
../src/crypter.h \
../src/qt/sendcoinsentry.h \
../src/qt/qvalidatedlineedit.h \
../src/qt/bitcoinunits.h \
../src/qt/qvaluecombobox.h \
../src/qt/askpassphrasedialog.h \
../src/protocol.h \
../src/qt/notificator.h \
../src/qt/paymentserver.h \
../src/allocators.h \
../src/ui_interface.h \
../src/qt/rpcconsole.h \
../src/i2p.h \
../src/Gost.h \
../src/version.h \
../src/netbase.h \
../src/clientversion.h \
../src/txdb.h \
../src/leveldb.h \
../src/threadsafety.h \
../src/limitedmap.h \
../src/qt/macnotificationhandler.h \
../src/qt/splashscreen.h \
../src/qt/showi2paddresses.h \
../src/qt/i2poptionswidget.h \
../src/qt/setupdarknet.h
SOURCES += ../src/qt/gostcoin.cpp \
../src/qt/bitcoingui.cpp \
../src/qt/transactiontablemodel.cpp \
../src/qt/addresstablemodel.cpp \
../src/qt/optionsdialog.cpp \
../src/qt/sendcoinsdialog.cpp \
../src/qt/coincontroldialog.cpp \
../src/qt/coincontroltreewidget.cpp \
../src/qt/addressbookpage.cpp \
../src/qt/signverifymessagedialog.cpp \
../src/qt/aboutdialog.cpp \
../src/qt/editaddressdialog.cpp \
../src/qt/bitcoinaddressvalidator.cpp \
../src/alert.cpp \
../src/version.cpp \
../src/sync.cpp \
../src/util.cpp \
../src/hash.cpp \
../src/netbase.cpp \
../src/key.cpp \
../src/script.cpp \
../src/main.cpp \
../src/init.cpp \
../src/net.cpp \
../src/bloom.cpp \
../src/checkpoints.cpp \
../src/addrman.cpp \
../src/db.cpp \
../src/walletdb.cpp \
../src/qt/clientmodel.cpp \
../src/qt/guiutil.cpp \
../src/qt/transactionrecord.cpp \
../src/qt/optionsmodel.cpp \
../src/qt/monitoreddatamapper.cpp \
../src/qt/transactiondesc.cpp \
../src/qt/transactiondescdialog.cpp \
../src/qt/bitcoinstrings.cpp \
../src/qt/bitcoinamountfield.cpp \
../src/wallet.cpp \
../src/keystore.cpp \
../src/qt/transactionfilterproxy.cpp \
../src/qt/transactionview.cpp \
../src/qt/walletmodel.cpp \
../src/qt/walletview.cpp \
../src/qt/walletstack.cpp \
../src/qt/walletframe.cpp \
../src/bitcoinrpc.cpp \
../src/rpcdump.cpp \
../src/rpcnet.cpp \
../src/rpcmining.cpp \
../src/rpcwallet.cpp \
../src/rpcblockchain.cpp \
../src/rpcrawtransaction.cpp \
../src/qt/overviewpage.cpp \
../src/qt/csvmodelwriter.cpp \
../src/crypter.cpp \
../src/qt/sendcoinsentry.cpp \
../src/qt/qvalidatedlineedit.cpp \
../src/qt/bitcoinunits.cpp \
../src/qt/qvaluecombobox.cpp \
../src/qt/askpassphrasedialog.cpp \
../src/protocol.cpp \
../src/qt/notificator.cpp \
../src/qt/paymentserver.cpp \
../src/qt/rpcconsole.cpp \
../src/i2p.cpp \
../src/Gost.cpp \
../src/noui.cpp \
../src/leveldb.cpp \
../src/txdb.cpp \
../src/qt/splashscreen.cpp \
../src/qt/showi2paddresses.cpp \
../src/qt/i2poptionswidget.cpp \
../i2psam/i2psam.cpp \
../src/qt/setupdarknet.cpp
RESOURCES += ../src/qt/bitcoin.qrc
FORMS += ../src/qt/forms/sendcoinsdialog.ui \
../src/qt/forms/coincontroldialog.ui \
../src/qt/forms/addressbookpage.ui \
../src/qt/forms/signverifymessagedialog.ui \
../src/qt/forms/aboutdialog.ui \
../src/qt/forms/editaddressdialog.ui \
../src/qt/forms/transactiondescdialog.ui \
../src/qt/forms/overviewpage.ui \
../src/qt/forms/sendcoinsentry.ui \
../src/qt/forms/askpassphrasedialog.ui \
../src/qt/forms/rpcconsole.ui \
../src/qt/forms/optionsdialog.ui \
../src/qt/forms/showi2paddresses.ui \
../src/qt/forms/i2poptionswidget.ui
contains(USE_QRCODE, 1) {
HEADERS += ../src/qt/qrcodedialog.h
SOURCES += ../src/qt/qrcodedialog.cpp
FORMS += ../src/qt/forms/qrcodedialog.ui
}
contains(BITCOIN_QT_TEST, 1) {
SOURCES += ../src/qt/test/test_main.cpp \
../src/qt/test/uritests.cpp
HEADERS += ../src/qt/test/uritests.h
DEPENDPATH += ../src/qt/test
QT += testlib
TARGET = anoncoin-qt_test
DEFINES += BITCOIN_QT_TEST
macx: CONFIG -= app_bundle
}
contains(USE_SSE2, 1) {
DEFINES += USE_SSE2
gccsse2.input = SOURCES_SSE2
gccsse2.output = $$PWD/build/${QMAKE_FILE_BASE}.o
gccsse2.commands = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} -msse2 -mstackrealign
QMAKE_EXTRA_COMPILERS += gccsse2
#SOURCES_SSE2 += ../src/scrypt-sse2.cpp
}
greaterThan(QT_MAJOR_VERSION, 4): {
} else {
CODECFORTR = UTF-8
}
# for lrelease/lupdate
# also add new translations to ../src/qt/bitcoin.qrc under translations/
TRANSLATIONS = $$files(../src/qt/locale/bitcoin_*.ts)
isEmpty(QMAKE_LRELEASE) {
QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(QM_DIR):QM_DIR = $$PWD/../src/qt/locale
# automatically build translations, so they can be included in resource file
TSQM.name = lrelease ${QMAKE_FILE_IN}
TSQM.input = TRANSLATIONS
TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
TSQM.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += TSQM
# "Other files" to show in Qt Creator
OTHER_FILES += README.md \
doc/*.rst \
doc/*.txt \
doc/*.md \
../src/qt/res/bitcoin-qt.rc \
../src/test/*.cpp \
../src/test/*.h \
../src/qt/test/*.cpp \
../src/qt/test/*.h
# platform specific defaults, if not overridden on command line
isEmpty(BOOST_THREAD_LIB_SUFFIX) {
BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX
}
isEmpty(BDB_LIB_SUFFIX) {
android:BDB_LIB_SUFFIX = -6.0
}
!win32:!macx {
android {
#LIBS += $$BDB_PATH/libdb.a $$BDB_PATH/libdb_cxx.a
LIBS += -L$$BDB_PATH
}
# _FILE_OFFSET_BITS=64 lets 32-bit fopen transparently support large files.
DEFINES += _FILE_OFFSET_BITS=64
}
# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
LIBS += -lssl -lcrypto
LIBS += -lz
!win32:LIBS += -ldl
android {
CXXFLAGS += -O0 -g
# LIBS += $$NDK_PATH/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
LIBS +=$$BDB_PATH/libdb_cxx.a $$BDB_PATH/libdb.a
}
system($$QMAKE_LRELEASE -silent $$TRANSLATIONS)
android {
DISTFILES += \
AndroidManifest.xml \
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 \
../docs/gost_android_take3.txt

BIN
android/gradle/wrapper/gradle-wrapper.jar vendored

Binary file not shown.

6
android/gradle/wrapper/gradle-wrapper.properties vendored

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

164
android/gradlew vendored

@ -0,0 +1,164 @@ @@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
android/gradlew.bat vendored

@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

25
android/res/values/libs.xml

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt5/qt-5.6</item>
</array>
<!-- The following is handled automatically by the deployment tool. It should
not be edited manually. -->
<array name="bundled_libs">
<!-- %%INSERT_EXTRA_LIBS%% -->
</array>
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="bundled_in_lib">
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
</array>
<array name="bundled_in_assets">
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
</array>
</resources>

127
docs/gost_android_take3.txt

@ -0,0 +1,127 @@ @@ -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

6
src/compat.h

@ -18,7 +18,11 @@ @@ -18,7 +18,11 @@
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/fcntl.h>
#ifndef ANDROID
# include <sys/fcntl.h>
#else
# include <fcntl.h>
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>

6
src/netbase.cpp

@ -10,7 +10,11 @@ @@ -10,7 +10,11 @@
#include "i2p.h"
#ifndef WIN32
#include <sys/fcntl.h>
#ifndef ANDROID
# include <sys/fcntl.h>
#else
# include <fcntl.h>
#endif
#endif
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()

14
src/qt/gostcoin.cpp

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include <QFile>
#include <QDir>
#include <QTextStream>
#include <QDebug>
#include "bitcoingui.h"
#include "clientmodel.h"
@ -25,6 +26,13 @@ @@ -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[]) @@ -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[]) @@ -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);

33
src/util.cpp

@ -13,6 +13,12 @@ @@ -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() @@ -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("/");
@ -1272,7 +1302,8 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) { @@ -1272,7 +1302,8 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) {
fcntl(fileno(file), F_PREALLOCATE, &fst);
}
ftruncate(fileno(file), fst.fst_length);
#elif defined(__linux__)
#elif defined(__linux__) && !defined(ANDROID)
//android doesn't have posix_fallocate
// Version using posix_fallocate
off_t nEndPos = (off_t)offset + length;
posix_fallocate(fileno(file), 0, nEndPos);

Loading…
Cancel
Save