// #device-owner: the provisioning QR modal — factory-reset a panel, scan this during first-run // setup, and Android silently installs the player as device owner. Shared by the device detail // page and the Add Display flow so both show the exact same (always-current) QR. The checksum in // the payload is computed server-side from the SERVED apk, so it can't drift from the build. import { api } from '../api.js'; import { showToast } from './toast.js'; import { esc } from '../utils.js'; import { t } from '../i18n.js'; export async function showDeviceOwnerQRModal() { let info; try { info = await api.getDeviceOwnerQR(); } catch (e) { showToast(e.message || t('device.owner_provision.error'), 'error'); return; } // Surface whether the checksum was derived from the live APK (the safe case) or fell back to a // constant because the server has no APK to read (the QR would then point at a missing download). const fromApk = info.checksum_source === 'apk'; const verifyNote = fromApk ? t('device.owner_provision.verified_from_apk') : t('device.owner_provision.fallback_checksum'); const overlay = document.createElement('div'); overlay.className = 'modal-overlay'; overlay.style.display = 'flex'; overlay.innerHTML = ` `; document.body.appendChild(overlay); const close = () => overlay.remove(); overlay.querySelector('#doClose').onclick = close; overlay.addEventListener('click', (e) => { if (e.target === overlay) close(); }); overlay.querySelector('#doCopy').onclick = () => { navigator.clipboard?.writeText(info.adb_command) .then(() => showToast(t('device.owner_provision.copied'), 'success')).catch(() => {}); }; }