@mentra/engine 3.5.0-dev.1444 → 3.5.0-dev.1462

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/build/generated/releaseMetadata.js +5 -5
  2. package/build/generated/releaseMetadata.js.map +1 -1
  3. package/build/services/HotspotOtaTransport.d.ts +1 -1
  4. package/build/services/HotspotOtaTransport.d.ts.map +1 -1
  5. package/build/services/HotspotOtaTransport.js +19 -1
  6. package/build/services/HotspotOtaTransport.js.map +1 -1
  7. package/build/services/OtaErrorMapping.d.ts.map +1 -1
  8. package/build/services/OtaErrorMapping.js +3 -0
  9. package/build/services/OtaErrorMapping.js.map +1 -1
  10. package/build/services/OtaInstallCoordinator.d.ts +7 -0
  11. package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
  12. package/build/services/OtaInstallCoordinator.js +61 -9
  13. package/build/services/OtaInstallCoordinator.js.map +1 -1
  14. package/build/services/OtaUpdateCheckService.d.ts +3 -14
  15. package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
  16. package/build/services/OtaUpdateCheckService.js +15 -25
  17. package/build/services/OtaUpdateCheckService.js.map +1 -1
  18. package/build/services/mtkDowngrade.d.ts +2 -8
  19. package/build/services/mtkDowngrade.d.ts.map +1 -1
  20. package/build/services/mtkDowngrade.js +3 -10
  21. package/build/services/mtkDowngrade.js.map +1 -1
  22. package/build/services/otaDisplayState.d.ts +2 -0
  23. package/build/services/otaDisplayState.d.ts.map +1 -1
  24. package/build/services/otaDisplayState.js +8 -1
  25. package/build/services/otaDisplayState.js.map +1 -1
  26. package/build/services/otaManifestPolicy.d.ts.map +1 -1
  27. package/build/services/otaManifestPolicy.js +4 -0
  28. package/build/services/otaManifestPolicy.js.map +1 -1
  29. package/build/services/otaManifestUrl.d.ts +2 -0
  30. package/build/services/otaManifestUrl.d.ts.map +1 -1
  31. package/build/services/otaManifestUrl.js +4 -0
  32. package/build/services/otaManifestUrl.js.map +1 -1
  33. package/package.json +8 -8
  34. package/src/generated/releaseMetadata.ts +5 -5
  35. package/src/services/HotspotOtaTransport.ts +20 -1
  36. package/src/services/OtaErrorMapping.ts +4 -0
  37. package/src/services/OtaInstallCoordinator.ts +61 -9
  38. package/src/services/OtaUpdateCheckService.ts +11 -34
  39. package/src/services/mtkDowngrade.ts +3 -10
  40. package/src/services/otaDisplayState.ts +10 -0
  41. package/src/services/otaManifestPolicy.ts +3 -0
  42. package/src/services/otaManifestUrl.ts +5 -0
