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

updated-device-name-implementation-for-backward-compatibility #634

Merged
merged 3 commits into from
Jun 21, 2021
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
17 changes: 11 additions & 6 deletions plyer/platforms/android/devicename.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
'''

from jnius import autoclass
from plyer.platforms.android import activity
from plyer.facades import DeviceName

Secure = autoclass('android.provider.Global$Secure')
Build = autoclass('android.os.Build')


class AndroidDeviceName(DeviceName):
Expand All @@ -15,10 +14,16 @@ class AndroidDeviceName(DeviceName):
'''

def _get_device_name(self):
return Secure.getString(
activity.getContentResolver(),
Secure.DEVICE_NAME
)
"""
Method to get the device name aka model in an android environment.

Changed the implementation from 'android.provider.Settings.Global' to
'android.os.Build' because 'android.provider.Settings.Global' was
introduced in API 17 whereas 'android.os.Build' is present since API 1

Thereby making this method more backward compatible.
"""
return Build.MODEL


def instance():
Expand Down