]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Increase minimum Android API level to 24 (#125946)
authorMalcolm Smith <smith@chaquo.com>
Fri, 25 Oct 2024 00:41:07 +0000 (01:41 +0100)
committerGitHub <noreply@github.com>
Fri, 25 Oct 2024 00:41:07 +0000 (08:41 +0800)
Minimum Android API level has been increased to 24 (Android 7.0).

Android/android-env.sh
Android/testbed/app/build.gradle.kts
Android/testbed/app/src/main/c/main_activity.c
Lib/test/test_android.py
Misc/NEWS.d/next/Build/2024-10-25-00-29-15.gh-issue-125946.KPA3g0.rst [new file with mode: 0644]

index b93e7f21ed5b94c826a3692bd3cb37967b7ad806..a0f23ef8c9fc52fc77f63dc1be9b98f923c24b8d 100644 (file)
@@ -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
 
 
index 6c17406c8724dcefedcc31b41c3863c5515eb751..211b5bbfadf64d9fea1c701d33dc8f6c19eb08cc 100644 (file)
@@ -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 {
index 69251332d48890c15541564890ca796a05aee6a9..ec7f93a3e5ee13a4c21d8236a4261353a7ea829f 100644 (file)
@@ -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))) {
index 076190f757204559f713b83de6ce89e6477a5ce6..a9abd61b9a8d92370a9ed6b439bd56860391708c 100644 (file)
@@ -24,10 +24,6 @@ STREAM_INFO = [("stdout", "I", 1), ("stderr", "W", 2)]
 
 
 # Test redirection of stdout and stderr to the Android log.
-@unittest.skipIf(
-    api_level < 23 and platform.machine() == "aarch64",
-    "SELinux blocks reading logs on older ARM64 emulators"
-)
 class TestAndroidOutput(unittest.TestCase):
     maxDiff = None
 
diff --git a/Misc/NEWS.d/next/Build/2024-10-25-00-29-15.gh-issue-125946.KPA3g0.rst b/Misc/NEWS.d/next/Build/2024-10-25-00-29-15.gh-issue-125946.KPA3g0.rst
new file mode 100644 (file)
index 0000000..ecab57c
--- /dev/null
@@ -0,0 +1 @@
+The minimum supported Android version is now 7.0 (API level 24).