1

Writing a POC at the moment and don't want to depend on Google Cloud's Pub/Sub service for getting back the deviceId for a newly provisioned BYOD using Android Management APIs.

Is any any other way that after using an enrollment token for provisioning a device, that we can determine its deviceId?

  • did you find out a solution to determine the deviceId in the end? – H.T. Koo Jul 08 '20 at 09:56
  • 1
    The DeviceId generated by Android Management API is same as the "Google Service Framework (GSF)" token. You can install https://play.google.com/store/apps/details?id=vtechnotm.com.deviceid app in the work profile and see that the GSF token will always match with the deviceId from AMA. Also to generate the DeviceId you can use the code from here: https://github.com/emulk/Android-Device-ID/blob/master/app/src/main/java/androiddeviceid/emulk/it/androiddeviceid/MainActivity.java#L317-L333 :) – jhakaas1708 Aug 31 '20 at 01:52

2 Answers2

0

While creating the enrollment token (QR Code) you can pass additional data in it such as a unique policyId or a unique enrollment key

EnrollmentToken enrollmentTokenBody = new EnrollmentToken
{
    PolicyName = policyId,
    AdditionalData = enrollmentKey
}

Once the device is successfully enrolled, you can call the List Devices API - enterprises.devices.list which will return all the devices enrolled to the enterprise.

You can now find the device you just enrolled with the unique policy Id or enrollment key that you passed during the QR code generation.

This is a lengthy process and would not recommend it, I'd suggest you to use Pub/Sub instead.

Sudhu
  • 565
  • 8
  • 24
  • 1
    Thought about this process and like you said it is cumbersome. With time, as more devices get provisioned, it will become slower. But are you saying, other than `List Devices API - enterprises.devices.list` and pub/sub there is no other way? Was looking at [this](https://developers.google.com/android/management/provision-device#launch_an_app_during_setup) to install and launch an app as part of provision. Was wondering if somehow the intent passed would have the `deviceId`. Any ideas? – jhakaas1708 Mar 02 '20 at 17:20
  • You can try it, but I doubt the APP that you install will have the permissions to retrieve the ```Device ID``` as it would not have device admin or device owner privileges – Sudhu Mar 03 '20 at 05:41
0

Use enterprises.device.list to list all devices for a given enterprise. However, if multiple devices are provisioned between the device list calls, it will be more difficult to align the device id to a specific device.

Deyzel
  • 186
  • 5