I have been passing WiFi info, locale, the DPC package and it seems all of them are working and my device gets connected with the WiFI but the enrolment token is not working. After taking a while, it says updating the device and take me to enter/scan the QR code screen to continue.
private void gatherAdminExtras(HashMap<String, String> values) {
Properties props = new Properties();
Set<String> keys = new HashSet<>(values.keySet());
for (String key : keys) {
if (key.startsWith("android.app.extra")) {
continue;
}
props.put(key, values.get(key));
values.remove(key);
}
StringWriter sw = new StringWriter();
try{
props.store(sw, "{\"com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN\": \"{Enrolment_Token}\"}");
values.put(DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE,
sw.toString());
Log.d(TAG, "Admin extras bundle=" + values.get(
DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE));
} catch (IOException e) {
Log.e(TAG, "Unable to build admin extras bundle");
}
}
Help appreciated, thanks.