Skip to content

Commit

Permalink
Merge pull request #11072 from rtibbles/robustly_android
Browse files Browse the repository at this point in the history
Change the way we check for Android to use Python internals.
  • Loading branch information
rtibbles authored Oct 12, 2023
2 parents 0fbcc1a + 9238464 commit 9eceee4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kolibri/utils/android.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os import environ
import sys


# A constant to be used in place of Python's platform.system()
Expand All @@ -8,7 +8,9 @@

# Android is based on the Linux kernel, but due to security issues, we cannot
# run the /proc command there, so we need a way to distinguish between the two.
# Python for Android always sets some Android environment variables, so we check
# for one of them to differentiate. This is how Kivy detects Android as well.
# When Python is built against a specific version of the Android API, this method
# is defined. Otherwise it is not. Note that this cannot be used to distinguish
# between the current runtime versions of Android, as this value is set to the minimum
# API level that this Python version was compiled against.
def on_android():
return "ANDROID_ARGUMENT" in environ
return hasattr(sys, "getandroidapilevel")

0 comments on commit 9eceee4

Please sign in to comment.