Skip to content

Instantly share code, notes, and snippets.

@bashenk
Last active May 6, 2024 11:16
Show Gist options
  • Save bashenk/58c6dd883b177ee6e6ed1c533f3e8066 to your computer and use it in GitHub Desktop.
Save bashenk/58c6dd883b177ee6e6ed1c533f3e8066 to your computer and use it in GitHub Desktop.
Creating a QR Code for Android Device Enrollment

Create a QR code

Android Enterprise Documentation: Create a QR code

Always required

Required if a DPC isn't already installed on the device

Required: Either one of the two checksums below (URL-safe base64 encoded SHA-256 checksum).

Note: For devices running Build.VERSION_CODES.LOLLIPOP and Build.VERSION_CODES.LOLLIPOP_MR1, only SHA-1 hash is supported. Starting from Build.VERSION_CODES.M, this parameter accepts SHA-256 in addition to SHA-1. From Build.VERSION_CODES.Q, only SHA-256 hash is supported.

Recommended if the device isn't already connected to Wi-Fi

Optional


EMM Provisioning

Android Zero-Touch Enrollment EMM Provisioning Guide

๐Ÿ‘ EMM Recommended

Use the following intent extras to set up your DPC

๐Ÿ‘Ž EMM Not recommended

Don't include the following extras that you might use in other enrollment methods

Additional references

@rekire
Copy link

rekire commented Nov 17, 2023

Thank you very helpful just the hash calculation seems to be wrong. It should be:

sha256sum your.apk | cut -d\  -f1 | xxd -r -p| openssl base64 | tr -- '+/' '-_'

@bashenk
Copy link
Author

bashenk commented Nov 17, 2023

Thank you very helpful just the hash calculation seems to be wrong. It should be:

sha256sum your.apk | cut -d\  -f1 | xxd -r -p| openssl base64 | tr -- '+/' '-_'

Ah, that's probably much simpler than what I had. I was originally basing it off instructions available at the time, but I think toolings have been updated since then, and so I am quite confident you're right. When I get a chance I'll test it out and update the gist. I'm sure other things have changed since I created this as well, so if I'll do a check for the important/useful things while I'm at it.

@ap9101
Copy link

ap9101 commented Mar 4, 2024

Hi really helpful
but I'm stuck on Android Zero-Touch Enrollment it requires a reseller?
or we can do it without a reseller account i need to enroll in my app after a hard reset can anyone help me how this is possible?
or share steps to enroll a device with zero-touch i have a Google Workspace account but it does not work for zero touch enrollment as well.

@bashenk
Copy link
Author

bashenk commented Mar 12, 2024

@ap9101 this gist is for QR Code Enrollment in particular, not Zero-Touch Enrollment. The section on EMM Provisioning has a link to Google's Zero-Touch Enrollment guide, but I mainly only included that section for reference and completeness purposes.
As far as I know, Zero-Touch requires a reseller at least in part because they have to upload the device IMEI to their portal. To get to the QR Code enrollment screen after a hard reset, tap the welcome screen six times (opens up a QR code reader, or in older devices it'll download the QR code reader after prompting for Wi-Fi first if necessary).

@bashenk
Copy link
Author

bashenk commented Mar 12, 2024

@rekire I updated the gist to include checksum calculation for the v2 signing scheme, which has a small chance of being one of the issues you could've encountered. To be clear, I was unable to get your sha256sum version to produce the proper checksum, but I also don't have a spare device to test with a factory reset these days, so I was just checking it against one of my known-working QR codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment