diff --git a/kolibri/utils/android.py b/kolibri/utils/android.py index 8aaddbdf167..e382b297803 100644 --- a/kolibri/utils/android.py +++ b/kolibri/utils/android.py @@ -1,4 +1,4 @@ -from os import environ +import sys # A constant to be used in place of Python's platform.system() @@ -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")