Please be aware that this application / sample is provided as-is for demonstration purposes without any guarantee of support
How to access device identifiers such as serial number and IMEI on Zebra devices running Android 10
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"/>
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 this sample it is com.zebra.emdk_deviceidentifiers_sample.
- Caller Signature: The signing certificate of your application. For more information on generating this see https://github.com/darryncampbell/MX-SignatureAuthentication-Demo.
You can apply the MX access manager settings in one of three ways:
- Via StageNow
- Via your EMM
- Via your application, using the EMDK Profile Manager.
For example, StageNow will look as follows to enable access to the serial number:
You can then run this sample app and should see something like the below:
Or, on a device that does not have WAN capabilities, i.e. no SIM card or data connection:
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:
Assign access to your device and re-run the application.
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>
<package android:name="com.zebra.zebracontentprovider" />
</queries>