简体   繁体   English

Android 管理 API:在 android Q 上的设备列表中查找设备

[英]Android management API: find device in list of devices on android Q

We have a cosu app, that can manage its lock state with calls to Android management API.我们有一个 cosu 应用程序,它可以通过调用 Android 管理 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:为此,我们使用devices.list查询接收设备列表,将每个设备的hardwareInfo.serialNumber与从Build.getSerial()接收的 IMEI 进行比较,然后使用以下代码应用不同的策略:

  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.但是,根据文档,android Q 中不再提供硬件设备标识符。( 链接)现在,我们使用带有 Android 8 的设备,但我怀疑我们的代码会在较新的操作系统上中断。 So, the questions are:所以,问题是:

  1. Is there any other way to identify the device in the list, without knowing its hardware ids?有没有其他方法可以在不知道其硬件 ID 的情况下识别列表中的设备?

  2. Or maybe there is a way to guarantee that using READ_PHONE_STATE will still provide us with IMEI on Android Q?或者也许有一种方法可以保证在 Android Q 上使用 READ_PHONE_STATE 仍然会为我们提供 IMEI? 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.在文档中指出,如果您的应用程序是设备或配置文件所有者应用程序,则您只需要 READ_PHONE_STATE 权限即可访问不可重置的设备标识符,即使您的应用程序面向 Android Q。但是,AMAPI 有自己的设备所有者应用程序,所以我不确定这是否适用于我们的情况。

The simplest approach here is to pass the device name to your COSU app via a managed configuration.这里最简单的方法是通过托管配置将设备name传递给您的 COSU 应用程序。 You COSU app can then call the API using that name.然后,您的 COSU 应用程序可以使用该名称调用 API。 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 .这种方法在我之前的一个答案中有详细解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM