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

fix #107 - Use Android_ID instead of IMEI #133

Merged
merged 1 commit into from
May 9, 2015
Merged
Show file tree
Hide file tree
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
9 changes: 4 additions & 5 deletions plyer/facades/uniqueid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ class UniqueID(object):

Returns the following depending on the platform:

* **Android**: IMEI
* **Android**: Android ID
* **Mac OSX**: Serial number of the device
* **Linux**: Serial number using lshw
* **Windows**: MachineGUID from regkey

.. note::
On Android your app needs the READ_PHONE_STATE permission


.. versionadded:: 1.2.0

.. versionchanged:: 1.2.4 On Android returns Android ID instead of IMEI
'''

@property
Expand Down
13 changes: 5 additions & 8 deletions plyer/platforms/android/uniqueid.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
from jnius import autoclass, cast
from jnius import autoclass
from plyer.platforms.android import activity
from plyer.facades import UniqueID

TelephonyManager = autoclass('android.telephony.TelephonyManager')
Context = autoclass('android.content.Context')

Secure = autoclass('android.provider.Settings$Secure')

class AndroidUniqueID(UniqueID):

def _get_uid(self):
manager = cast('android.telephony.TelephonyManager',
activity.getSystemService(Context.TELEPHONY_SERVICE))
return manager.getDeviceId()
return Secure.getString(activity.getContentResolver(),
Secure.ANDROID_ID)


def instance():
return AndroidUniqueID()
return AndroidUniqueID()