summaryrefslogtreecommitdiffstats
path: root/Android
diff options
context:
space:
mode:
authorMalcolm Smith <smith@chaquo.com>2024-10-25 00:41:07 (GMT)
committerGitHub <noreply@github.com>2024-10-25 00:41:07 (GMT)
commit371c537dff0b384e46ebe6b08009f6628b7acd58 (patch)
treee9ff1d2bdd80de12409527ff2c37b1c63b615ae1 /Android
parentb08570c90eb9fa2e2ee4429909b14240b7a427d4 (diff)
downloadcpython-371c537dff0b384e46ebe6b08009f6628b7acd58.zip
cpython-371c537dff0b384e46ebe6b08009f6628b7acd58.tar.gz
cpython-371c537dff0b384e46ebe6b08009f6628b7acd58.tar.bz2
Increase minimum Android API level to 24 (#125946)
Minimum Android API level has been increased to 24 (Android 7.0).
Diffstat (limited to 'Android')
-rw-r--r--Android/android-env.sh2
-rw-r--r--Android/testbed/app/build.gradle.kts14
-rw-r--r--Android/testbed/app/src/main/c/main_activity.c9
3 files changed, 20 insertions, 5 deletions
diff --git a/Android/android-env.sh b/Android/android-env.sh
index b93e7f2..a0f23ef 100644
--- a/Android/android-env.sh
+++ b/Android/android-env.sh
@@ -3,7 +3,7 @@
: ${HOST:?} # GNU target triplet
# You may also override the following:
-: ${api_level:=21} # Minimum Android API level the build will run on
+: ${api_level:=24} # Minimum Android API level the build will run on
: ${PREFIX:-} # Path in which to find required libraries
diff --git a/Android/testbed/app/build.gradle.kts b/Android/testbed/app/build.gradle.kts
index 6c17406..211b5bb 100644
--- a/Android/testbed/app/build.gradle.kts
+++ b/Android/testbed/app/build.gradle.kts
@@ -32,13 +32,24 @@ val PYTHON_VERSION = file("$PYTHON_DIR/Include/patchlevel.h").useLines {
android {
+ val androidEnvFile = file("../../android-env.sh").absoluteFile
+
namespace = "org.python.testbed"
compileSdk = 34
defaultConfig {
applicationId = "org.python.testbed"
- minSdk = 21
+
+ minSdk = androidEnvFile.useLines {
+ for (line in it) {
+ """api_level:=(\d+)""".toRegex().find(line)?.let {
+ return@useLines it.groupValues[1].toInt()
+ }
+ }
+ throw GradleException("Failed to find API level in $androidEnvFile")
+ }
targetSdk = 34
+
versionCode = 1
versionName = "1.0"
@@ -52,7 +63,6 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
- val androidEnvFile = file("../../android-env.sh").absoluteFile
ndkVersion = androidEnvFile.useLines {
for (line in it) {
"""ndk_version=(\S+)""".toRegex().find(line)?.let {
diff --git a/Android/testbed/app/src/main/c/main_activity.c b/Android/testbed/app/src/main/c/main_activity.c
index 6925133..ec7f93a 100644
--- a/Android/testbed/app/src/main/c/main_activity.c
+++ b/Android/testbed/app/src/main/c/main_activity.c
@@ -34,9 +34,12 @@ typedef struct {
int pipe[2];
} StreamInfo;
+// The FILE member can't be initialized here because stdout and stderr are not
+// compile-time constants. Instead, it's initialized immediately before the
+// redirection.
static StreamInfo STREAMS[] = {
- {stdout, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
- {stderr, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
+ {NULL, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
+ {NULL, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
{NULL, -1, ANDROID_LOG_UNKNOWN, NULL, {-1, -1}},
};
@@ -87,6 +90,8 @@ static char *redirect_stream(StreamInfo *si) {
JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToLogcat(
JNIEnv *env, jobject obj
) {
+ STREAMS[0].file = stdout;
+ STREAMS[1].file = stderr;
for (StreamInfo *si = STREAMS; si->file; si++) {
char *error_prefix;
if ((error_prefix = redirect_stream(si))) {