Access Serial Number and IMEI on Mobile Computers Running Android 10 and higher

Darryn Campbell -
2 MIN READ
8892
5

By @darryncampbell

The sample application to accompany this post can be found at https://github.com/darryncampbell/EMDK-DeviceIdentifiers-Sample. This article was updated on 19th April to reflect the behaviour on Android 11

To obtain the serial number or IMEI without using StageNow (using EMDK Profile Manager instead), please see this article instead.

Android 10 limited access to device identifiers for all apps running on the platform regardless of their target API level. As explained in the docs for Android 10 privacy changes this includes the serial number, IMEI and some other identifiable information.

Zebra mobile computers running Android 10 are able to access both the serial number and IMEI however applications need to be explicitly granted the ability to do so and use a proprietary API.

To access the serial number and IMEI file on Zebra Android devices running Android 10 or higher, first declare a new permission in your AndroidManifest.xml

<uses-permission android:name="com.zebra.provider.READ">
</uses-permission>

Then use the MX access manager to allow your application to call the service identifiers associated with the serial number and IMEI

The MX access manager settings to enable this are as follows:

  • Service Access Action: "AllowCaller" (or 'Allow Caller to Call Service')
  • Service Identifier: For the serial number use content://oem_info/oem.zebra.secure/build_serial. For the IMEI use content://oem_info/wan/imei. If you want to allow your app access to both, you will need to declare two different instances of the AccessManager.

  • Caller Package Name: Your package name, in the case of the sample it is com.zebra.emdk_deviceidentifiers_sample.

  • Caller Signature: The signing certificate of your application. For more information on generating this see https://developer.zebra.com/blog/generating-package-signature-use-mx.

You can apply the MX access manager settings in one of three ways:

  1. Via StageNow
  2. Via your EMM
  3. Via your application, using the EMDK Profile Manager.

For example, StageNow will look as follows to enable access to the serial number:

StageNow

You can then run this sample app and should see something like the below:

Working

Or, on a device that does not have WAN capabilities, i.e. no SIM card or data connection:

Non-WAN

Handling errors:

If you failed to correctly allow your application access to oem_info service, you will see an error stating so against each property you did not assign access to, as shown below:

no_service_access

Assign access via MX and re-run the application.

Changes to Package visibility in Android 11

Applications targeting SDK 30 (Android 11) will need to confirm to the package visibility filtering on Android as described in the Android documentation at https://developer.android.com/training/package-visibility and https://developer.android.com/training/package-visibility

To grant visility by authority, add the following to your manifest:

<queries>   
        <provider android:authorities="oem_info" />
</queries>

 

profile

Darryn Campbell

Please Register or Login to post a reply

5 Replies

D Devi Paul

IMEI is one of the best method to track mobiles. Connections Wordle

V Viet Heo

I was looking for this but couldn't find it until I read your article, it's great and has helped me a wordle lot.

M Mariah Carey

Your desire to share your wordle knowledge has greatly benefited me and made a positive difference in my life.

L Luca Silingardi

I'm trying to use the sample above to get the WiFi Mac-Address on a Zebra device (running Android 11, of course Wifi is turned on and connected), using this oem identifier: content://oem_info/oem.zebra.secure/wifi_mac.

I changed all the correct parts in tha sample, but I didn't get the value.

Can you provide any sample code to get the value (if it's possibile)?

T Tommy Yan

I'm encountering a crash with 'java.lang.NoSuchMethodError' when calling EMDKManager.getEMDKManager() on a TC26 device. This issue doesn't occur on other versions of the device. How can I fix this problem? thx