@@ -1 +1 @@
1
- {"version":3,"file":"otaDisplayState.js","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAoBlC;IACC,MAAM,EACJ,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EACR,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,GACrB,GAAG,IAAI,CAAA;IAER,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAE7B,gFAAgF;IAChF,iFAAiF;IACjF,+EAA+E;IAC/E,6DAA6D;IAC7D,IAAI,sBAAsB;QAAE,OAAO,UAAU,CAAA;IAE7C,yEAAyE;IACzE,+EAA+E;IAC/E,oDAAoD;IACpD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,UAAU,CAAA;IACxD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,YAAY,CAAA;IAE1D,sFAAsF;IACtF,sFAAsF;IACtF,yFAAyF;IACzF,sFAAsF;IACtF,wFAAwF;IACxF,wEAAwE;IACxE,MAAM,kBAAkB,GAAG,SAAS,EAAE,QAAQ,KAAK,KAAK,IAAI,SAAS,EAAE,QAAQ,KAAK,KAAK,CAAA;IACzF,IAAI,oBAAoB,IAAI,SAAS,EAAE,MA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n\nimport {isLegacyShapedOtaStatus} from \"./otaInstallPolicy\"\n\nexport type DisplayState = \"starting\" | \"updating\" | \"complete\" | \"failed\" | \"disconnected\" | \"restarting\"\n\n/**\n * Pure derivation of the OTA progress UI state from the glasses data in the\n * Zustand store plus a couple of genuinely-local inputs. See\n * OtaInstallCoordinator.ts for the state machine that consumes this (the host\n * progress screen renders its snapshot).\n *\n * Legacy shape (WP 8C): old (< 37) ASG builds send `ota_progress`, which the SDK\n * maps to ota_status with sessionId \"\" and FINISHED→\"complete\" at ANY phase. For\n * those statuses a download-phase \"complete\" only means the download finished\n * (the install is still ahead), and an apk install \"complete\" may be held by the\n * coordinator's settle window — both stay \"updating\" instead of terminal.\n *\n * Priority-ordered rules (first match wins):\n * 1. errorMsg !== \"\" -> \"failed\"\n * 2. BES reboot recovery complete -> \"complete\"\n * 3. BES reboot recovery awaiting reconnect -> \"restarting\"\n * 4. BES terminal (any connection state) -> \"restarting\"\n * (legacy-shaped BES \"complete\" counts only in install phase)\n * 6. apkCompletedViaBuildIncrease (legacy build-number port) -> \"complete\"\n * 7. otaStatus.status === \"failed\" -> \"failed\"\n * 8. otaStatus.status === \"complete\" (non-BES) -> \"complete\"\n * (unless legacy-shaped download-complete or held apk settle -> in flight)\n * 9. !connected + legacy in-flight complete (held apk) -> \"updating\"\n * 10. !connected + APK step_complete with totalSteps > 1 -> \"starting\" (expected reboot)\n * 11. !connected + BES in flight -> \"restarting\" (defensive)\n * 12. !connected -> \"disconnected\"\n * 13. connected + in_progress | step_complete | legacy in-flight complete -> \"updating\"\n * 14. fallback -> \"starting\"\n */\nexport function deriveDisplayState(args: {\n otaStatus: OtaStatus | null\n otaProgress: OtaProgress | null\n connected: boolean\n errorMsg: string\n /**\n * Retained for host API compatibility. A session-wide reconnect edge is not\n * sufficient for BES completion because it may belong to an earlier APK step.\n */\n sawReconnectEdge: boolean\n /** Coordinator is holding a legacy apk install \"complete\" for the settle window (WP 8C). */\n legacyApkSettleHold?: boolean\n /** Legacy APK completion detected by build-number increase (WP 8C). */\n apkCompletedViaBuildIncrease?: boolean\n /** Phone-observed BES disconnect/reconnect recovery, independent of stale OTA progress. */\n besRestartRecovery?: \"awaiting\" | \"complete\" | null\n /** Downgrade detour: the reconnected glasses reported exactly the pinned target version. */\n versionChangeConverged?: boolean\n /** True for the whole downgrade (version-change) session. */\n versionChangeSession?: boolean\n}): DisplayState {\n const {\n otaStatus,\n otaProgress,\n connected,\n errorMsg,\n legacyApkSettleHold,\n apkCompletedViaBuildIncrease,\n besRestartRecovery,\n versionChangeConverged,\n versionChangeSession,\n } = args\n\n if (errorMsg) return \"failed\"\n\n // Downgrade detour completion: exact-version convergence after reconnect is the\n // only completion signal (the wipe destroys ASG's ota_session, and the target is\n // a LOWER build so no build-number increase fires). Outranks the stale install\n // status still sitting in the store from before the handoff.\n if (versionChangeConverged) return \"complete\"\n\n // A BES reboot destroys or strands the glasses-side OTA session on older\n // clients. Once the phone observed that reboot, stale pre-reboot progress must\n // not move the UI from restarting back to updating.\n if (besRestartRecovery === \"complete\") return \"complete\"\n if (besRestartRecovery === \"awaiting\") return \"restarting\"\n\n // In a version-change session, convergence (above) is the ONLY completion for the ASG\n // downgrade. A bare non-firmware \"complete\" before convergence — the glasses refusing\n // the downgrade (floor/gate) with no install, or a stale pre-handoff status — must never\n // present as success. Firmware-step completions (mtk/bes) DO pass through: a combined\n // downgrade+firmware manifest applies firmware first on its own pass, which must finish\n // so the phone re-checks and re-offers the now-firmware-free downgrade.\n const isFirmwareComplete = otaStatus?.stepType === \"mtk\" || otaStatus?.stepType === \"bes\"\n if (versionChangeSession && otaStatus?.status === \"complete\" && !isFirmwareComplete) {\n return connected ? \"updating\" : \"disconnected\"\n }\n\n // Download completion is never proof that the BES flash ran or rebooted.\n const besDownloadComplete =\n otaStatus?.stepType === \"bes\" &&\n otaStatus.phase === \"download\" &&\n (otaStatus.status === \"complete\" || otaStatus.status === \"step_complete\")\n if (besDownloadComplete) return connected ? \"updating\" : \"disconnected\"\n\n const besTerminal = isBesTerminal(otaStatus, otaProgress)\n if (besTerminal) return \"restarting\"\n\n // Legacy build-number APK completion: the coordinator clears errorMsg when it fires,\n // and the flag outranks whatever stale legacy status is still in the store (the old\n // screen's last-write-wins completion from starting/failed/installing).\n if (apkCompletedViaBuildIncrease) return \"complete\"\n\n if (otaStatus?.status === \"failed\") return \"failed\"\n\n // Legacy-shaped \"complete\" that is still in flight: a download-phase FINISHED (the\n // install is still ahead), or an apk install FINISHED held by the settle window.\n const legacyInFlightComplete =\n isLegacyShapedOtaStatus(otaStatus) &&\n otaStatus?.status === \"complete\" &&\n (otaStatus.phase === \"download\" ||\n (!!legacyApkSettleHold && otaStatus.stepType === \"apk\" && otaStatus.phase === \"install\"))\n\n if (otaStatus?.status === \"complete\" && !legacyInFlightComplete) return \"complete\"\n\n if (!connected) {\n // The held apk install complete means the glasses are restarting into the new\n // build — the legacy screen kept showing \"installing\" through that restart.\n if (legacyInFlightComplete && otaStatus?.phase === \"install\") return \"updating\"\n\n // By here, the failed/complete rules already returned for terminal statuses.\n // For APK multi-step, \"step_complete\" means the current step ended and the\n // glasses are rebooting to start the next one.\n const apkRebootExpected =\n otaStatus?.stepType === \"apk\" && (otaStatus?.totalSteps ?? 0) > 1 && otaStatus.status === \"step_complete\"\n if (apkRebootExpected) return \"starting\"\n\n // A BES download has not started the flash and cannot establish an expected reboot.\n const besStatusInFlight = otaStatus?.stepType === \"bes\" && otaStatus.phase === \"install\"\n const besInFlight = besStatusInFlight || (otaProgress?.currentUpdate === \"bes\" && otaProgress?.stage === \"install\")\n if (besInFlight) return \"restarting\"\n\n return \"disconnected\"\n }\n\n if (otaStatus?.status === \"in_progress\" || otaStatus?.status === \"step_complete\" || legacyInFlightComplete) {\n return \"updating\"\n }\n\n return \"starting\"\n}\n\nfunction isBesTerminal(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null): boolean {\n if (\n otaStatus?.stepType === \"bes\" &&\n otaStatus.phase === \"install\" &&\n (otaStatus.status === \"step_complete\" || otaStatus.status === \"complete\")\n ) {\n return true\n }\n if (otaProgress?.currentUpdate === \"bes\" && otaProgress.stage === \"install\" && otaProgress.status === \"FINISHED\") {\n return true\n }\n return false\n}\n"]}
1
+ {"version":3,"file":"otaDisplayState.js","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAsBlC;IACC,MAAM,EACJ,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EACR,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,GACzB,GAAG,IAAI,CAAA;IAER,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAE7B,gFAAgF;IAChF,iFAAiF;IACjF,+EAA+E;IAC/E,6DAA6D;IAC7D,IAAI,sBAAsB;QAAE,OAAO,UAAU,CAAA;IAE7C,6FAA6F;IAC7F,yDAAyD;IACzD,IAAI,wBAAwB,EAAE,CAAC;QAC7B,IAAI,SAAS,EAAE,MAAM,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAA;QACnD,OAAO,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAA;IAC9C,CAAC;IAED,yEAAyE;IACzE,+EAA+E;IAC/E,oDAAoD;IACpD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,UAAU,CAAA;IACxD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,YAAY,CAAA;IAE1D,sFAAsF;IACtF,sFAAsF;IACtF,yFAAyF;IACzF,sFAAsF;IACtF,wFAAwF;IACxF,wEAAwE;IACxE,MAAM,kBAAkB,GAAG,SAAS,EAAE,QAAQ,KAAK,KAAK,IAAI,SAAS,EAAE,QAAQ,KAAK,KAAK,CAAA;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OtaProgress, OtaStatus} from \"@mentra/bluetooth-sdk\"\n\nimport {isLegacyShapedOtaStatus} from \"./otaInstallPolicy\"\n\nexport type DisplayState = \"starting\" | \"updating\" | \"complete\" | \"failed\" | \"disconnected\" | \"restarting\"\n\n/**\n * Pure derivation of the OTA progress UI state from the glasses data in the\n * Zustand store plus a couple of genuinely-local inputs. See\n * OtaInstallCoordinator.ts for the state machine that consumes this (the host\n * progress screen renders its snapshot).\n *\n * Legacy shape (WP 8C): old (< 37) ASG builds send `ota_progress`, which the SDK\n * maps to ota_status with sessionId \"\" and FINISHED→\"complete\" at ANY phase. For\n * those statuses a download-phase \"complete\" only means the download finished\n * (the install is still ahead), and an apk install \"complete\" may be held by the\n * coordinator's settle window — both stay \"updating\" instead of terminal.\n *\n * Priority-ordered rules (first match wins):\n * 1. errorMsg !== \"\" -> \"failed\"\n * 2. BES reboot recovery complete -> \"complete\"\n * 3. BES reboot recovery awaiting reconnect -> \"restarting\"\n * 4. BES terminal (any connection state) -> \"restarting\"\n * (legacy-shaped BES \"complete\" counts only in install phase)\n * 6. apkCompletedViaBuildIncrease (legacy build-number port) -> \"complete\"\n * 7. otaStatus.status === \"failed\" -> \"failed\"\n * 8. otaStatus.status === \"complete\" (non-BES) -> \"complete\"\n * (unless legacy-shaped download-complete or held apk settle -> in flight)\n * 9. !connected + legacy in-flight complete (held apk) -> \"updating\"\n * 10. !connected + APK step_complete with totalSteps > 1 -> \"starting\" (expected reboot)\n * 11. !connected + BES in flight -> \"restarting\" (defensive)\n * 12. !connected -> \"disconnected\"\n * 13. connected + in_progress | step_complete | legacy in-flight complete -> \"updating\"\n * 14. fallback -> \"starting\"\n */\nexport function deriveDisplayState(args: {\n otaStatus: OtaStatus | null\n otaProgress: OtaProgress | null\n connected: boolean\n errorMsg: string\n /**\n * Retained for host API compatibility. A session-wide reconnect edge is not\n * sufficient for BES completion because it may belong to an earlier APK step.\n */\n sawReconnectEdge: boolean\n /** Coordinator is holding a legacy apk install \"complete\" for the settle window (WP 8C). */\n legacyApkSettleHold?: boolean\n /** Legacy APK completion detected by build-number increase (WP 8C). */\n apkCompletedViaBuildIncrease?: boolean\n /** Phone-observed BES disconnect/reconnect recovery, independent of stale OTA progress. */\n besRestartRecovery?: \"awaiting\" | \"complete\" | null\n /** Downgrade detour: the reconnected glasses reported exactly the pinned target version. */\n versionChangeConverged?: boolean\n /** True for the whole downgrade (version-change) session. */\n versionChangeSession?: boolean\n /** Detour wait that began at the firmware's completion, before the glasses' own handoff. */\n versionChangeAfterReboot?: boolean\n}): DisplayState {\n const {\n otaStatus,\n otaProgress,\n connected,\n errorMsg,\n legacyApkSettleHold,\n apkCompletedViaBuildIncrease,\n besRestartRecovery,\n versionChangeConverged,\n versionChangeSession,\n versionChangeAfterReboot,\n } = args\n\n if (errorMsg) return \"failed\"\n\n // Downgrade detour completion: exact-version convergence after reconnect is the\n // only completion signal (the wipe destroys ASG's ota_session, and the target is\n // a LOWER build so no build-number increase fires). Outranks the stale install\n // status still sitting in the store from before the handoff.\n if (versionChangeConverged) return \"complete\"\n\n // The firmware's terminal status stays in the store across the reboot that applies it; it is\n // the start of the glasses' own downgrade, not a result.\n if (versionChangeAfterReboot) {\n if (otaStatus?.status === \"failed\") return \"failed\"\n return connected ? \"updating\" : \"restarting\"\n }\n\n // A BES reboot destroys or strands the glasses-side OTA session on older\n // clients. Once the phone observed that reboot, stale pre-reboot progress must\n // not move the UI from restarting back to updating.\n if (besRestartRecovery === \"complete\") return \"complete\"\n if (besRestartRecovery === \"awaiting\") return \"restarting\"\n\n // In a version-change session, convergence (above) is the ONLY completion for the ASG\n // downgrade. A bare non-firmware \"complete\" before convergence — the glasses refusing\n // the downgrade (floor/gate) with no install, or a stale pre-handoff status — must never\n // present as success. Firmware-step completions (mtk/bes) DO pass through: a combined\n // downgrade+firmware manifest applies firmware first on its own pass, which must finish\n // so the phone re-checks and re-offers the now-firmware-free downgrade.\n const isFirmwareComplete = otaStatus?.stepType === \"mtk\" || otaStatus?.stepType === \"bes\"\n if (versionChangeSession && otaStatus?.status === \"complete\" && !isFirmwareComplete) {\n return connected ? \"updating\" : \"disconnected\"\n }\n\n // Download completion is never proof that the BES flash ran or rebooted.\n const besDownloadComplete =\n otaStatus?.stepType === \"bes\" &&\n otaStatus.phase === \"download\" &&\n (otaStatus.status === \"complete\" || otaStatus.status === \"step_complete\")\n if (besDownloadComplete) return connected ? \"updating\" : \"disconnected\"\n\n const besTerminal = isBesTerminal(otaStatus, otaProgress)\n if (besTerminal) return \"restarting\"\n\n // Legacy build-number APK completion: the coordinator clears errorMsg when it fires,\n // and the flag outranks whatever stale legacy status is still in the store (the old\n // screen's last-write-wins completion from starting/failed/installing).\n if (apkCompletedViaBuildIncrease) return \"complete\"\n\n if (otaStatus?.status === \"failed\") return \"failed\"\n\n // Legacy-shaped \"complete\" that is still in flight: a download-phase FINISHED (the\n // install is still ahead), or an apk install FINISHED held by the settle window.\n const legacyInFlightComplete =\n isLegacyShapedOtaStatus(otaStatus) &&\n otaStatus?.status === \"complete\" &&\n (otaStatus.phase === \"download\" ||\n (!!legacyApkSettleHold && otaStatus.stepType === \"apk\" && otaStatus.phase === \"install\"))\n\n if (otaStatus?.status === \"complete\" && !legacyInFlightComplete) return \"complete\"\n\n if (!connected) {\n // The held apk install complete means the glasses are restarting into the new\n // build — the legacy screen kept showing \"installing\" through that restart.\n if (legacyInFlightComplete && otaStatus?.phase === \"install\") return \"updating\"\n\n // By here, the failed/complete rules already returned for terminal statuses.\n // For APK multi-step, \"step_complete\" means the current step ended and the\n // glasses are rebooting to start the next one.\n const apkRebootExpected =\n otaStatus?.stepType === \"apk\" && (otaStatus?.totalSteps ?? 0) > 1 && otaStatus.status === \"step_complete\"\n if (apkRebootExpected) return \"starting\"\n\n // A BES download has not started the flash and cannot establish an expected reboot.\n const besStatusInFlight = otaStatus?.stepType === \"bes\" && otaStatus.phase === \"install\"\n const besInFlight = besStatusInFlight || (otaProgress?.currentUpdate === \"bes\" && otaProgress?.stage === \"install\")\n if (besInFlight) return \"restarting\"\n\n return \"disconnected\"\n }\n\n if (otaStatus?.status === \"in_progress\" || otaStatus?.status === \"step_complete\" || legacyInFlightComplete) {\n return \"updating\"\n }\n\n return \"starting\"\n}\n\nfunction isBesTerminal(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null): boolean {\n if (\n otaStatus?.stepType === \"bes\" &&\n otaStatus.phase === \"install\" &&\n (otaStatus.status === \"step_complete\" || otaStatus.status === \"complete\")\n ) {\n return true\n }\n if (otaProgress?.currentUpdate === \"bes\" && otaProgress.stage === \"install\" && otaProgress.status === \"FINISHED\") {\n return true\n }\n return false\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"otaManifestPolicy.d.ts","sourceRoot":"","sources":["../../src/services/otaManifestPolicy.ts"],"names":[],"mappings":"AAOA,wBAAgB,wBAAwB,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGpF;AAED,wBAAgB,0BAA0B,CAAC,EACzC,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,EAAE;IACD,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC,GAAG,MAAM,GAAG,IAAI,CAEhB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC,GAAG,MAAM,GAAG,IAAI,C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G"}
@@ -12,6 +12,10 @@ export function selectModernOtaManifestPin({ developerOverride, hostReleasePin,
12
12
  }
13
13
  export function resolveOtaManifestPolicy({ glassesUrl, glassesBuildNumber, developerOverride, hostReleasePin, engineReleasePin, }) {
14
14
  if (isLegacyAsgOtaStartBuild(glassesBuildNumber)) {
15
+ // A service app before 39 can't take a manifest URL, so with an override set these glasses are where it took them
16
+ // (an older set): every check says up to date until the override is cleared, then they follow production.
17
+ if (trimmed(developerOverride))
18
+ return null;
15
19
  return trimmed(glassesUrl) || OTA_VERSION_URL_LEGACY_PROD;
16
20
  }
17
21
  return selectModernOtaManifestPin({ developerOverride, hostReleasePin, engineReleasePin });
@@ -1 +1 @@
1
- {"version":3,"file":"otaManifestPolicy.js","sourceRoot":"","sources":["../../src/services/otaManifestPolicy.ts"],"names":[],"mappings":"AAAA,MAAM,2BAA2B,GAAG,oDAAoD,CAAA;AAExF,SAAS,OAAO,CAAC,KAAqB;IACpC,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;IAC5B,OAAO,MAAM,IAAI,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,kBAAkC;IACzE,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IACjE,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,EAAE,CAAA;AACzD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EACzC,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAKjB;IACC,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC3F,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAOjB;IACC,IAAI,wBAAwB,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACjD,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,2BAA2B,CAAA;IAC3D,CAAC;IACD,OAAO,0BAA0B,CAAC,EAAC,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAC,CAAC,CAAA;AAC1F,CAAC;AAED,MAAM,UAAU,uCAAuC,CAAC,EACtD,oBAAoB,EACpB,GAAG,MAAM,EACwE;IACjF,0EAA0E;IAC1E,4EAA4E;IAC5E,yDAAyD;IACzD,IAAI,oBAAoB;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IACpG,OAAO,wBAAwB,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC","sourcesContent":["const OTA_VERSION_URL_LEGACY_PROD = \"https://ota.mentraglass.com/prod_live_version.json\"\n\nfunction trimmed(value?: string | null): string | null {\n const result = value?.trim()\n return result || null\n}\n\nexport function isLegacyAsgOtaStartBuild(glassesBuildNumber?: string | null): boolean {\n const buildNumber = Number.parseInt(glassesBuildNumber ?? \"\", 10)\n return Number.isFinite(buildNumber) && buildNumber < 39\n}\n\nexport function selectModernOtaManifestPin({\n developerOverride,\n hostReleasePin,\n engineReleasePin,\n}: {\n developerOverride?: string | null\n hostReleasePin?: string | null\n engineReleasePin?: string | null\n}): string | null {\n return trimmed(developerOverride) || trimmed(hostReleasePin) || trimmed(engineReleasePin)\n}\n\nexport function resolveOtaManifestPolicy({\n glassesUrl,\n glassesBuildNumber,\n developerOverride,\n hostReleasePin,\n engineReleasePin,\n}: {\n glassesUrl?: string | null\n glassesBuildNumber?: string | null\n developerOverride?: string | null\n hostReleasePin?: string | null\n engineReleasePin?: string | null\n}): string | null {\n if (isLegacyAsgOtaStartBuild(glassesBuildNumber)) {\n return trimmed(glassesUrl) || OTA_VERSION_URL_LEGACY_PROD\n }\n return selectModernOtaManifestPin({developerOverride, hostReleasePin, engineReleasePin})\n}\n\nexport function resolveDeploymentAwareOtaManifestPolicy({\n hostPolicyConfigured,\n ...policy\n}: Parameters<typeof resolveOtaManifestPolicy>[0] & {hostPolicyConfigured: boolean}): string | null {\n // A selected deployment is authoritative for every glasses generation. An\n // explicit null is a deliberate OTA-off policy, not permission to inherit a\n // device-reported URL or Mentra's legacy public default.\n if (hostPolicyConfigured) return trimmed(policy.developerOverride) || trimmed(policy.hostReleasePin)\n return resolveOtaManifestPolicy(policy)\n}\n"]}
1
+ {"version":3,"file":"otaManifestPolicy.js","sourceRoot":"","sources":["../../src/services/otaManifestPolicy.ts"],"names":[],"mappings":"AAAA,MAAM,2BAA2B,GAAG,oDAAoD,CAAA;AAExF,SAAS,OAAO,CAAC,KAAqB;IACpC,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;IAC5B,OAAO,MAAM,IAAI,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,kBAAkC;IACzE,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IACjE,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,EAAE,CAAA;AACzD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EACzC,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAKjB;IACC,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC3F,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GAOjB;IACC,IAAI,wBAAwB,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACjD,kHAAkH;QAClH,0GAA0G;QAC1G,IAAI,OAAO,CAAC,iBAAiB,CAAC;YAAE,OAAO,IAAI,CAAA;QAC3C,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,2BAA2B,CAAA;IAC3D,CAAC;IACD,OAAO,0BAA0B,CAAC,EAAC,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAC,CAAC,CAAA;AAC1F,CAAC;AAED,MAAM,UAAU,uCAAuC,CAAC,EACtD,oBAAoB,EACpB,GAAG,MAAM,EACwE;IACjF,0EAA0E;IAC1E,4EAA4E;IAC5E,yDAAyD;IACzD,IAAI,oBAAoB;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IACpG,OAAO,wBAAwB,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC","sourcesContent":["const OTA_VERSION_URL_LEGACY_PROD = \"https://ota.mentraglass.com/prod_live_version.json\"\n\nfunction trimmed(value?: string | null): string | null {\n const result = value?.trim()\n return result || null\n}\n\nexport function isLegacyAsgOtaStartBuild(glassesBuildNumber?: string | null): boolean {\n const buildNumber = Number.parseInt(glassesBuildNumber ?? \"\", 10)\n return Number.isFinite(buildNumber) && buildNumber < 39\n}\n\nexport function selectModernOtaManifestPin({\n developerOverride,\n hostReleasePin,\n engineReleasePin,\n}: {\n developerOverride?: string | null\n hostReleasePin?: string | null\n engineReleasePin?: string | null\n}): string | null {\n return trimmed(developerOverride) || trimmed(hostReleasePin) || trimmed(engineReleasePin)\n}\n\nexport function resolveOtaManifestPolicy({\n glassesUrl,\n glassesBuildNumber,\n developerOverride,\n hostReleasePin,\n engineReleasePin,\n}: {\n glassesUrl?: string | null\n glassesBuildNumber?: string | null\n developerOverride?: string | null\n hostReleasePin?: string | null\n engineReleasePin?: string | null\n}): string | null {\n if (isLegacyAsgOtaStartBuild(glassesBuildNumber)) {\n // A service app before 39 can't take a manifest URL, so with an override set these glasses are where it took them\n // (an older set): every check says up to date until the override is cleared, then they follow production.\n if (trimmed(developerOverride)) return null\n return trimmed(glassesUrl) || OTA_VERSION_URL_LEGACY_PROD\n }\n return selectModernOtaManifestPin({developerOverride, hostReleasePin, engineReleasePin})\n}\n\nexport function resolveDeploymentAwareOtaManifestPolicy({\n hostPolicyConfigured,\n ...policy\n}: Parameters<typeof resolveOtaManifestPolicy>[0] & {hostPolicyConfigured: boolean}): string | null {\n // A selected deployment is authoritative for every glasses generation. An\n // explicit null is a deliberate OTA-off policy, not permission to inherit a\n // device-reported URL or Mentra's legacy public default.\n if (hostPolicyConfigured) return trimmed(policy.developerOverride) || trimmed(policy.hostReleasePin)\n return resolveOtaManifestPolicy(policy)\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  export declare function hasConfiguredModernOtaManifestPin(): boolean;
2
2
  /** Legacy rescue manifests are intermediate targets before the release pin can be used. */
3
3
  export declare function isLegacyOtaManifestSelected(glassesBuildNumber?: string | null): boolean;
4
+ /** An override is set, and these glasses' service app can't take a manifest URL: they are where it took them. */
5
+ export declare function isHeldByOtaOverride(glassesBuildNumber?: string | null): boolean;
4
6
  export declare function resolveOtaManifestUrl(glassesUrl?: string | null, glassesBuildNumber?: string | null): string | null;
5
7
  //# sourceMappingURL=otaManifestUrl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"otaManifestUrl.d.ts","sourceRoot":"","sources":["../../src/services/otaManifestUrl.ts"],"names":[],"mappings":"AAqCA,wBAAgB,iCAAiC,IAAI,OAAO,CAQ3D;AAED,2FAA2F;AAC3F,wBAAgB,2BAA2B,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEvF;AAED,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CASnH"}
1
+ {"version":3,"file":"otaManifestUrl.d.ts","sourceRoot":"","sources":["../../src/services/otaManifestUrl.ts"],"names":[],"mappings":"AAqCA,wBAAgB,iCAAiC,IAAI,OAAO,CAQ3D;AAED,2FAA2F;AAC3F,wBAAgB,2BAA2B,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEvF;AAED,iHAAiH;AACjH,wBAAgB,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE/E;AAED,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CASnH"}
@@ -38,6 +38,10 @@ export function hasConfiguredModernOtaManifestPin() {
38
38
  export function isLegacyOtaManifestSelected(glassesBuildNumber) {
39
39
  return !hasDeploymentOtaPolicy() && isLegacyAsgOtaStartBuild(glassesBuildNumber);
40
40
  }
41
+ /** An override is set, and these glasses' service app can't take a manifest URL: they are where it took them. */
42
+ export function isHeldByOtaOverride(glassesBuildNumber) {
43
+ return Boolean(getOtaVersionUrlDevOverride()) && isLegacyOtaManifestSelected(glassesBuildNumber);
44
+ }
41
45
  export function resolveOtaManifestUrl(glassesUrl, glassesBuildNumber) {
42
46
  return resolveDeploymentAwareOtaManifestPolicy({
43
47
  hostPolicyConfigured: hasDeploymentOtaPolicy(),
@@ -1 +1 @@
1
- {"version":3,"file":"otaManifestUrl.js","sourceRoot":"","sources":["../../src/services/otaManifestUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,wBAAwB,EACxB,uCAAuC,EACvC,0BAA0B,GAC3B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAEpD,SAAS,2BAA2B;IAClC,sEAAsE;IACtE,4DAA4D;IAC5D,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UA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,sBAAsB,EAAE,IAAI,wBAAwB,CAAC,kBAAkB,CAAC,CAAA;AAClF,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,UAA0B,EAAE,kBAAkC;IAClG,OAAO,uCAAuC,CAAC;QAC7C,oBAAoB,EAAE,sBAAsB,EAAE;QAC9C,UAAU;QACV,kBAAkB;QAClB,iBAAiB,EAAE,2BAA2B,EAAE;QAChD,cAAc,EAAE,iBAAiB,EAAE;QACnC,gBAAgB,EAAE,2BAA2B,EAAE;KAChD,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {ENGINE_RELEASE_METADATA} from \"../generated/releaseMetadata\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {\n isLegacyAsgOtaStartBuild,\n resolveDeploymentAwareOtaManifestPolicy,\n selectModernOtaManifestPin,\n} from \"./otaManifestPolicy\"\nimport {getConfigValues} from \"../runtime/bootstrap\"\n\nfunction getOtaVersionUrlDevOverride(): string | null {\n // Super mode only: a wrong OTA manifest can brick glasses, so a saved\n // override is inert unless super mode is currently enabled.\n if (!useSettingsStore.getState().getSetting(SETTINGS.super_mode.key)) {\n return null\n }\n const value = useSettingsStore.getState().getSetting(SETTINGS.ota_version_url.key)\n const trimmed = typeof value === \"string\" ? value.trim() : \"\"\n return trimmed || null\n}\n\nfunction getHostReleasePin(): string | null {\n const configured = getConfigValues().otaManifestUrl\n if (configured !== undefined) return configured?.trim() || null\n const value = process.env.EXPO_PUBLIC_ASG_OTA_VERSION_URL?.trim()\n return value || null\n}\n\nfunction hasDeploymentOtaPolicy(): boolean {\n const config = getConfigValues()\n return config.otaManifestUrl !== undefined && !config.allowLegacyOtaFallback\n}\n\nfunction getEmbeddedEngineReleasePin(): string | null {\n const value = ENGINE_RELEASE_METADATA.otaManifestUrl?.trim()\n return value || null\n}\n\nexport function hasConfiguredModernOtaManifestPin(): boolean {\n return Boolean(\n selectModernOtaManifestPin({\n developerOverride: getOtaVersionUrlDevOverride(),\n hostReleasePin: getHostReleasePin(),\n engineReleasePin: getEmbeddedEngineReleasePin(),\n }),\n )\n}\n\n/** Legacy rescue manifests are intermediate targets before the release pin can be used. */\nexport function isLegacyOtaManifestSelected(glassesBuildNumber?: string | null): boolean {\n return !hasDeploymentOtaPolicy() && isLegacyAsgOtaStartBuild(glassesBuildNumber)\n}\n\nexport function resolveOtaManifestUrl(glassesUrl?: string | null, glassesBuildNumber?: string | null): string | null {\n return resolveDeploymentAwareOtaManifestPolicy({\n hostPolicyConfigured: hasDeploymentOtaPolicy(),\n glassesUrl,\n glassesBuildNumber,\n developerOverride: getOtaVersionUrlDevOverride(),\n hostReleasePin: getHostReleasePin(),\n engineReleasePin: getEmbeddedEngineReleasePin(),\n })\n}\n"]}
1
+ {"version":3,"file":"otaManifestUrl.js","sourceRoot":"","sources":["../../src/services/otaManifestUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EACL,wBAAwB,EACxB,uCAAuC,EACvC,0BAA0B,GAC3B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAEpD,SAAS,2BAA2B;IAClC,sEAAsE;IACtE,4DAA4D;IAC5D,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrE,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;IAClF,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAC7D,OAAO,OA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UAAU;QACV,kBAAkB;QAClB,iBAAiB,EAAE,2BAA2B,EAAE;QAChD,cAAc,EAAE,iBAAiB,EAAE;QACnC,gBAAgB,EAAE,2BAA2B,EAAE;KAChD,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {ENGINE_RELEASE_METADATA} from \"../generated/releaseMetadata\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {\n isLegacyAsgOtaStartBuild,\n resolveDeploymentAwareOtaManifestPolicy,\n selectModernOtaManifestPin,\n} from \"./otaManifestPolicy\"\nimport {getConfigValues} from \"../runtime/bootstrap\"\n\nfunction getOtaVersionUrlDevOverride(): string | null {\n // Super mode only: a wrong OTA manifest can brick glasses, so a saved\n // override is inert unless super mode is currently enabled.\n if (!useSettingsStore.getState().getSetting(SETTINGS.super_mode.key)) {\n return null\n }\n const value = useSettingsStore.getState().getSetting(SETTINGS.ota_version_url.key)\n const trimmed = typeof value === \"string\" ? value.trim() : \"\"\n return trimmed || null\n}\n\nfunction getHostReleasePin(): string | null {\n const configured = getConfigValues().otaManifestUrl\n if (configured !== undefined) return configured?.trim() || null\n const value = process.env.EXPO_PUBLIC_ASG_OTA_VERSION_URL?.trim()\n return value || null\n}\n\nfunction hasDeploymentOtaPolicy(): boolean {\n const config = getConfigValues()\n return config.otaManifestUrl !== undefined && !config.allowLegacyOtaFallback\n}\n\nfunction getEmbeddedEngineReleasePin(): string | null {\n const value = ENGINE_RELEASE_METADATA.otaManifestUrl?.trim()\n return value || null\n}\n\nexport function hasConfiguredModernOtaManifestPin(): boolean {\n return Boolean(\n selectModernOtaManifestPin({\n developerOverride: getOtaVersionUrlDevOverride(),\n hostReleasePin: getHostReleasePin(),\n engineReleasePin: getEmbeddedEngineReleasePin(),\n }),\n )\n}\n\n/** Legacy rescue manifests are intermediate targets before the release pin can be used. */\nexport function isLegacyOtaManifestSelected(glassesBuildNumber?: string | null): boolean {\n return !hasDeploymentOtaPolicy() && isLegacyAsgOtaStartBuild(glassesBuildNumber)\n}\n\n/** An override is set, and these glasses' service app can't take a manifest URL: they are where it took them. */\nexport function isHeldByOtaOverride(glassesBuildNumber?: string | null): boolean {\n return Boolean(getOtaVersionUrlDevOverride()) && isLegacyOtaManifestSelected(glassesBuildNumber)\n}\n\nexport function resolveOtaManifestUrl(glassesUrl?: string | null, glassesBuildNumber?: string | null): string | null {\n return resolveDeploymentAwareOtaManifestPolicy({\n hostPolicyConfigured: hasDeploymentOtaPolicy(),\n glassesUrl,\n glassesBuildNumber,\n developerOverride: getOtaVersionUrlDevOverride(),\n hostReleasePin: getHostReleasePin(),\n engineReleasePin: getEmbeddedEngineReleasePin(),\n })\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/engine",
3
- "version": "3.5.0-dev.1444",
3
+ "version": "3.5.0-dev.1462",
4
4
  "description": "Mentra Engine — miniapp registry, WebView bridge, and miniapp store",
5
5
  "main": "build/index.js",
6
6
  "react-native": "src/index.ts",
@@ -107,13 +107,13 @@
107
107
  "registry": "https://registry.npmjs.org/"
108
108
  },
109
109
  "dependencies": {
110
- "@mentra/acs-meeting": "3.5.0-dev.1444",
111
- "@mentra/glasses-media": "3.5.0-dev.1444",
112
- "@mentra/bluetooth-sdk": "3.5.0-dev.1444",
113
- "@mentra/cloud-client": "3.5.0-dev.1444",
114
- "@mentra/cloud-protocol": "3.5.0-dev.1444",
115
- "@mentra/crust": "3.5.0-dev.1444",
116
- "@mentra/miniapp": "3.5.0-dev.1444",
110
+ "@mentra/acs-meeting": "3.5.0-dev.1462",
111
+ "@mentra/glasses-media": "3.5.0-dev.1462",
112
+ "@mentra/bluetooth-sdk": "3.5.0-dev.1462",
113
+ "@mentra/cloud-client": "3.5.0-dev.1462",
114
+ "@mentra/cloud-protocol": "3.5.0-dev.1462",
115
+ "@mentra/crust": "3.5.0-dev.1462",
116
+ "@mentra/miniapp": "3.5.0-dev.1462",
117
117
  "buffer": "^6.0.3",
118
118
  "events": "^3.3.0",
119
119
  "jszip": "^3.10.1",
@@ -12,9 +12,9 @@ export interface EngineReleaseMetadata {
12
12
  export const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({
13
13
  "schemaVersion": 1,
14
14
  "familyBaseVersion": "3.5.0",
15
- "releaseIdentity": "3.5.0-dev.1444",
16
- "releaseSetId": "mentra-3.5.0-dev.1444",
17
- "sourceCommit": "63ccdcb71db404a08152316cb479af7962500ef2",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1444.json",
19
- "otaManifestSha256": "65712c897a0e98c005e8edd9a437f3e10e8dee4073482d9e161e2317e5b3ed38"
15
+ "releaseIdentity": "3.5.0-dev.1462",
16
+ "releaseSetId": "mentra-3.5.0-dev.1462",
17
+ "sourceCommit": "4dc658df98cc64e6d48d0bbaaf7cc7e10803a6f6",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1462.json",
19
+ "otaManifestSha256": "2c1cb9011d6d725760a395c3a2f35fa1c6c6f31159cc729963fa404d9851c1c9"
20
20
  })
@@ -40,11 +40,16 @@ export type HotspotOtaProgress = {
40
40
  export type HotspotOtaErrorCode =
41
41
  | "hotspot_wifi_permission_denied"
42
42
  | "hotspot_wifi_disabled"
43
+ | "hotspot_location_denied"
43
44
  | "hotspot_start_failed"
44
45
  | "hotspot_join_failed"
45
46
  | "hotspot_other_glasses"
46
47
  | "hotspot_server_failed"
47
48
 
49
+ /** Mac causes that need Location Services and Mentra's Location access, not Wi-Fi. */
50
+ const MAC_LOCATION_CAUSE =
51
+ /^(Location (access is|services are) required to |Mac hotspot Location authorization is unavailable)/
52
+
48
53
  /** Joins after the first that may land on other glasses before the update stops and says so. */
49
54
  const WRONG_GLASSES_REJOINS = 2
50
55
 
@@ -81,6 +86,16 @@ class HotspotOtaTransport {
81
86
  const ownerRevision = otaDeviceSessionRevision()
82
87
  if (this.teardownPromise) await this.teardownPromise
83
88
  if (ownerRevision !== otaDeviceSessionRevision()) throw new Error("The OTA glasses have changed")
89
+ // A teardown whose hotspot shutdown went unconfirmed (glasses whose replies are queued behind
90
+ // a file transfer) leaves its cleanup here. Retry it rather than refuse every later attempt.
91
+ if (this.releaseHotspot && !this.active && !this.preparing) {
92
+ try {
93
+ await this.teardown()
94
+ } catch (cleanupError) {
95
+ console.warn("[OTA_PROGRESS] leftover cleanup failed", localNetworkErrorDetails(cleanupError))
96
+ }
97
+ if (ownerRevision !== otaDeviceSessionRevision()) throw new Error("The OTA glasses have changed")
98
+ }
84
99
  if (
85
100
  this.releaseHotspot ||
86
101
  this.active ||
@@ -215,7 +230,11 @@ class HotspotOtaTransport {
215
230
  if (Platform.OS === "android" && (await WifiManager.isEnabled().catch(() => true)) === false) {
216
231
  throw new HotspotOtaTransportError("hotspot_wifi_disabled", "Phone Wi-Fi is off")
217
232
  }
218
- throw new HotspotOtaTransportError("hotspot_join_failed", message, localNetworkErrorDetails(error))
233
+ const nativeError = localNetworkErrorDetails(error)
234
+ if (MAC_LOCATION_CAUSE.test(nativeError.message ?? "")) {
235
+ throw new HotspotOtaTransportError("hotspot_location_denied", message, nativeError)
236
+ }
237
+ throw new HotspotOtaTransportError("hotspot_join_failed", message, nativeError)
219
238
  }
220
239
  throw new HotspotOtaTransportError("hotspot_server_failed", message)
221
240
  }
@@ -81,6 +81,8 @@ export function phoneOtaErrorCopyKey(error: unknown, os?: string): string {
81
81
  return "ota:errorPhoneNearbyPermission"
82
82
  case "hotspot_wifi_disabled":
83
83
  return "ota:errorPhoneWifiOff"
84
+ case "hotspot_location_denied":
85
+ return "ota:errorMacLocation"
84
86
  case "hotspot_start_failed":
85
87
  return "ota:errorGlassesHotspotStart"
86
88
  case "hotspot_join_failed":
@@ -143,6 +145,8 @@ export const OTA_ERROR_ENGLISH_COPY: Readonly<Record<string, string>> = {
143
145
  "ota:errorPhoneVerify": "The update file could not be verified. Please try again later.",
144
146
  "ota:errorPhoneNearbyPermission": "Allow nearby devices access so your phone can connect to your glasses.",
145
147
  "ota:errorPhoneWifiOff": "Turn on your phone’s Wi-Fi so it can connect to your glasses, then try again.",
148
+ "ota:errorMacLocation":
149
+ "This Mac needs Location access to find your glasses’ Wi-Fi. In System Settings, open Privacy & Security, turn on Location Services and allow Mentra, then try again.",
146
150
  "ota:errorGlassesHotspotStart":
147
151
  "Your glasses could not start the connection needed for the update. Please try again.",
148
152
  "ota:errorPhoneHotspotJoin": "Your phone could not connect to your glasses for the update. Please try again.",
@@ -246,6 +246,11 @@ class OtaInstallCoordinator {
246
246
  private versionChangeInstallStarted = false
247
247
  // Latched when a reconnect reports buildNumber === versionChangeTarget.
248
248
  private versionChangeConverged = false
249
+ // Set when the glasses download the pin as the first step of a firmware pass: they hand it
250
+ // to recovery themselves after the firmware reboot (the detour only lands on the new MTK
251
+ // slot), so the firmware's completion starts the detour wait instead of ending the pass.
252
+ // Older glasses plan no apk step next to firmware in a downgrade and keep the two passes.
253
+ private versionChangeAfterReboot = false
249
254
  // Holds a legacy apk install FINISHED out of "complete" for the settle window.
250
255
  private legacyApkSettleHold = false
251
256
  // Display-only legacy MTK install stall simulation.
@@ -580,6 +585,7 @@ class OtaInstallCoordinator {
580
585
  besRestartRecovery: this.besRestartRecovery,
581
586
  versionChangeConverged: this.versionChangeConverged,
582
587
  versionChangeSession: this.versionChangeSession,
588
+ versionChangeAfterReboot: this.versionChangeAfterReboot && this.isInVersionChangeDetour(),
583
589
  }),
584
590
  errorMsg: this.errorMsg,
585
591
  errorCopyKey: this.errorCopyKey,
@@ -672,6 +678,7 @@ class OtaInstallCoordinator {
672
678
  this.versionChangeTarget = null
673
679
  this.versionChangeInstallStarted = false
674
680
  this.versionChangeConverged = false
681
+ this.versionChangeAfterReboot = false
675
682
  this.legacyApkSettleHold = false
676
683
  this.mtkSimulatedPercent = null
677
684
  this.lastRealMtkProgress = 0
@@ -861,7 +868,9 @@ class OtaInstallCoordinator {
861
868
 
862
869
  const legacySession = this.isLegacySessionShapeNow()
863
870
 
864
- if (this.isBesRestartExpected(otaStatus, otaProgress, legacySession)) {
871
+ this.runVersionChangeAfterRebootPass(otaStatus)
872
+
873
+ if (!this.isInVersionChangeDetour() && this.isBesRestartExpected(otaStatus, otaProgress, legacySession)) {
865
874
  this.besRestartExpected = true
866
875
  }
867
876
 
@@ -886,6 +895,7 @@ class OtaInstallCoordinator {
886
895
  besRestartRecovery: this.besRestartRecovery,
887
896
  versionChangeConverged: this.versionChangeConverged,
888
897
  versionChangeSession: this.versionChangeSession,
898
+ versionChangeAfterReboot: this.versionChangeAfterReboot && this.isInVersionChangeDetour(),
889
899
  })
890
900
  if (otaStatusChanged && otaStatus?.status === "failed") this.reportFailure("device_failed")
891
901
  else if (otaProgressChanged && !otaStatus && otaProgress?.status === "FAILED") this.reportFailure("device_failed")
@@ -1002,7 +1012,10 @@ class OtaInstallCoordinator {
1002
1012
  (otaStatus.error === "downgrade_not_owned" ||
1003
1013
  otaStatus.error === "downgrade_handoff_refused" ||
1004
1014
  otaStatus.error === "downgrade_handoff_failed" ||
1005
- otaStatus.error === "downgrade_transaction_stalled")
1015
+ otaStatus.error === "downgrade_transaction_stalled" ||
1016
+ // Before the post-reboot handoff any failure (a firmware step's included) means no
1017
+ // transaction owns the detour; only the unknown status keeps waiting.
1018
+ (this.versionChangeAfterReboot && otaStatus.error !== "downgrade_status_unknown"))
1006
1019
  ) {
1007
1020
  console.log(
1008
1021
  `[OTA_PROGRESS] version-change: no transaction owns the detour (${otaStatus.error}) — releasing latch`,
@@ -1011,9 +1024,10 @@ class OtaInstallCoordinator {
1011
1024
  this.emitInternalChange()
1012
1025
  }
1013
1026
 
1014
- // Version-change convergence: the reconnected glasses report exactly the pinned
1015
- // target. This is the ONLY completion signal for a downgrade (lower build, no
1016
- // increase, wiped session). Mirrors the legacy build-increase latch but by equality.
1027
+ // Version-change convergence: the reconnected glasses report the pinned target. This is
1028
+ // the ONLY completion signal for a downgrade (lower build, no increase, wiped session).
1029
+ // A build above the pin but below the one the session started from also converges: an
1030
+ // older service app can update itself over Wi-Fi seconds after the pin starts.
1017
1031
  if (
1018
1032
  this.versionChangeSession &&
1019
1033
  this.versionChangeInstallStarted &&
@@ -1023,7 +1037,11 @@ class OtaInstallCoordinator {
1023
1037
  buildNumber
1024
1038
  ) {
1025
1039
  const currentBuild = Number.parseInt(buildNumber, 10)
1026
- if (Number.isFinite(currentBuild) && currentBuild === this.versionChangeTarget) {
1040
+ const startBuild = Number.parseInt(this.initialBuildNumber ?? "", 10)
1041
+ const reached =
1042
+ currentBuild === this.versionChangeTarget ||
1043
+ (currentBuild > this.versionChangeTarget && Number.isFinite(startBuild) && currentBuild < startBuild)
1044
+ if (Number.isFinite(currentBuild) && reached) {
1027
1045
  console.log(`[OTA_PROGRESS] version-change converged: glasses report target ${currentBuild}, completing`)
1028
1046
  this.clearPerStepTimers()
1029
1047
  this.clearGlobalTimeout()
@@ -1112,8 +1130,9 @@ class OtaInstallCoordinator {
1112
1130
  }
1113
1131
  }
1114
1132
 
1115
- // Any glasses activity proves the logical ota_start was accepted.
1116
- if ((otaStatusChanged || otaProgressChanged) && (otaStatus || otaProgress)) {
1133
+ // Any glasses activity proves the logical ota_start was accepted. An idle reply does not:
1134
+ // a hotspot start still joining has sent the glasses nothing yet.
1135
+ if ((otaStatusChanged || otaProgressChanged) && hasRecoveringOtaReply(otaStatus, otaProgress)) {
1117
1136
  this.onFirstActivity()
1118
1137
  }
1119
1138
 
@@ -1409,6 +1428,32 @@ class OtaInstallCoordinator {
1409
1428
  return statusReadyToRestart || progressReadyToRestart || legacyInstallInProgress
1410
1429
  }
1411
1430
 
1431
+ /**
1432
+ * Firmware pass of a downgrade whose glasses hand the pin off after the firmware reboot: note
1433
+ * the staging, then treat the firmware's completion as the handoff point. From there the detour
1434
+ * wait owns the reboot and reconnects, and completion is exact-version convergence.
1435
+ */
1436
+ private runVersionChangeAfterRebootPass(otaStatus: OtaStatus | null): void {
1437
+ if (!this.versionChangeSession || this.versionChangeInstallStarted) return
1438
+ if (this.otaStartOwnership?.outcome !== "acknowledged" || !otaStatus) return
1439
+ if (otaStatus.stepType === "apk" && otaStatus.phase === "download" && otaStatus.totalSteps > 1) {
1440
+ if (!this.versionChangeAfterReboot) {
1441
+ console.log("[OTA_PROGRESS] version-change: glasses stage the pin for after their firmware reboot")
1442
+ this.versionChangeAfterReboot = true
1443
+ }
1444
+ return
1445
+ }
1446
+ const firmwareDone =
1447
+ otaStatus.phase === "install" &&
1448
+ ((otaStatus.stepType === "bes" && (otaStatus.status === "step_complete" || otaStatus.status === "complete")) ||
1449
+ (otaStatus.stepType === "mtk" && otaStatus.status === "complete"))
1450
+ if (!this.versionChangeAfterReboot || !firmwareDone) return
1451
+ console.log("[OTA_PROGRESS] version-change: firmware done — entering detour wait across its reboot")
1452
+ this.versionChangeInstallStarted = true
1453
+ this.otaStartOwnership.versionChangeTarget = this.versionChangeTarget ?? undefined
1454
+ this.emitInternalChange()
1455
+ }
1456
+
1412
1457
  /** Complete only after a protocol-authorized BES restart traverses disconnect -> reconnect. */
1413
1458
  private completeBesRestartRecovery(): void {
1414
1459
  if (!this.besRestartDisconnectObserved || this.besRestartRecovery !== "awaiting") return
@@ -1497,6 +1542,7 @@ class OtaInstallCoordinator {
1497
1542
  besRestartRecovery: this.besRestartRecovery,
1498
1543
  versionChangeConverged: this.versionChangeConverged,
1499
1544
  versionChangeSession: this.versionChangeSession,
1545
+ versionChangeAfterReboot: this.versionChangeAfterReboot && this.isInVersionChangeDetour(),
1500
1546
  })
1501
1547
  }
1502
1548
 
@@ -1720,7 +1766,13 @@ class OtaInstallCoordinator {
1720
1766
  ownership.outcome = "rejected"
1721
1767
  this.clearStuckTimeout()
1722
1768
  this.reportFailure("hotspot_preflight_failed", err instanceof OtaArtifactError ? err.failure : undefined)
1723
- await this.teardownHotspotTransport()
1769
+ // Unconfirmed cleanup stays with the transport, which retries it on the next attempt;
1770
+ // it must not leave the screen on "starting" without the error.
1771
+ try {
1772
+ await this.teardownHotspotTransport()
1773
+ } catch (cleanupError) {
1774
+ console.warn("[OTA_PROGRESS] hotspot cleanup failed", cleanupError)
1775
+ }
1724
1776
  if (!isCurrentAttempt()) return
1725
1777
  if (this.attached) {
1726
1778
  const copyKey = phoneOtaErrorCopyKey(err, Platform.OS)
@@ -4,25 +4,11 @@ import {otaDeviceSessionRevision} from "./OtaDeviceSession"
4
4
  import {ENGINE_RELEASE_METADATA} from "../generated/releaseMetadata"
5
5
  import {getGlassesSystemTimeMs, isGlassesConnected, useGlassesStore, waitForGlassesState} from "../stores/glasses"
6
6
  import {maybeFixGlassesClockFromVersionInfo} from "./glassesClockSync"
7
- import {hasConfiguredModernOtaManifestPin, isLegacyOtaManifestSelected, resolveOtaManifestUrl} from "./otaManifestUrl"
7
+ import {hasConfiguredModernOtaManifestPin, isHeldByOtaOverride, isLegacyOtaManifestSelected, resolveOtaManifestUrl} from "./otaManifestUrl"
8
8
  import {resolveOtaReleaseVersion} from "./otaReleaseVersion"
9
9
  import {isNewerMtk, normalizeMtkVersion, resolveMtkDowngrade, type MtkDowngrade} from "./mtkDowngrade"
10
10
  import {observeManifestNativeErrors} from "./otaNativeNetworkDiagnostics"
11
11
 
12
- /**
13
- * Phone-side mirror of ASG's `DOWNGRADE_FLOOR_VERSION_CODE`. Set to the versionCode of the first
14
- * release shipping the shared media root (the first downgrade-safe build). A non-positive value
15
- * means downgrades are disabled, so the phone must NOT offer them — offering a downgrade the
16
- * glasses' `DowngradeGate` will refuse leaves the version-change session with no install and the
17
- * glasses reporting a bare "complete", which would otherwise present as false success. Keep this
18
- * in lockstep with the ASG/recovery constant at release time.
19
- */
20
- // Mentra 3.0: matches OtaConstants and RecoveryConstants on the glasses.
21
- // Coordinated releases guarantee higher supported ASG builds can downgrade; no source gate is needed.
22
- // The shipped floor may increase, never decrease, and must stay aligned across all checkers.
23
- // See asg_client/docs/mentra-live-spec.md#ota-and-updates.
24
- export const DOWNGRADE_FLOOR_VERSION_CODE = 51518114
25
-
26
12
  export interface VersionInfo {
27
13
  versionCode: number
28
14
  versionName: string
@@ -133,8 +119,6 @@ export interface OtaCheckCurrentGlassesOptions {
133
119
  waitForLegacyMigrationMs?: number
134
120
  refreshVersionInfo?: boolean
135
121
  fixClockBeforeCheck?: boolean
136
- /** Downgrade floor override (defaults to DOWNGRADE_FLOOR_VERSION_CODE); for tests. */
137
- floorVersionCode?: number
138
122
  }
139
123
 
140
124
  function emptyCheckResult(
@@ -236,9 +220,8 @@ export async function fetchVersionInfo(url: string): Promise<VersionJson | null>
236
220
  export function checkVersionUpdateAvailable(
237
221
  currentBuildNumber: string | undefined,
238
222
  versionJson: VersionJson | null,
239
- floorVersionCode: number = DOWNGRADE_FLOOR_VERSION_CODE,
240
223
  ): boolean {
241
- return getApkUpdateDirection(currentBuildNumber, versionJson, floorVersionCode) !== null
224
+ return getApkUpdateDirection(currentBuildNumber, versionJson) !== null
242
225
  }
243
226
 
244
227
  /**
@@ -250,7 +233,6 @@ export function checkVersionUpdateAvailable(
250
233
  export function getApkUpdateDirection(
251
234
  currentBuildNumber: string | undefined,
252
235
  versionJson: VersionJson | null,
253
- floorVersionCode: number = DOWNGRADE_FLOOR_VERSION_CODE,
254
236
  ): "upgrade" | "downgrade" | null {
255
237
  if (!currentBuildNumber || !versionJson) {
256
238
  return null
@@ -279,10 +261,8 @@ export function getApkUpdateDirection(
279
261
  if (serverVersion > currentVersion) {
280
262
  return "upgrade"
281
263
  }
282
- // Downgrades require an exact pin AND a target at/above the enabled floor. A non-positive floor
283
- // disables downgrades entirely, matching ASG's fail-closed DowngradeGate — so the phone never
284
- // offers what the glasses would refuse.
285
- if (serverVersion < currentVersion && exactPin && floorVersionCode > 0 && serverVersion >= floorVersionCode) {
264
+ // Downgrades require an exact pin.
265
+ if (serverVersion < currentVersion && exactPin) {
286
266
  return "downgrade"
287
267
  }
288
268
  return null
@@ -376,7 +356,6 @@ export async function checkForOtaUpdate(
376
356
  currentBuildNumber: string,
377
357
  currentMtkVersion?: string,
378
358
  currentBesVersion?: string,
379
- floorVersionCode: number = DOWNGRADE_FLOOR_VERSION_CODE,
380
359
  ): Promise<OtaCheckResult> {
381
360
  try {
382
361
  console.log("OTA: Checking for OTA update - URL: " + otaVersionUrl + ", current build: " + currentBuildNumber)
@@ -431,7 +410,7 @@ export async function checkForOtaUpdate(
431
410
  }
432
411
  }
433
412
 
434
- const apkDirection = getApkUpdateDirection(currentBuildNumber, versionJson, floorVersionCode)
413
+ const apkDirection = getApkUpdateDirection(currentBuildNumber, versionJson)
435
414
  const apkUpdateAvailable = apkDirection !== null
436
415
  console.log(
437
416
  `OTA: APK update available: ${apkUpdateAvailable} (current: ${currentBuildNumber}, direction: ${
@@ -565,7 +544,6 @@ export async function checkCurrentGlassesForUpdate(
565
544
  waitForLegacyMigrationMs = 0,
566
545
  refreshVersionInfo = true,
567
546
  fixClockBeforeCheck = true,
568
- floorVersionCode = DOWNGRADE_FLOOR_VERSION_CODE,
569
547
  } = options
570
548
 
571
549
  if (deviceChanged() || !glassesConnectedNow()) {
@@ -652,17 +630,16 @@ export async function checkCurrentGlassesForUpdate(
652
630
 
653
631
  if (deviceChanged()) return emptyCheckResult("disconnected")
654
632
  const manifestUrl = resolveOtaManifestUrl(useGlassesStore.getState().otaVersionUrl, buildNumber)
633
+ if (!manifestUrl && isHeldByOtaOverride(buildNumber)) {
634
+ // The override took these glasses to its set and they can't follow it further: up to date there.
635
+ console.log("OTA: glasses are at the developer override's set; nothing to install until it is cleared")
636
+ return {...emptyCheckResult(), hasCheckCompleted: true}
637
+ }
655
638
  if (!manifestUrl) {
656
639
  console.log("OTA: check skipped - no OTA manifest pin resolved")
657
640
  return emptyCheckResult("dev_build")
658
641
  }
659
- const result = await checkForOtaUpdate(
660
- manifestUrl,
661
- buildNumber,
662
- mtkFirmwareVersion,
663
- besFirmwareVersion,
664
- floorVersionCode,
665
- )
642
+ const result = await checkForOtaUpdate(manifestUrl, buildNumber, mtkFirmwareVersion, besFirmwareVersion)
666
643
 
667
644
  if (deviceChanged()) return emptyCheckResult("disconnected")
668
645
  if (!result.hasCheckCompleted) {
@@ -9,12 +9,6 @@ export interface MtkDowngrade {
9
9
  size: number
10
10
  }
11
11
 
12
- /**
13
- * Mentra 3.0's MTK. No downgrade goes below it: downgrades keep userdata (photos and videos), which
14
- * holds only between builds with the same Android version, security patch level and AVB rollback
15
- * indexes. The glasses (MtkOtaSelector) and the Bluetooth SDKs keep the same floor.
16
- */
17
- export const MTK_DOWNGRADE_FLOOR = "MentraLive_20260709"
18
12
  /** Each published downgrade's record, by its two versions. */
19
13
  export const MTK_DOWNGRADE_RECORD_BASE_URL = "https://mtkfirmware.mentraglass.com/"
20
14
 
@@ -36,8 +30,8 @@ export function isNewerMtk(target: unknown, current: unknown): boolean {
36
30
  }
37
31
 
38
32
  /**
39
- * The older MTK this manifest pins, from Mentra 3.0's up: its full OTA's version, or else the one
40
- * version its patches all end at.
33
+ * The older MTK this manifest pins: its full OTA's version, or else the one version its patches all
34
+ * end at.
41
35
  */
42
36
  export function mtkDowngradeTarget(manifest: VersionJson | undefined, currentVersion: string | undefined): string | null {
43
37
  if (!manifest || !currentVersion) return null
@@ -51,7 +45,7 @@ export function mtkDowngradeTarget(manifest: VersionJson | undefined, currentVer
51
45
  target = end
52
46
  }
53
47
  }
54
- if (!target || !isNewerMtk(currentVersion, target) || isNewerMtk(MTK_DOWNGRADE_FLOOR, target)) return null
48
+ if (!target || !isNewerMtk(currentVersion, target)) return null
55
49
  return target
56
50
  }
57
51
 
@@ -65,7 +59,6 @@ export function isMtkDowngrade(entry: unknown, currentVersion: string, target: s
65
59
  normalizeMtkVersion(value.start_firmware) === normalizeMtkVersion(currentVersion) &&
66
60
  normalizeMtkVersion(value.end_firmware) === normalizeMtkVersion(target) &&
67
61
  isNewerMtk(currentVersion, target) &&
68
- !isNewerMtk(MTK_DOWNGRADE_FLOOR, target) &&
69
62
  typeof value.url === "string" &&
70
63
  /^https?:\/\/[^/\s]+\//.test(value.url) &&
71
64
  typeof value.sha256 === "string" &&
@@ -53,6 +53,8 @@ export function deriveDisplayState(args: {
53
53
  versionChangeConverged?: boolean
54
54
  /** True for the whole downgrade (version-change) session. */
55
55
  versionChangeSession?: boolean
56
+ /** Detour wait that began at the firmware's completion, before the glasses' own handoff. */
57
+ versionChangeAfterReboot?: boolean
56
58
  }): DisplayState {
57
59
  const {
58
60
  otaStatus,
@@ -64,6 +66,7 @@ export function deriveDisplayState(args: {
64
66
  besRestartRecovery,
65
67
  versionChangeConverged,
66
68
  versionChangeSession,
69
+ versionChangeAfterReboot,
67
70
  } = args
68
71
 
69
72
  if (errorMsg) return "failed"
@@ -74,6 +77,13 @@ export function deriveDisplayState(args: {
74
77
  // status still sitting in the store from before the handoff.
75
78
  if (versionChangeConverged) return "complete"
76
79
 
80
+ // The firmware's terminal status stays in the store across the reboot that applies it; it is
81
+ // the start of the glasses' own downgrade, not a result.
82
+ if (versionChangeAfterReboot) {
83
+ if (otaStatus?.status === "failed") return "failed"
84
+ return connected ? "updating" : "restarting"
85
+ }
86
+
77
87
  // A BES reboot destroys or strands the glasses-side OTA session on older
78
88
  // clients. Once the phone observed that reboot, stale pre-reboot progress must
79
89
  // not move the UI from restarting back to updating.
@@ -36,6 +36,9 @@ export function resolveOtaManifestPolicy({
36
36
  engineReleasePin?: string | null
37
37
  }): string | null {
38
38
  if (isLegacyAsgOtaStartBuild(glassesBuildNumber)) {
39
+ // A service app before 39 can't take a manifest URL, so with an override set these glasses are where it took them
40
+ // (an older set): every check says up to date until the override is cleared, then they follow production.
41
+ if (trimmed(developerOverride)) return null
39
42
  return trimmed(glassesUrl) || OTA_VERSION_URL_LEGACY_PROD
40
43
  }
41
44
  return selectModernOtaManifestPin({developerOverride, hostReleasePin, engineReleasePin})
@@ -50,6 +50,11 @@ export function isLegacyOtaManifestSelected(glassesBuildNumber?: string | null):
50
50
  return !hasDeploymentOtaPolicy() && isLegacyAsgOtaStartBuild(glassesBuildNumber)
51
51
  }
52
52
 
53
+ /** An override is set, and these glasses' service app can't take a manifest URL: they are where it took them. */
54
+ export function isHeldByOtaOverride(glassesBuildNumber?: string | null): boolean {
55
+ return Boolean(getOtaVersionUrlDevOverride()) && isLegacyOtaManifestSelected(glassesBuildNumber)
56
+ }
57
+
53
58
  export function resolveOtaManifestUrl(glassesUrl?: string | null, glassesBuildNumber?: string | null): string | null {
54
59
  return resolveDeploymentAwareOtaManifestPolicy({
55
60
  hostPolicyConfigured: hasDeploymentOtaPolicy(),