Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 10: IMEI no longer available on API 29. Looking for alternatives

Our client's app main feature is heavily relaying on tracking their clients' devices, they offer products that are bound to the specific phone(not its owner). This was possible using the device imei, but with the privacy changes in Android 10, they made it unreachable. (https://developer.android.com/about/versions/10/privacy/changes).

Android has a documentation about what identifier to use on specific user cases, but non matches our case since we need it to be unique, constant and bound to the device(or at least difficult to change). https://developer.android.com/training/articles/user-data-ids. I'm considering Android ID to be a possible solution, or using the mac address knowing they aren't 100% reliable.

Any thoughts? recommendations? experiences? at this point anything could be an option

like image 495
kvnnj.m_av Avatar asked Sep 25 '19 17:09

kvnnj.m_av


People also ask

How do I find my IMEI Android 10?

Find and tap Settings. Android 10 / 11 / 12: About phone → IMEI. Android 9: System → About phone → IMEI.

Can Android read IMEI?

Android recognizes the importance of protecting the IMEI. In order for apps to access it, they must be granted the READ_PHONE_STATE permission (see figure above); only apps with that permission are allowed to access the IMEI.

Is the IMEI the Android ID?

The android device ID is a unique alphanumeric code generated for your Android phone when you first set it up. This code basically identifies your device similar to how the IMEI number works. However, Android device ID is specifically used for identification purposes, instead of tracking your device.


1 Answers

I advice you to read the official blog of the best practice of google to see what the use case match with your specification : https://developer.android.com/training/articles/user-data-ids.html

For me i occcured the same problem about the unicity of android identifiers and i found the only solution is to use the MediaDrm API ( https://android.googlesource.com/platform/frameworks/base/+/android-cts-4.4_r1/media/java/android/media/MediaDrm.java#539 ) which contains a unique device id and can survive even on the factory reset and doesn't need any additional permission on your manifest file.

Here is the couple of code how can we retreive the unique identifier on Android 10 :

import android.media.MediaDrm import java.security.MessageDigest import java.util.*  object UniqueDeviceID {      /**      * UUID for the Widevine DRM scheme.      * <p>      * Widevine is supported on Android devices running Android 4.3 (API Level 18) and up.      */     fun getUniqueId(): String? {          val WIDEVINE_UUID = UUID(-0x121074568629b532L, -0x5c37d8232ae2de13L)         var wvDrm: MediaDrm? = null         try {             wvDrm = MediaDrm(WIDEVINE_UUID)             val widevineId = wvDrm.getPropertyByteArray(MediaDrm.PROPERTY_DEVICE_UNIQUE_ID)             val md = MessageDigest.getInstance("SHA-256")             md.update(widevineId)             return  md.digest().toHexString()         } catch (e: Exception) {             //WIDEVINE is not available             return null         } finally {             if (AndroidPlatformUtils.isAndroidTargetPieAndHigher()) {                 wvDrm?.close()             } else {                 wvDrm?.release()             }         }     }       fun ByteArray.toHexString() = joinToString("") { "%02x".format(it) } } 
like image 118
Sofien Rahmouni Avatar answered Oct 06 '22 16:10

Sofien Rahmouni