0

I am working on a app in which I am setting up my app as profile owner to get IMEI and serial number of device. But in android 12 both IMEI and serial number are restricted and we can’t fetch these parameters further. Can you please let me know what are the other options to get IMEI and serial number of devices except making the devices system app or make app device owner.

  • If you really need IMEI and serial number, specifically, I believe you don't have an easy way. But maybe another unique identifier might be suitable for your use case. You can check them out [here](https://developer.android.com/training/articles/user-data-ids). – Milack27 Sep 28 '21 at 12:38
  • Also, it seems the restriction you mentioned was added in Android 10 (API 29), not 12. – Milack27 Sep 28 '21 at 12:40
  • 1
    Does this answer your question? [Get Permanent Unique ID for android device](https://stackoverflow.com/questions/57039625/get-permanent-unique-id-for-android-device) – Sweta Jain Oct 06 '21 at 09:07

1 Answers1

1

As Android's reference describes, the only way for an app to access the IMEI is to meet one of conditions listed(Link):

Starting with API level 29, persistent device identifiers are guarded behind additional restrictions, and apps are recommended to use resettable identifiers (see Best practices for unique identifiers). This method can be invoked if one of the following requirements is met:

  • If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this is a privileged permission that can only be granted to apps preloaded on the device.
  • If the calling app is the device owner of a fully-managed device, a profile owner of an organization-owned device, or their delegates (see DevicePolicyManager.getEnrollmentSpecificId()).
  • If the calling app has carrier privileges (see hasCarrierPrivileges()) on any active subscription.
  • If the calling app is the default SMS role holder (see RoleManager.isRoleHeld(java.lang.String)).
  • If the calling app has been granted the Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER permission.

You must either pick one of those or rely on other identifiers like android-id that is resettable

Amin Rezaei
  • 376
  • 2
  • 11