From 759c6228c34317f9c52df725b0d327113ec999c0 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Fri, 29 Mar 2024 19:11:40 +0800 Subject: [PATCH 1/2] Android build fixes - updates requirements as per Play Store - can build aab on release --- .buildbot/android/build.sh | 15 +++++++++++++-- .buildbot/android/test.sh | 6 ++++++ packages/android/buildozer.spec | 12 +++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.buildbot/android/build.sh b/.buildbot/android/build.sh index 10176ef3..52f563f7 100755 --- a/.buildbot/android/build.sh +++ b/.buildbot/android/build.sh @@ -2,8 +2,19 @@ export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 pushd packages/android -buildozer android debug || exit $? + +BUILDMODE=debug + +if [ "$BUILDBOT_JOBNAME" = "android" -a \ + "$BUILDBOT_REPOSITORY" = "https://github.com/Bitmessage/PyBitmessage" -a \ + "$BUILDBOT_BRANCH" = "v0.6" ]; then + sed -e 's/android.release_artifact *=.*/release_artifact = aab/' -i "" buildozer.spec + BUILDMODE=release +fi + +buildozer android $BUILDMODE || exit $? popd mkdir -p ../out -cp packages/android/bin/*.apk ../out +RELEASE_ARTIFACT=$(grep release_artifact packages/android/buildozer.spec |cut -d= -f2|tr -Cd 'a-z') +cp packages/android/bin/*.${RELEASE_ARTIFACT} ../out diff --git a/.buildbot/android/test.sh b/.buildbot/android/test.sh index b61fac85..65a0fe7d 100755 --- a/.buildbot/android/test.sh +++ b/.buildbot/android/test.sh @@ -1,5 +1,11 @@ #!/bin/bash +RELEASE_ARTIFACT=$(grep release_artifact packages/android/buildozer.spec |cut -d= -f2|tr -Cd 'a-z') + +if [ $RELEASE_ARTIFACT = "aab" ]; then + exit +fi + unzip -p packages/android/bin/*.apk assets/private.tar \ | tar --list -z > package.list cat package.list diff --git a/packages/android/buildozer.spec b/packages/android/buildozer.spec index c98717b4..14afa47d 100644 --- a/packages/android/buildozer.spec +++ b/packages/android/buildozer.spec @@ -1,13 +1,13 @@ [app] # (str) Title of your application -title = mockone +title = PyBitmessage Mock # (str) Package name -package.name = mock +package.name = pybitmessagemock # (str) Package domain (needed for android/ios packaging) -package.domain = org.mock +package.domain = at.bitmessage # (str) Source code where the main.py live source.dir = ../../src @@ -28,7 +28,7 @@ source.include_exts = py,png,jpg,kv,atlas,tflite,sql #source.exclude_patterns = license,images/*/*.jpg # (str) Application versioning (method 1) -version = 0.1 +version = 0.1.1 # (str) Application versioning (method 2) # version.regex = __version__ = ['"](.*)['"] @@ -92,7 +92,7 @@ fullscreen = 0 # (int) Android API to use (targetSdkVersion AND compileSdkVersion) # note: when changing, Dockerfile also needs to be changed to install corresponding build tools -android.api = 28 +android.api = 33 # (int) Minimum API required. You will need to set the android.ndk_api to be as low as this value. android.minapi = 21 @@ -243,6 +243,8 @@ android.allow_backup = True # Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"] # android.manifest_placeholders = [:] +android.release_artifact = apk + # # Python for android (p4a) specific # -- 2.45.1 From cf3716950f6ae5280534536dd280a1c754e53cc1 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Fri, 29 Mar 2024 19:53:08 +0800 Subject: [PATCH 2/2] Use mock for android build --- .buildbot/android/Dockerfile | 2 +- .buildbot/android/build.sh | 12 +++++++++++ packages/android/buildozer.spec | 4 ++-- src/main-android-live.py | 13 ++++++++++++ src/main.py | 36 ++++++++++++++++++++++++--------- src/pyelliptic/openssl.py | 4 ++++ 6 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 src/main-android-live.py diff --git a/.buildbot/android/Dockerfile b/.buildbot/android/Dockerfile index 2d722834..faf29233 100755 --- a/.buildbot/android/Dockerfile +++ b/.buildbot/android/Dockerfile @@ -22,7 +22,7 @@ RUN apt-get -y update -qq \ RUN apt-get -y install -qq --no-install-recommends openjdk-17-jdk \ && apt-get -y autoremove -RUN pip install pip install buildozer cython virtualenv +RUN pip install buildozer cython virtualenv ENV ANDROID_NDK_HOME="${ANDROID_HOME}/android-ndk" diff --git a/.buildbot/android/build.sh b/.buildbot/android/build.sh index 52f563f7..e008218a 100755 --- a/.buildbot/android/build.sh +++ b/.buildbot/android/build.sh @@ -1,6 +1,18 @@ #!/bin/bash export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 + +# buildozer OOM workaround +mkdir -p ~/.gradle +echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" \ + > ~/.gradle/gradle.properties + +# workaround for symlink +rm -rf src/pybitmessage +mkdir -p src/pybitmessage +cp src/*.py src/pybitmessage +cp -r src/bitmessagekivy src/backend src/mockbm src/pybitmessage + pushd packages/android BUILDMODE=debug diff --git a/packages/android/buildozer.spec b/packages/android/buildozer.spec index 14afa47d..99393e86 100644 --- a/packages/android/buildozer.spec +++ b/packages/android/buildozer.spec @@ -13,7 +13,7 @@ package.domain = at.bitmessage source.dir = ../../src # (list) Source files to include (let empty to include all the files) -source.include_exts = py,png,jpg,kv,atlas,tflite,sql +source.include_exts = py,png,jpg,kv,atlas,tflite,sql,json # (list) List of inclusions using pattern matching #source.include_patterns = assets/*,images/*.png @@ -36,7 +36,7 @@ version = 0.1.1 # (list) Application requirements # comma separated e.g. requirements = sqlite3,kivy -requirements = python3,kivy +requirements = python3,kivy,sqlite3,kivymd==1.0.2,Pillow,opencv,kivy-garden.qrcode,qrcode,typing_extensions,libpng # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes diff --git a/src/main-android-live.py b/src/main-android-live.py new file mode 100644 index 00000000..e1644436 --- /dev/null +++ b/src/main-android-live.py @@ -0,0 +1,13 @@ +"""This module is for thread start.""" +import state +import sys +from bitmessagemain import main +from termcolor import colored +print(colored('kivy is not supported at the moment for this version..', 'red')) +sys.exit() + + +if __name__ == '__main__': + state.kivy = True + print("Kivy Loading......") + main() diff --git a/src/main.py b/src/main.py index e1644436..ce042b84 100644 --- a/src/main.py +++ b/src/main.py @@ -1,13 +1,31 @@ -"""This module is for thread start.""" +# pylint: disable=unused-import, wrong-import-position, ungrouped-imports +# flake8: noqa:E401, E402 + +"""Mock kivy app with mock threads.""" + +import os +from kivy.config import Config +from mockbm import multiqueue import state -import sys -from bitmessagemain import main -from termcolor import colored -print(colored('kivy is not supported at the moment for this version..', 'red')) -sys.exit() + +from mockbm.class_addressGenerator import FakeAddressGenerator # noqa:E402 +from bitmessagekivy.mpybit import NavigateApp # noqa:E402 +from mockbm import network # noqa:E402 + +stats = network.stats +objectracker = network.objectracker -if __name__ == '__main__': - state.kivy = True - print("Kivy Loading......") +def main(): + """main method for starting threads""" + addressGeneratorThread = FakeAddressGenerator() + addressGeneratorThread.daemon = True + addressGeneratorThread.start() + state.kivyapp = NavigateApp() + state.kivyapp.run() + addressGeneratorThread.stopThread() + + +if __name__ == "__main__": + os.environ['INSTALL_TESTS'] = "True" main() diff --git a/src/pyelliptic/openssl.py b/src/pyelliptic/openssl.py index deb81644..851dfa15 100644 --- a/src/pyelliptic/openssl.py +++ b/src/pyelliptic/openssl.py @@ -805,6 +805,10 @@ def loadOpenSSL(): 'libcrypto.dylib', '/usr/local/opt/openssl/lib/libcrypto.dylib']) elif 'win32' in sys.platform or 'win64' in sys.platform: libdir.append('libeay32.dll') + # kivy + elif 'ANDROID_ARGUMENT' in environ: + libdir.append('libcrypto1.1.so') + libdir.append('libssl1.1.so') else: libdir.append('libcrypto.so') libdir.append('libssl.so') -- 2.45.1