diff --git a/.github/workflows/android_debug.yml b/.github/workflows/android_debug.yml index 822b1e328dbf..019a2a790c93 100644 --- a/.github/workflows/android_debug.yml +++ b/.github/workflows/android_debug.yml @@ -49,6 +49,12 @@ jobs: - run: sudo apt update + - name: Setup Java environment + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: @@ -118,10 +124,6 @@ jobs: mkdir gstreamer-1.0-android-universal-1.18.5 tar xf gstreamer-1.0-android-universal-1.18.5.tar.xz -C gstreamer-1.0-android-universal-1.18.5 - - name: Update android manifest - if: github.ref_name != 'Stable' - run: ${SOURCE_DIR}/tools/update_android_manifest_package.sh ${{ github.ref_name }} - - name: Install dependencies run: sudo apt-get install -y ninja-build diff --git a/.github/workflows/android_release.yml b/.github/workflows/android_release.yml index 76f9108f9c11..1d4780e6b80c 100644 --- a/.github/workflows/android_release.yml +++ b/.github/workflows/android_release.yml @@ -50,6 +50,12 @@ jobs: - run: sudo apt update + - name: Setup Java environment + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: @@ -96,11 +102,6 @@ jobs: mkdir gstreamer-1.0-android-universal-1.18.5 tar xf gstreamer-1.0-android-universal-1.18.5.tar.xz -C gstreamer-1.0-android-universal-1.18.5 - - name: Update android manifest - if: github.ref_name != 'Stable' - run: | - ${SOURCE_DIR}/tools/update_android_manifest_package.sh ${{ github.ref_name }} - - name: Build working-directory: ${{ runner.temp }}/shadow_build_dir env: diff --git a/CMakeLists.txt b/CMakeLists.txt index d3be93e293fa..04eb1115fbad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,7 +228,7 @@ elseif(ANDROID) PROPERTIES QT_ANDROID_ABIS ${ANDROID_ABI} QT_ANDROID_MIN_SDK_VERSION 26 - QT_ANDROID_TARGET_SDK_VERSION 33 + QT_ANDROID_TARGET_SDK_VERSION 34 QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android QT_ANDROID_VERSION_NAME ${APP_VERSION_STR} # QT_ANDROID_VERSION_CODE 5.0 diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 5d26f8c742fd..96ee1c6ca45d 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,8 +1,8 @@ @@ -22,7 +22,9 @@ android:requestLegacyExternalStorage="true" android:allowBackup="true" android:fullBackupOnly="false" - android:icon="@drawable/icon"> + android:icon="@drawable/icon" + android:usesCleartextTraffic="true" + android:networkSecurityConfig="@xml/network_security_config"> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +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 + if ! command -v java >/dev/null 2>&1 + then + 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 +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 000000000000..5b73dbbe0ff9 --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +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 execute + +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 + +: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 %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega \ No newline at end of file diff --git a/android/res/values/libs.xml b/android/res/values/libs.xml new file mode 100644 index 000000000000..fe63866f7264 --- /dev/null +++ b/android/res/values/libs.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/android/res/xml/network_security_config.xml b/android/res/xml/network_security_config.xml new file mode 100644 index 000000000000..c15c09cbf2d5 --- /dev/null +++ b/android/res/xml/network_security_config.xml @@ -0,0 +1,4 @@ + + + + diff --git a/android/res/xml/qtprovider_paths.xml b/android/res/xml/qtprovider_paths.xml new file mode 100644 index 000000000000..ae5b4b6074e7 --- /dev/null +++ b/android/res/xml/qtprovider_paths.xml @@ -0,0 +1,4 @@ + + + + diff --git a/android/src/org/mavlink/qgroundcontrol/QGCActivity.java b/android/src/org/mavlink/qgroundcontrol/QGCActivity.java index 3b23f3abcde0..1826e043acca 100644 --- a/android/src/org/mavlink/qgroundcontrol/QGCActivity.java +++ b/android/src/org/mavlink/qgroundcontrol/QGCActivity.java @@ -202,7 +202,11 @@ public void onCreate(Bundle savedInstanceState) filter.addAction(ACTION_USB_PERMISSION); filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); - _instance.registerReceiver(_instance._usbReceiver, filter); + if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) { + _instance.registerReceiver(_instance._usbReceiver, filter, RECEIVER_EXPORTED); + } else { + _instance.registerReceiver(_instance._usbReceiver, filter); + } // Create intent for usb permission request int intentFlags = 0; diff --git a/tools/update_android_manifest_package.sh b/tools/update_android_manifest_package.sh deleted file mode 100755 index 10041f113ad1..000000000000 --- a/tools/update_android_manifest_package.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -MANIFEST_FILE=android/AndroidManifest.xml - -echo "Adjusting package name for daily build" -QGC_PKG_NAME="org.mavlink.qgroundcontrolbeta" -sed -i -e 's/package *= *"[^"]*"/package="'$QGC_PKG_NAME'"/' $MANIFEST_FILE diff --git a/tools/update_android_version.sh b/tools/update_android_version.sh deleted file mode 100755 index 5819ac5f65a7..000000000000 --- a/tools/update_android_version.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash - -# git tag is in the form vX.Y.Z for builds from tagged commit -# git tag is in the form vX.Y.Z-1234-gSHA for builds from non-tagged commit - -# Strip the 'v' from the beginning of the tag -VERSIONNAME=`git describe --always --tags | sed -e 's/^v//'` -echo "tag $VERSIONNAME" - -# Change all occurences of '-' in tag to '.' and separate into parts -IFS=. read major minor patch dev sha <<<"${VERSIONNAME//-/.}" -echo "major:$major minor:$minor patch:$patch dev:$dev sha:$sha" - -# Max Android version code is 2100000000. Version codes must increase with each release and the -# version codes for multiple apks for the same release must be unique and not collide as well. -# All of this makes it next to impossible to create a rational system of building a version code -# from a semantic version without imposing some strict restrictions. -if [ $major -gt 9 ]; then - echo "Error: Major version larger than 1 digit: $major" - exit 1 -fi -if [ $minor -gt 9 ]; then - echo "Error: Minor version larger than 1 digit: $minor" - exit 1 -fi -if [ $patch -gt 99 ]; then - echo "Error: Patch version larger than 2 digits: $patch" - exit 1 -fi -if [ $dev -gt 999 ]; then - echo "Error: Dev version larger than 3 digits: $dev" - exit 1 -fi - -# Version code format: BBMIPPDDD (B=Bitness, I=Minor) -VERSIONCODE=$(($major*1000000)) -VERSIONCODE=$(($(($minor*100000)) + $VERSIONCODE)) -VERSIONCODE=$(($(($patch*1000)) + $VERSIONCODE)) -VERSIONCODE=$(($(($dev)) + $VERSIONCODE)) - -# The 32 bit and 64 bit APKs each need there own version code unique version code -if [ "$1" = "32" ]; then - VERSIONCODE=34$VERSIONCODE -else - VERSIONCODE=66$VERSIONCODE -fi - -MANIFEST_FILE=android/AndroidManifest.xml - -# manifest package -if [ "$2" = "master" ]; then - echo "Adjusting package name for daily build" - QGC_PKG_NAME="org.mavlink.qgroundcontrolbeta" - sed -i -e 's/package *= *"[^"]*"/package="'$QGC_PKG_NAME'"/' $MANIFEST_FILE -fi - -# android:versionCode -if [ -n "$VERSIONCODE" ]; then - echo "Android versionCode: ${VERSIONCODE}" - sed -i -e "s/android:versionCode=\"[0-9][0-9]*\"/android:versionCode=\"$VERSIONCODE\"/" $MANIFEST_FILE -else - echo "Error: versionCode empty" - exit 1 -fi - -# android:versionName -if [ -n "$VERSIONNAME" ]; then - echo "Android versionName: ${VERSIONNAME}" - sed -i -e 's/versionName *= *"[^"]*"/versionName="'$VERSIONNAME'"/' $MANIFEST_FILE -else - echo "Error: versionName empty" - exit 1 -fi -