From a6a4da7654513e0cedfb3bbaab3f629485ce9078 Mon Sep 17 00:00:00 2001 From: Lakhya Jyoti Nath Date: Mon, 21 Jun 2021 15:47:21 +0530 Subject: [PATCH 1/3] updated-device-name-implementation-for-backward-compatibility --- plyer/platforms/android/devicename.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plyer/platforms/android/devicename.py b/plyer/platforms/android/devicename.py index c2636f1ef..6b5f54d78 100644 --- a/plyer/platforms/android/devicename.py +++ b/plyer/platforms/android/devicename.py @@ -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): @@ -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 in an android environment. + + Changed the implementation from 'android.provider.Settings.Global' to + 'android.os.Build' becuase '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.DEVICE def instance(): From 8533cea7c8f8d36e3e008118b2db9b2cc9957304 Mon Sep 17 00:00:00 2001 From: Lakhya Jyoti Nath Date: Mon, 21 Jun 2021 16:22:54 +0530 Subject: [PATCH 2/3] Fixed devicename to return device model number --- plyer/platforms/android/devicename.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plyer/platforms/android/devicename.py b/plyer/platforms/android/devicename.py index 6b5f54d78..3895e6f2b 100644 --- a/plyer/platforms/android/devicename.py +++ b/plyer/platforms/android/devicename.py @@ -15,7 +15,7 @@ class AndroidDeviceName(DeviceName): def _get_device_name(self): """ - Method to get the device name in an android environment. + Method to get the device name aka model in an android environment. Changed the implementation from 'android.provider.Settings.Global' to 'android.os.Build' becuase 'android.provider.Settings.Global' was @@ -23,7 +23,7 @@ def _get_device_name(self): Thereby making this method more backward compatible. """ - return Build.DEVICE + return Build.MODEL def instance(): From 8cd95212746aae3a801fc20f176a7117eff7a650 Mon Sep 17 00:00:00 2001 From: Lakhya Jyoti Nath Date: Mon, 21 Jun 2021 16:30:29 +0530 Subject: [PATCH 3/3] Changed devicename api from android.provider.Settings.Global to android.os.Build for backward compatibility --- plyer/platforms/android/devicename.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plyer/platforms/android/devicename.py b/plyer/platforms/android/devicename.py index 3895e6f2b..75855cc75 100644 --- a/plyer/platforms/android/devicename.py +++ b/plyer/platforms/android/devicename.py @@ -18,7 +18,7 @@ def _get_device_name(self): Method to get the device name aka model in an android environment. Changed the implementation from 'android.provider.Settings.Global' to - 'android.os.Build' becuase 'android.provider.Settings.Global' was + '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.