Android Q has restricted to access for both IMEI and serial no. It is available only for platform and apps with special carrier permission. Also the permission READ_PRIVILEGED_PHONE_STATE is not available for non platform apps.
Existing version(Android P, Android O, Android M) we have used the serial no for uniquely identified the device. Now we have faced the below Exception while tried to access the device identifier.
Android Q has restricted to access for both IMEI and serial no.
06-21 12:37:07.460 1250 2555 W DevicePolicyManager: Package com.nagra.nmp.corepaktest (uid=10201, pid=32694) cannot access Device IDs
06-21 12:37:07.460 1250 2555 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:com.nagra.nmp.corepaktest:getSerial:isPreinstalled=false:isPrivApp=false
06-21 12:37:07.464 32694 32718 W System.err: java.lang.SecurityException: getSerial: The user 10201 does not meet the requirements to access device identifiers.
06-21 12:37:07.464 32694 32718 W System.err: at android.os.Parcel.createException(Parcel.java:2069)
06-21 12:37:07.464 32694 32718 W System.err: at android.os.Parcel.readException(Parcel.java:2037)
06-21 12:37:07.465 32694 32718 W System.err: at android.os.Parcel.readException(Parcel.java:1986)
06-21 12:37:07.465 32694 32718 W System.err: at android.os.IDeviceIdentifiersPolicyService$Stub$Proxy.getSerialForPackage(IDeviceIdentifiersPolicyService.java:159)
06-21 12:37:07.465 32694 32718 W System.err: at android.os.Build.getSerial(Build.java:149)
06-21 12:37:07.465 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestBridge.start(Native Method)
06-21 12:37:07.466 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestWrapper.start(TestWrapper.java:111)
06-21 12:37:07.466 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestWrapper.access$200(TestWrapper.java:58)
06-21 12:37:07.466 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestWrapper$WrapperThread.run(TestWrapper.java:427)
06-21 12:37:07.472 1250 2555 W DevicePolicyManager: Package com.nagra.nmp.corepaktest (uid=10201, pid=32694) cannot access Device IDs
06-21 12:37:07.472 2744 2764 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:com.nagra.nmp.corepaktest:getDeviceId:isPreinstalled=false:isPrivApp=false
06-21 12:37:07.473 32694 32718 W System.err: java.lang.SecurityException: getDeviceId: The user 10201 does not meet the requirements to access device identifiers.
06-21 12:37:07.474 32694 32718 W System.err: at android.os.Parcel.createException(Parcel.java:2069)
06-21 12:37:07.474 32694 32718 W System.err: at android.os.Parcel.readException(Parcel.java:2037)
06-21 12:37:07.474 32694 32718 W System.err: at android.os.Parcel.readException(Parcel.java:1986)
06-21 12:37:07.474 32694 32718 W System.err: at com.android.internal.telephony.ITelephony$Stub$Proxy.getDeviceId(ITelephony.java:10278)
06-21 12:37:07.474 32694 32718 W System.err: at android.telephony.TelephonyManager.getDeviceId(TelephonyManager.java:1565)
06-21 12:37:07.474 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestBridge.start(Native Method)
06-21 12:37:07.474 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestWrapper.start(TestWrapper.java:111)
06-21 12:37:07.474 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestWrapper.access$200(TestWrapper.java:58)
06-21 12:37:07.474 32694 32718 W System.err: at com.nagra.CppUnitForAndroid.TestWrapper$WrapperThread.run(TestWrapper.java:427)
Which one(Property/API) used for Uniquely identify the device?
Since hardware ids are restricted, you can use an almost reliable software id like ANDROID_ID
:
Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)
I used almost since it can be changed on a rooted phone, but reliable on non-rooted devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With