Jarvis2345's picture
Squash history — remove all prior commits (secret hygiene, S4)
a31f556
Raw
History Blame
1.84 kB
import json
import base64
import io
import qrcode
import os
OMEGA_FAMILY_APK_URL = os.environ.get("OMEGA_FAMILY_APK_URL", "https://huggingface.co/spaces/Jarvis2345/jarvis-cloud/resolve/main/app-release.apk")
# Generates a QR code containing Android's standard "qr code provisioning" payload format
# (android.app.extra.PROVISIONING_*), which Android's OWN setup wizard recognizes during
# initial device setup or factory-reset-then-setup. This is the SAME mechanism legitimate
# MDM products (Google Family Link, enterprise MDM) use — not a custom accessibility hack.
async def generate_enrollment_qr(family_member_name: str) -> str:
"""
Generates a base64 encoded PNG QR code for Android Device Owner provisioning.
Requires device to be in setup wizard (factory reset state) to scan.
"""
payload = {
"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.example.service/.FamilyDeviceAdminReceiver",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": OMEGA_FAMILY_APK_URL,
"android.app.extra.PROVISIONING_LOCALE": "en_US",
"android.app.extra.PROVISIONING_SKIP_ENCRYPTION": False,
"android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE": {
"family_account_name": family_member_name
}
}
qr_data = json.dumps(payload)
# Generate QR Code image
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
qr.add_data(qr_data)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
# Convert to base64 string for the React frontend
buffered = io.BytesIO()
img.save(buffered, format="PNG")
img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
return f"data:image/png;base64,{img_str}"