8000 Increase minimum Android API level to 24 (#125946) · python/cpython@371c537 · GitHub
[go: up one dir, main page]

Skip to content

Commit 371c537

Browse files
authored
Increase minimum Android API level to 24 (#125946)
Minimum Android API level has been increased to 24 (Android 7.0).
1 parent b08570c commit 371c537

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

Android/android-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
: ${HOST:?} # GNU target triplet
44

55
# You may also override the following:
6-
: ${api_level:=21} # Minimum Android API level the build will run on
6+
: ${api_level:=24} # Minimum Android API level the build will run on
77
: ${PREFIX:-} # Path in which to find required libraries
88

99

Android/testbed/app/build.gradle.kts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,24 @@ val PYTHON_VERSION = file("$PYTHON_DIR/Include/patchlevel.h").useLines {
3232

3333

3434
android {
35+
val androidEnvFile = file("../../android-env.sh").absoluteFile
36+
3537
namespace = "org.python.testbed"
3638
compileSdk = 34
3739

3840
defaultConfig {
3941
applicationId = "org.python.testbed"
40-
minSdk = 21
42+
43+
minSdk = androidEnvFile.useLines {
44+
for (line in it) {
45+
"""api_level:=(\d+)""".toRegex().find(line)?.let {
46+
return@useLines it.groupValues[1].toInt()
47+
}
48+
}
49+
throw GradleException("Failed to find API level in $androidEnvFile")
50+
}
4151
targetSdk = 34
52+
4253
versionCode = 1
4354
versionName = "1.0"
4455

@@ -52,7 +63,6 @@ android {
5263
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
5364
}
5465

55-
val androidEnvFile = file("../../android-env.sh").absoluteFile
5666
ndkVersion = androidEnvFile.useLines {
5767
for (line in it) {
5868
"""ndk_version=(\S+)""".toRegex().find(line)?.let {

Android/testbed/app/src/main/c/main_activity.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ typedef struct {
3434
int pipe[2];
3535
} StreamInfo;
3636

37+
// The FILE member can't be initialized here because stdout and stderr are not
38+
// compile-time constants. Instead, it's initialized immediately before the
39+
// redirection.
3740
static StreamInfo STREAMS[] = {
38-
{stdout, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
39-
{stderr, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
41+
{NULL, STDOUT_FILENO, ANDROID_LOG_INFO, "native.stdout", {-1, -1}},
42+
{NULL, STDERR_FILENO, ANDROID_LOG_WARN, "native.stderr", {-1, -1}},
4043
{NULL, -1, ANDROID_LOG_UNKNOWN, NULL, {-1, -1}},
4144
};
4245

@@ -87,6 +90,8 @@ static char *redirect_stream(StreamInfo *si) {
8790
JNIEXPORT void JNICALL Java_org_python_testbed_PythonTestRunner_redirectStdioToLogcat(
8891
JNIEnv *env, jobject obj
8992
) {
93+
STREAMS[0].file = stdout;
94+
STREAMS[1].file = stderr;
9095
for (StreamInfo *si = STREAMS; si->file; si++) {
9196
char *error_prefix;
9297
if ((error_prefix = redirect_stream(si))) {

Lib/test/test_android.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424

2525

2626
# Test redirection of stdout and stderr to the Android log.
27-
@unittest.skipIf(
28-
api_level < 23 and platform.machine() == "aarch64",
29-
"SELinux blocks reading logs on older ARM64 emulators"
30-
)
3127
class TestAndroidOutput(unittest.TestCase):
3228
maxDiff = None
3329

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The minimum supported Android version is now 7.0 (API level 24).

0 commit comments

Comments
 (0)
0