We have a cosu app, that can manage its lock state with calls to Android management API. To do this, we receive a list of devices with devices.list
query, compare each device's hardwareInfo.serialNumber
with IMEI, received from Build.getSerial()
and then use the following code to apply different policy:
fun patchDevice(device: Device, policyName: String) {
device.policyName = policyName
androidManagementClient.enterprises().devices().patch(device.name, device).execute()
}
However, according to docs, hardware device identifiers are no longer available in android Q. (link) Right now, we use devices with Android 8, but I suspect our code will break on newer OS. So, the questions are:
Is there any other way to identify the device in the list, without knowing its hardware ids?
Or maybe there is a way to guarantee that using READ_PHONE_STATE will still provide us with IMEI on Android Q? In the documentation it is stated that If your app is the device or profile owner app, you need only the READ_PHONE_STATE permission to access non-resettable device identifiers, even if your app targets Android Q. However, AMAPI has its own device owner app, so I'm not sure if that will work in our case.
The simplest approach here is to pass the device name
to your COSU app via a managed configuration. You COSU app can then call the API using that name. With this approach you don't need to access the serial number of the device.
This approach is explained in details in one of my previous answers.