Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sys.getandroidapilevel for more robust Android detection #670

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plyer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from os import environ
from os import path
from sys import platform as _sys_platform
import sys


class Platform:
Expand Down Expand Up @@ -41,9 +42,11 @@ def __hash__(self):
def _get_platform(self):

if self._platform_android is None:
# sys.getandroidapilevel is defined as of Python 3.7
# ANDROID_ARGUMENT and ANDROID_PRIVATE are 2 environment variables
# from python-for-android project
self._platform_android = 'ANDROID_ARGUMENT' in environ
self._platform_android = hasattr(sys, 'getandroidapilevel') or \
'ANDROID_ARGUMENT' in environ

if self._platform_ios is None:
self._platform_ios = (environ.get('KIVY_BUILD', '') == 'ios')
Expand Down