androidqr-codeprovisioningdevice-owner

QR code provisioning into Device Owner mode fails


I have a device running Android 7.1.1 and I am building sample DPC app in preparation for making a COSU kiosk app but I keep running into an error in the provisioning setup.

Steps I take:

  1. Factory reset the device
  2. Successfully scan the code from the QR provisioning screen
  3. App downloads successfully and checksum check passes. I know this because at first it kept failing at wrongly generated checksum.
  4. Installing app message passes without error.
  5. The message changes to "Setting the device owner..." and immediately fails with the generic message "Oops! Couldn't set up your device..."

I've put simple Toast in DeviceAdminReceiver subclass into onEnabled and onProvisioningComplete functions. The Toast in onEnabled is displayed, the one in onProvisioningComplete is unsuprisingly not.

The app is signed with proper release certificate, setting the device owner through adb works fine as well which also leads me to belief that component name and manifest is ok otherwise adb command would fail as well.

QR code text:

{
  "android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "component name",   
  "android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "the checksum",
  "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "the link",
  "android.app.extra.PROVISIONING_SKIP_ENCRYPTION" : "True",
  "android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED" : "True"
}

Any ideas what might be wrong ? I've run out of mine. Thanks for any input !


Solution

  • {
         "android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.my.app/com.my.app.MyDeviceAdminReceiver",   
         "android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "the checksum",
         "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "the link",
         "android.app.extra.PROVISIONING_SKIP_ENCRYPTION" : true,
         "android.app.extra.PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED" : true
    }
    

    values for PROVISIONING_SKIP_ENCRYPTION and PROVISIONING_LEAVE_ALL_SYSTEM_APPS_ENABLED should be boolean, not strings. At least its boolean in my app and it works.

    Also make sure you specified the component name of the device admin receiver in a proper way. the specified component must extend android.app.admin.DeviceAdminReceiver.