Skip to content

Commit

Permalink
Merge pull request #670 from rdb/robust-android-detection
Browse files Browse the repository at this point in the history
Use sys.getandroidapilevel for more robust Android detection
  • Loading branch information
akshayaurora authored Apr 19, 2022
2 parents 890aa39 + 9ca7203 commit 2179cd0
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 2179cd0

Please sign in to comment.