Skip to content
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