@mentra/engine 3.2.0-dev.177 → 3.2.0-dev.180
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.
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/react/MentraLiveOtaFlow.d.ts.map +1 -1
- package/build/react/MentraLiveOtaFlow.js +54 -6
- package/build/react/MentraLiveOtaFlow.js.map +1 -1
- package/build/react/useMentraLiveOta.d.ts +9 -0
- package/build/react/useMentraLiveOta.d.ts.map +1 -1
- package/build/react/useMentraLiveOta.js +4 -0
- package/build/react/useMentraLiveOta.js.map +1 -1
- package/build/services/OtaArtifactDownloader.d.ts.map +1 -1
- package/build/services/OtaArtifactDownloader.js +10 -0
- package/build/services/OtaArtifactDownloader.js.map +1 -1
- package/build/services/OtaInstallCoordinator.d.ts +3 -0
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +12 -4
- package/build/services/OtaInstallCoordinator.js.map +1 -1
- package/build/services/OtaUpdateCheckService.d.ts +1 -1
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +5 -1
- package/build/services/OtaUpdateCheckService.js.map +1 -1
- package/package.json +7 -7
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/react/MentraLiveOtaFlow.tsx +66 -6
- package/src/react/useMentraLiveOta.ts +9 -0
- package/src/services/OtaArtifactDownloader.ts +10 -0
- package/src/services/OtaInstallCoordinator.ts +13 -3
- package/src/services/OtaUpdateCheckService.ts +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMentraLiveOta.js","sourceRoot":"","sources":["../../src/react/useMentraLiveOta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAEvE,OAAO,EAAC,GAAG,EAA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ClB,KAAK;YACL,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,MAAM,KAAK,QAAQ,IAAI,CAAC,qBAAqB;YACvD,SAAS,EAAE,MAAM,KAAK,UAAU,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,qBAAqB,CAAC;YAClF,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,MAAM,KAAK,cAAc;YACrC,gBAAgB,EAAE,MAAM,KAAK,QAAQ,IAAI,cAAc;YACvD,gBAAgB,EAAE,eAAe,CAAC,sBAAsB;YACxD,eAAe,EAAE,KAAK;YACtB,iBAAiB,EAAE,0BAA0B,CAAC,wBAAwB,EAAE,CAAC;YACzE,UAAU;YACV,kBAAkB,EAAE,IAAI;SACzB,CAAA;IACH,CAAC,EAAE;QACD,uBAAuB;QACvB,UAAU;QACV,cAAc;QACd,mBAAmB;QACnB,0BAA0B;QAC1B,eAAe;QACf,SAAS;QACT,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAChB,eAAe;QACf,WAAW;QACX,wBAAwB;QACxB,IAAI;QACJ,YAAY;KACb,CAAC,CAAA;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAC,CAAC,EAChG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,CAAC,CACtE,CAAA;AACH,CAAC","sourcesContent":["import {useCallback, useEffect, useMemo, useRef, useState} from \"react\"\n\nimport {ota} from \"../facades/ota\"\nimport {\n beginOtaAutoChain,\n clearOtaAutoChainReconnectWait,\n isOtaAutoChainActive,\n otaAutoChainFingerprint,\n otaAutoChainReleaseRange,\n otaAutoChainReconnectWaitRemaining,\n stopOtaAutoChain,\n tryAdvanceOtaAutoChain,\n type OtaAutoChainReleaseRange,\n} from \"../services/OtaAutoChain\"\nimport {\n BES_INSTALL_RESTART_MESSAGE,\n getOtaErrorMessage,\n shouldRequireGlassesRebootForBesFailure,\n shouldShowChangeWifiForOtaDownloadFailure,\n} from \"../services/OtaErrorMapping\"\nimport type {OtaInstallSnapshot} from \"../services/OtaInstallCoordinator\"\nimport type {OtaCheckCurrentGlassesResult} from \"../services/OtaUpdateCheckService\"\nimport type {ReleaseChangelog} from \"../facades/ota\"\nimport {useEngineSnapshot} from \"./useEngineSnapshot\"\n\nexport type MentraLiveOtaFlowPage = \"check\" | \"progress\"\n\nexport type MentraLiveOtaScreen =\n | \"initializing\"\n | \"checking\"\n | \"finishing\"\n | \"update_available\"\n | \"battery_required\"\n | \"wifi_required\"\n | \"up_to_date\"\n | \"dev_build\"\n | \"unofficial_client\"\n | \"check_failed\"\n | \"update_info_unavailable\"\n | \"starting\"\n | \"preparing_hotspot\"\n | \"updating\"\n | \"restarting\"\n | \"verifying\"\n | \"complete\"\n | \"failed\"\n | \"disconnected\"\n\nexport type MentraLiveOtaErrorCode =\n | \"check_failed\"\n | \"update_info_unavailable\"\n | \"install_failed\"\n | \"bes_restart_required\"\n\nexport type MentraLiveOtaError = {\n code: MentraLiveOtaErrorCode\n message: string\n}\n\nexport type MentraLiveOtaTransport = \"wifi\" | \"hotspot\"\nexport type MentraLiveOtaHotspotPhase = \"idle\" | \"downloading\" | \"starting_hotspot\" | \"joining_hotspot\" | \"serving\"\nexport type MentraLiveOtaInstallPhase = \"download\" | \"install\"\nexport type MentraLiveOtaStep = \"apk\" | \"mtk\" | \"bes\"\n\nexport type MentraLiveOtaReleaseTransition = {\n /** Current glasses software label. Temporarily backed by the reported ASG app version. */\n fromVersion: string | null\n /** Exact coordinated release identity for the selected OTA pin. */\n toVersion: string\n}\n\nexport type MentraLiveOtaState = {\n screen: MentraLiveOtaScreen\n connected: boolean\n batteryLevel: number | null\n transport: MentraLiveOtaTransport | null\n updateRequired: boolean\n versionChange: boolean\n versionChangeConverged: boolean\n versionChangePhase: \"installing\" | \"restarting\" | \"verifying\" | null\n wifiConnected: boolean\n wifiStatusKnown: boolean\n hotspotSupported: boolean\n hotspotPhase: MentraLiveOtaHotspotPhase\n hotspotArtifactPercent: number | null\n phase: MentraLiveOtaInstallPhase | null\n step: MentraLiveOtaStep | null\n currentStep: number | null\n totalSteps: number | null\n progress: number | null\n installingApkOnly: boolean\n firmwareRestarting: boolean\n error: MentraLiveOtaError | null\n canInstall: boolean\n canRetry: boolean\n canFinish: boolean\n canDismiss: boolean\n canDiscard: boolean\n canOpenWifiSetup: boolean\n continueDisabled: boolean\n /** True only after an approved update session reaches a final no-update check. */\n completedUpdate: boolean\n /** Release labels for the offered or just-completed coordinated update. */\n releaseTransition: MentraLiveOtaReleaseTransition | null\n /** Release notes crossed by this update, newest first. Populated on completion. */\n changelogs: ReleaseChangelog[]\n /** Sideloaded glasses client package, set only on the `unofficial_client` screen. */\n glassesPackageName: string | null\n}\n\nexport type UseMentraLiveOtaOptions = {\n /** Entry page. `progress` exists for interrupted-session recovery. */\n initialPage?: MentraLiveOtaFlowPage\n /** Start Engine's OTA-only projections. Full Engine hosts should pass false. */\n initializeRuntime?: boolean\n /** Called after the final check or when an optional update is dismissed. */\n onFinished?: () => void\n /** Host-owned Wi-Fi setup for glasses without hotspot OTA support. */\n onOpenWifiSetup?: () => void\n /** Lets a host coordinate its connection overlay with OTA firmware restarts. */\n onFirmwareRestartingChange?: (restarting: boolean, progressActive: boolean) => void\n}\n\nexport type MentraLiveOtaController = {\n state: MentraLiveOtaState\n check: () => void\n retryCheck: () => void\n install: () => void\n retryInstall: () => void\n finish: () => void\n discard: () => void\n openWifiSetup: () => void\n}\n\ntype CheckState = \"checking\" | \"update_available\" | \"no_update\" | \"dev_build\" | \"unofficial_client\" | \"error\"\n\nconst AUTO_CHAIN_NETWORK_RETRY_DELAY_MS = 5000\nconst AUTO_CHAIN_COMPLETE_DELAY_MS = 750\nexport const MINIMUM_OTA_BATTERY_LEVEL = 25\n\nfunction releaseRangeTargetVersion(result: OtaCheckCurrentGlassesResult): string | null {\n return result.releaseVersion ?? result.updateInfo?.versionName ?? result.latestVersionInfo?.versionName ?? null\n}\n\nfunction currentReleaseVersion(appVersion: string | null): string | null {\n const version = appVersion?.trim()\n return version || null\n}\n\nfunction releaseTransitionFromRange(range: OtaAutoChainReleaseRange | null): MentraLiveOtaReleaseTransition | null {\n if (!range?.releaseVersion) return null\n return {fromVersion: range.fromVersion, toVersion: range.releaseVersion}\n}\n\nfunction releaseChangelogsForActiveChain(): ReleaseChangelog[] {\n const range = otaAutoChainReleaseRange()\n if (!range?.toVersion) return []\n try {\n return ota.getReleaseChangelogs(range.fromVersion, range.toVersion)\n } catch {\n try {\n return ota.getReleaseChangelogs(null, range.toVersion)\n } catch {\n return []\n }\n }\n}\n\nfunction installProgress(snapshot: OtaInstallSnapshot): number | null {\n if (snapshot.displayState !== \"updating\") return null\n const {otaStatus} = snapshot\n const isDownload = otaStatus?.phase === \"download\"\n const totalSteps = otaStatus?.totalSteps ?? 1\n const rawPercent = isDownload\n ? (otaStatus?.stepPercent ?? 0)\n : totalSteps >= 2\n ? (otaStatus?.overallPercent ?? 0)\n : (otaStatus?.stepPercent ?? 0)\n return Math.min(Math.max(rawPercent, snapshot.mtkInstallStallSimulatedPercent ?? 0, 0), 100)\n}\n\nfunction progressScreen(snapshot: OtaInstallSnapshot): MentraLiveOtaScreen {\n if (snapshot.versionChangePhase === \"restarting\") return \"restarting\"\n if (snapshot.versionChangePhase === \"verifying\") return \"verifying\"\n switch (snapshot.displayState) {\n case \"starting\":\n return snapshot.hotspotPhase === \"idle\" || snapshot.hotspotPhase === \"serving\" ? \"starting\" : \"preparing_hotspot\"\n case \"updating\":\n return \"updating\"\n case \"restarting\":\n return \"restarting\"\n case \"complete\":\n return \"complete\"\n case \"failed\":\n return \"failed\"\n default:\n return \"disconnected\"\n }\n}\n\n/**\n * Headless Mentra Live OTA flow. Engine owns checking, hotspot staging,\n * APK/MTK/BES sequencing, restart recovery, retries, and verification; the host\n * renders semantic state and invokes these idempotent actions.\n */\nexport function useMentraLiveOta(options: UseMentraLiveOtaOptions = {}): MentraLiveOtaController {\n const {\n initialPage = \"check\",\n initializeRuntime = true,\n onFinished,\n onFirmwareRestartingChange,\n onOpenWifiSetup,\n } = options\n const otaSnapshot = useEngineSnapshot(ota.snapshot, ota.onSnapshot)\n const installSnapshot = useEngineSnapshot(ota.installSession.snapshot, ota.installSession.onSnapshot)\n const [page, setPage] = useState<MentraLiveOtaFlowPage>(initialPage)\n const [runtimeReady, setRuntimeReady] = useState(!initializeRuntime)\n const [checkState, setCheckState] = useState<CheckState>(\"checking\")\n const [isUpdateRequired, setIsUpdateRequired] = useState(true)\n const [isVersionChange, setIsVersionChange] = useState(false)\n const [errorKind, setErrorKind] = useState<\"network\" | \"pin_unavailable\">(\"network\")\n const [unofficialClientPackage, setUnofficialClientPackage] = useState<string | null>(null)\n const [updateFingerprint, setUpdateFingerprint] = useState<string | null>(null)\n const [offeredReleaseTransition, setOfferedReleaseTransition] = useState<MentraLiveOtaReleaseTransition | null>(null)\n const [completedReleaseTransition, setCompletedReleaseTransition] = useState<MentraLiveOtaReleaseTransition | null>(\n null,\n )\n const [completedUpdate, setCompletedUpdate] = useState(false)\n const [completedChangelogs, setCompletedChangelogs] = useState<ReleaseChangelog[]>([])\n const [batteryBlocked, setBatteryBlocked] = useState(false)\n const [checkGeneration, setCheckGeneration] = useState(0)\n const performCheckGenerationRef = useRef(0)\n const activeCheckKeyRef = useRef<string | null>(null)\n const checkStartedRef = useRef(false)\n const checkCompletedRef = useRef(false)\n const selectedCheckResultRef = useRef<OtaCheckCurrentGlassesResult | null>(null)\n const autoChainAdvancedRef = useRef(false)\n const installActionPendingRef = useRef(false)\n const onFinishedRef = useRef(onFinished)\n const onOpenWifiSetupRef = useRef(onOpenWifiSetup)\n const onFirmwareRestartingChangeRef = useRef(onFirmwareRestartingChange)\n onFinishedRef.current = onFinished\n onOpenWifiSetupRef.current = onOpenWifiSetup\n onFirmwareRestartingChangeRef.current = onFirmwareRestartingChange\n\n useEffect(() => {\n if (!initializeRuntime) {\n setRuntimeReady(true)\n return\n }\n let cancelled = false\n setRuntimeReady(false)\n void ota.initialize().finally(() => {\n if (!cancelled) setRuntimeReady(true)\n })\n return () => {\n cancelled = true\n }\n }, [initializeRuntime])\n\n const returnToCheck = useCallback(() => {\n installActionPendingRef.current = false\n autoChainAdvancedRef.current = false\n setCheckState(\"checking\")\n setPage(\"check\")\n setCheckGeneration((generation) => generation + 1)\n }, [])\n\n const navigateToProgress = useCallback(() => {\n installActionPendingRef.current = true\n ota.clearProgress()\n setPage(\"progress\")\n }, [])\n\n const continueApprovedChain = useCallback(\n (result: OtaCheckCurrentGlassesResult): boolean => {\n if (installActionPendingRef.current || !isOtaAutoChainActive() || !result.updateInfo) return false\n const snapshot = ota.snapshot()\n if (!snapshot.wifiStatusKnown || (!snapshot.wifiConnected && snapshot.hotspotOtaVersion !== 1)) return false\n\n const admission = tryAdvanceOtaAutoChain(\n otaAutoChainFingerprint(result),\n result.updateInfo.isDowngrade === true,\n releaseRangeTargetVersion(result),\n result.releaseVersion,\n )\n if (!admission.advance) return false\n\n checkCompletedRef.current = true\n ota.installSession.prepare(result)\n navigateToProgress()\n return true\n },\n [navigateToProgress],\n )\n\n useEffect(() => {\n if (!runtimeReady || page !== \"check\") return\n const MIN_DISPLAY_TIME_MS = 1100\n const MAX_WAIT_FOR_VERSION_INFO_MS = 10_000\n const checkKey = String(checkGeneration)\n if (activeCheckKeyRef.current !== checkKey) {\n activeCheckKeyRef.current = checkKey\n checkStartedRef.current = false\n checkCompletedRef.current = false\n selectedCheckResultRef.current = null\n installActionPendingRef.current = false\n setCheckState(\"checking\")\n }\n\n const myGeneration = ++performCheckGenerationRef.current\n let cancelled = false\n let reconnectTimeout: ReturnType<typeof setTimeout> | null = null\n\n const performCheck = async () => {\n if (checkCompletedRef.current) return\n if (isOtaAutoChainActive() && !otaSnapshot.ready) {\n const remainingMs = otaAutoChainReconnectWaitRemaining()\n if (remainingMs === null) return\n reconnectTimeout = setTimeout(() => {\n if (cancelled || myGeneration !== performCheckGenerationRef.current || ota.snapshot().ready) return\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setCheckState(\"error\")\n }, remainingMs)\n return\n }\n if (!otaSnapshot.connected) {\n if (checkStartedRef.current) {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setCheckState(\"error\")\n return\n }\n checkCompletedRef.current = true\n onFinishedRef.current?.()\n return\n }\n\n clearOtaAutoChainReconnectWait()\n checkStartedRef.current = true\n const startTime = Date.now()\n try {\n const checkOptions = {\n waitForBuildNumberMs: MAX_WAIT_FOR_VERSION_INFO_MS,\n waitForBesVersionMs: 5000,\n waitForMtkVersionMs: 2000,\n refreshVersionInfo: true,\n fixClockBeforeCheck: false,\n }\n let result = await ota.checkForUpdates(checkOptions)\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n if (!result.hasCheckCompleted && result.checkFailureReason === \"network\" && isOtaAutoChainActive()) {\n await new Promise((resolve) => setTimeout(resolve, AUTO_CHAIN_NETWORK_RETRY_DELAY_MS))\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n result = await ota.checkForUpdates(checkOptions)\n }\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n selectedCheckResultRef.current = result\n await new Promise((resolve) => setTimeout(resolve, Math.max(0, MIN_DISPLAY_TIME_MS - (Date.now() - startTime))))\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n\n if (result.skippedReason === \"disconnected\") {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setCheckState(\"error\")\n return\n }\n if (result.skippedReason === \"missing_build\") {\n checkCompletedRef.current = true\n if (isOtaAutoChainActive()) {\n stopOtaAutoChain()\n setCheckState(\"error\")\n } else {\n onFinishedRef.current?.()\n }\n return\n }\n if (result.skippedReason === \"dev_build\") {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n ota.clearUpdateAvailable()\n setCheckState(\"dev_build\")\n return\n }\n if (result.skippedReason === \"unofficial_client\") {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n ota.clearUpdateAvailable()\n setUnofficialClientPackage(result.packageName ?? null)\n setCheckState(\"unofficial_client\")\n return\n }\n if (!result.hasCheckCompleted) {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setErrorKind(result.checkFailureReason === \"pin_unavailable\" ? \"pin_unavailable\" : \"network\")\n setCheckState(\"error\")\n return\n }\n if (result.updateAvailable && result.updateInfo) {\n setIsUpdateRequired(result.isRequired)\n setIsVersionChange(result.updateInfo.isDowngrade === true)\n const fingerprint = otaAutoChainFingerprint(result)\n setUpdateFingerprint(fingerprint)\n if (!isOtaAutoChainActive()) {\n const fromVersion = currentReleaseVersion(ota.snapshot().appVersion)\n setOfferedReleaseTransition(result.releaseVersion ? {fromVersion, toVersion: result.releaseVersion} : null)\n }\n if (isOtaAutoChainActive() && !ota.snapshot().wifiStatusKnown) {\n checkCompletedRef.current = true\n return\n }\n if (continueApprovedChain(result)) return\n checkCompletedRef.current = true\n setCheckState(\"update_available\")\n return\n }\n const completedApprovedSession = isOtaAutoChainActive()\n if (completedApprovedSession) {\n setCompletedChangelogs(releaseChangelogsForActiveChain())\n setCompletedReleaseTransition(releaseTransitionFromRange(otaAutoChainReleaseRange()))\n }\n setCompletedUpdate(completedApprovedSession)\n stopOtaAutoChain()\n checkCompletedRef.current = true\n ota.clearUpdateAvailable()\n setCheckState(\"no_update\")\n } catch (error) {\n console.error(\"OTA check failed:\", error)\n await new Promise((resolve) => setTimeout(resolve, Math.max(0, MIN_DISPLAY_TIME_MS - (Date.now() - startTime))))\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setErrorKind(\"network\")\n setCheckState(\"error\")\n }\n }\n\n void performCheck()\n return () => {\n cancelled = true\n if (reconnectTimeout) clearTimeout(reconnectTimeout)\n }\n }, [\n checkGeneration,\n continueApprovedChain,\n otaSnapshot.connected,\n otaSnapshot.ready,\n otaSnapshot.wifiStatusKnown,\n page,\n runtimeReady,\n ])\n\n useEffect(() => {\n if (\n !runtimeReady ||\n page !== \"check\" ||\n (checkState !== \"checking\" && checkState !== \"update_available\") ||\n !otaSnapshot.wifiStatusKnown ||\n !isOtaAutoChainActive()\n ) {\n return\n }\n const result = selectedCheckResultRef.current\n if (!result?.updateAvailable || !result.updateInfo) return\n if (!otaSnapshot.wifiConnected && otaSnapshot.hotspotOtaVersion !== 1) {\n setCheckState(\"update_available\")\n return\n }\n continueApprovedChain(result)\n }, [\n checkState,\n continueApprovedChain,\n otaSnapshot.hotspotOtaVersion,\n otaSnapshot.wifiConnected,\n otaSnapshot.wifiStatusKnown,\n page,\n runtimeReady,\n ])\n\n useEffect(() => {\n if (!runtimeReady || page !== \"progress\") return\n ota.installSession.attach()\n return () => ota.installSession.detach()\n }, [page, runtimeReady])\n\n const firmwareRestarting =\n page === \"progress\" &&\n ((!installSnapshot.connected && installSnapshot.displayState === \"restarting\") ||\n installSnapshot.versionChangePhase === \"restarting\")\n\n useEffect(() => {\n if (page !== \"progress\") return\n onFirmwareRestartingChangeRef.current?.(firmwareRestarting, true)\n }, [firmwareRestarting, page])\n\n useEffect(() => {\n if (page !== \"progress\") return\n return () => {\n onFirmwareRestartingChangeRef.current?.(false, false)\n }\n }, [page])\n\n useEffect(() => {\n if (\n page !== \"progress\" ||\n installSnapshot.displayState !== \"complete\" ||\n !installSnapshot.connected ||\n !isOtaAutoChainActive() ||\n autoChainAdvancedRef.current\n ) {\n return\n }\n const timeout = setTimeout(async () => {\n if (!isOtaAutoChainActive()) return\n autoChainAdvancedRef.current = true\n await ota.installSession.finish()\n returnToCheck()\n }, AUTO_CHAIN_COMPLETE_DELAY_MS)\n return () => clearTimeout(timeout)\n }, [installSnapshot.connected, installSnapshot.displayState, page, returnToCheck])\n\n const check = useCallback(() => {\n setBatteryBlocked(false)\n setOfferedReleaseTransition(null)\n setCompletedReleaseTransition(null)\n setCompletedUpdate(false)\n setCompletedChangelogs([])\n setPage(\"check\")\n setCheckState(\"checking\")\n setCheckGeneration((generation) => generation + 1)\n }, [])\n\n const install = useCallback(() => {\n if (installActionPendingRef.current || page !== \"check\") return\n const result = selectedCheckResultRef.current\n if (!result) {\n setErrorKind(\"network\")\n setCheckState(\"error\")\n return\n }\n const snapshot = ota.snapshot()\n if (snapshot.batteryLevel !== null && snapshot.batteryLevel < MINIMUM_OTA_BATTERY_LEVEL) {\n setBatteryBlocked(true)\n return\n }\n if (!snapshot.wifiStatusKnown) {\n check()\n return\n }\n if (!snapshot.wifiConnected && snapshot.hotspotOtaVersion !== 1) {\n onOpenWifiSetupRef.current?.()\n return\n }\n ota.installSession.prepare(result)\n setBatteryBlocked(false)\n setCompletedUpdate(false)\n setCompletedChangelogs([])\n if (updateFingerprint) {\n const fromVersion = offeredReleaseTransition\n ? offeredReleaseTransition.fromVersion\n : currentReleaseVersion(snapshot.appVersion)\n beginOtaAutoChain(updateFingerprint, isVersionChange, {\n fromVersion,\n toVersion: releaseRangeTargetVersion(result),\n releaseVersion: result.releaseVersion,\n })\n }\n navigateToProgress()\n }, [check, isVersionChange, navigateToProgress, offeredReleaseTransition, page, updateFingerprint])\n\n useEffect(() => {\n if (\n batteryBlocked &&\n (otaSnapshot.batteryLevel === null || otaSnapshot.batteryLevel >= MINIMUM_OTA_BATTERY_LEVEL)\n ) {\n setBatteryBlocked(false)\n }\n }, [batteryBlocked, otaSnapshot.batteryLevel])\n\n const retryInstall = useCallback(() => {\n if (page !== \"progress\") return\n onFirmwareRestartingChangeRef.current?.(false, true)\n ota.installSession.retry()\n }, [page])\n\n const finish = useCallback(async () => {\n if (page === \"check\") {\n onFinishedRef.current?.()\n return\n }\n const restartStillInProgress =\n installSnapshot.displayState === \"restarting\" ||\n installSnapshot.versionChangePhase === \"restarting\" ||\n installSnapshot.versionChangePhase === \"verifying\"\n if (restartStillInProgress) return\n const requiresGlassesReboot = shouldRequireGlassesRebootForBesFailure(\n installSnapshot.otaStatus,\n installSnapshot.otaProgress,\n installSnapshot.errorMsg,\n )\n if (requiresGlassesReboot) stopOtaAutoChain()\n await ota.installSession.finish()\n returnToCheck()\n }, [installSnapshot, page, returnToCheck])\n\n const discard = useCallback(async () => {\n if (page !== \"progress\") return\n stopOtaAutoChain()\n await ota.installSession.discard()\n returnToCheck()\n }, [page, returnToCheck])\n\n const openWifiSetup = useCallback(() => {\n if (page === \"progress\") stopOtaAutoChain()\n onOpenWifiSetupRef.current?.()\n }, [page])\n\n const state = useMemo<MentraLiveOtaState>(() => {\n const hotspotSupported = otaSnapshot.hotspotOtaVersion === 1\n const canInstall = otaSnapshot.wifiStatusKnown && (otaSnapshot.wifiConnected || hotspotSupported)\n const autoChainActive = isOtaAutoChainActive()\n if (!runtimeReady) {\n return {\n screen: \"initializing\",\n connected: otaSnapshot.connected,\n batteryLevel: otaSnapshot.batteryLevel,\n transport: null,\n updateRequired: isUpdateRequired,\n versionChange: isVersionChange,\n versionChangeConverged: false,\n versionChangePhase: null,\n wifiConnected: otaSnapshot.wifiConnected,\n wifiStatusKnown: otaSnapshot.wifiStatusKnown,\n hotspotSupported,\n hotspotPhase: \"idle\",\n hotspotArtifactPercent: null,\n phase: null,\n step: null,\n currentStep: null,\n totalSteps: null,\n progress: null,\n installingApkOnly: false,\n firmwareRestarting: false,\n error: null,\n canInstall: false,\n canRetry: false,\n canFinish: false,\n canDismiss: false,\n canDiscard: false,\n canOpenWifiSetup: false,\n continueDisabled: false,\n completedUpdate: false,\n releaseTransition: null,\n changelogs: [],\n glassesPackageName: null,\n }\n }\n\n if (page === \"check\") {\n const wifiRequired = otaSnapshot.wifiStatusKnown && !otaSnapshot.wifiConnected && !hotspotSupported\n let screen: MentraLiveOtaScreen\n if (checkState === \"checking\") screen = autoChainActive ? \"finishing\" : \"checking\"\n else if (checkState === \"update_available\") {\n screen = wifiRequired ? \"wifi_required\" : batteryBlocked ? \"battery_required\" : \"update_available\"\n } else if (checkState === \"no_update\") screen = \"up_to_date\"\n else if (checkState === \"dev_build\") screen = \"dev_build\"\n else if (checkState === \"unofficial_client\") screen = \"unofficial_client\"\n else screen = errorKind === \"pin_unavailable\" ? \"update_info_unavailable\" : \"check_failed\"\n\n let error: MentraLiveOtaError | null = null\n if (screen === \"check_failed\") {\n error = {\n code: \"check_failed\",\n message: \"Couldn't check for updates. Please check your connection and try again.\",\n }\n } else if (screen === \"update_info_unavailable\") {\n error = {code: \"update_info_unavailable\", message: \"Update information for this app version is unavailable.\"}\n }\n return {\n screen,\n connected: otaSnapshot.connected,\n batteryLevel: otaSnapshot.batteryLevel,\n transport: otaSnapshot.wifiConnected ? \"wifi\" : hotspotSupported ? \"hotspot\" : null,\n updateRequired: isUpdateRequired,\n versionChange: isVersionChange,\n versionChangeConverged: false,\n versionChangePhase: null,\n wifiConnected: otaSnapshot.wifiConnected,\n wifiStatusKnown: otaSnapshot.wifiStatusKnown,\n hotspotSupported,\n hotspotPhase: \"idle\",\n hotspotArtifactPercent: null,\n phase: null,\n step: null,\n currentStep: null,\n totalSteps: null,\n progress: null,\n installingApkOnly: false,\n firmwareRestarting: false,\n error,\n canInstall: screen === \"update_available\" && canInstall,\n canRetry: screen === \"check_failed\",\n canFinish:\n screen === \"up_to_date\" ||\n screen === \"dev_build\" ||\n screen === \"unofficial_client\" ||\n screen === \"update_info_unavailable\",\n canDismiss:\n (screen === \"update_available\" || screen === \"wifi_required\" || screen === \"battery_required\") &&\n !isUpdateRequired &&\n !autoChainActive,\n canDiscard: false,\n canOpenWifiSetup: screen === \"wifi_required\",\n continueDisabled: false,\n completedUpdate: screen === \"up_to_date\" && completedUpdate,\n releaseTransition:\n screen === \"update_available\" || screen === \"wifi_required\"\n ? autoChainActive\n ? releaseTransitionFromRange(otaAutoChainReleaseRange())\n : offeredReleaseTransition\n : screen === \"up_to_date\"\n ? completedReleaseTransition\n : null,\n changelogs: screen === \"up_to_date\" ? completedChangelogs : [],\n glassesPackageName: screen === \"unofficial_client\" ? unofficialClientPackage : null,\n }\n }\n\n const requiresGlassesReboot = shouldRequireGlassesRebootForBesFailure(\n installSnapshot.otaStatus,\n installSnapshot.otaProgress,\n installSnapshot.errorMsg,\n )\n const showChangeWifi = shouldShowChangeWifiForOtaDownloadFailure(\n installSnapshot.otaStatus,\n installSnapshot.otaProgress,\n installSnapshot.errorMsg,\n )\n const displayedError = requiresGlassesReboot\n ? BES_INSTALL_RESTART_MESSAGE\n : installSnapshot.errorMsg || getOtaErrorMessage(installSnapshot.otaStatus?.error)\n const progressState = progressScreen(installSnapshot)\n const screen = progressState === \"complete\" && autoChainActive ? \"finishing\" : progressState\n const error =\n screen === \"failed\"\n ? {\n code: requiresGlassesReboot ? (\"bes_restart_required\" as const) : (\"install_failed\" as const),\n message: displayedError,\n }\n : null\n const totalSteps = installSnapshot.otaStatus?.totalSteps ?? null\n const changelogs = screen === \"complete\" ? releaseChangelogsForActiveChain() : []\n return {\n screen,\n connected: installSnapshot.connected,\n batteryLevel: otaSnapshot.batteryLevel,\n transport: installSnapshot.transport,\n updateRequired: isUpdateRequired,\n versionChange: installSnapshot.isVersionChange,\n versionChangeConverged: installSnapshot.versionChangeConverged,\n versionChangePhase: installSnapshot.versionChangePhase,\n wifiConnected: otaSnapshot.wifiConnected,\n wifiStatusKnown: otaSnapshot.wifiStatusKnown,\n hotspotSupported,\n hotspotPhase: installSnapshot.hotspotPhase,\n hotspotArtifactPercent: installSnapshot.hotspotArtifactPercent,\n phase: installSnapshot.otaStatus?.phase ?? installSnapshot.otaProgress?.stage ?? null,\n step: installSnapshot.otaStatus?.stepType ?? null,\n currentStep: installSnapshot.otaStatus?.currentStep ?? null,\n totalSteps,\n progress: installProgress(installSnapshot),\n installingApkOnly:\n installSnapshot.otaStatus?.stepType === \"apk\" &&\n installSnapshot.otaStatus.phase === \"install\" &&\n totalSteps === 1,\n firmwareRestarting,\n error,\n canInstall: false,\n canRetry: screen === \"failed\" && !requiresGlassesReboot,\n canFinish: screen === \"complete\" || (screen === \"failed\" && requiresGlassesReboot),\n canDismiss: false,\n canDiscard: screen === \"disconnected\",\n canOpenWifiSetup: screen === \"failed\" && showChangeWifi,\n continueDisabled: installSnapshot.continueButtonDisabled,\n completedUpdate: false,\n releaseTransition: releaseTransitionFromRange(otaAutoChainReleaseRange()),\n changelogs,\n glassesPackageName: null,\n }\n }, [\n unofficialClientPackage,\n checkState,\n batteryBlocked,\n completedChangelogs,\n completedReleaseTransition,\n completedUpdate,\n errorKind,\n firmwareRestarting,\n installSnapshot,\n isUpdateRequired,\n isVersionChange,\n otaSnapshot,\n offeredReleaseTransition,\n page,\n runtimeReady,\n ])\n\n return useMemo(\n () => ({state, check, retryCheck: check, install, retryInstall, finish, discard, openWifiSetup}),\n [check, discard, finish, install, openWifiSetup, retryInstall, state],\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useMentraLiveOta.js","sourceRoot":"","sources":["../../src/react/useMentraLiveOta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAEvE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAA;AAClC,OAAO,EACL,iBAAiB,EACjB,8BAA8B,EAC9B,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,kCAAkC,EAClC,gBAAgB,EAChB,sBAAsB,GAEvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,uCAAuC,EACvC,yCAAyC,GAC1C,MAAM,6BAA6B,CAAA;AAIpC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AAsHrD,MAAM,iCAAiC,GAAG,IAAI,CAAA;AAC9C,MAAM,4BAA4B,GAAG,GAAG,CAAA;AACxC,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAE3C,SAAS,yBAAyB,CAAC,MAAoC;IACrE,OAAO,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC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E,MAAM,KAAK,QAAQ,IAAI,cAAc;YACvD,gBAAgB,EAAE,eAAe,CAAC,sBAAsB;YACxD,eAAe,EAAE,KAAK;YACtB,iBAAiB,EAAE,0BAA0B,CAAC,wBAAwB,EAAE,CAAC;YACzE,UAAU;YACV,kBAAkB,EAAE,IAAI;SACzB,CAAA;IACH,CAAC,EAAE;QACD,uBAAuB;QACvB,UAAU;QACV,cAAc;QACd,mBAAmB;QACnB,0BAA0B;QAC1B,eAAe;QACf,SAAS;QACT,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAChB,eAAe;QACf,WAAW;QACX,wBAAwB;QACxB,IAAI;QACJ,YAAY;KACb,CAAC,CAAA;IAEF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAC,CAAC,EAChG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,CAAC,CACtE,CAAA;AACH,CAAC","sourcesContent":["import {useCallback, useEffect, useMemo, useRef, useState} from \"react\"\n\nimport {ota} from \"../facades/ota\"\nimport {\n beginOtaAutoChain,\n clearOtaAutoChainReconnectWait,\n isOtaAutoChainActive,\n otaAutoChainFingerprint,\n otaAutoChainReleaseRange,\n otaAutoChainReconnectWaitRemaining,\n stopOtaAutoChain,\n tryAdvanceOtaAutoChain,\n type OtaAutoChainReleaseRange,\n} from \"../services/OtaAutoChain\"\nimport {\n BES_INSTALL_RESTART_MESSAGE,\n getOtaErrorMessage,\n shouldRequireGlassesRebootForBesFailure,\n shouldShowChangeWifiForOtaDownloadFailure,\n} from \"../services/OtaErrorMapping\"\nimport type {OtaInstallSnapshot} from \"../services/OtaInstallCoordinator\"\nimport type {OtaCheckCurrentGlassesResult} from \"../services/OtaUpdateCheckService\"\nimport type {ReleaseChangelog} from \"../facades/ota\"\nimport {useEngineSnapshot} from \"./useEngineSnapshot\"\n\nexport type MentraLiveOtaFlowPage = \"check\" | \"progress\"\n\nexport type MentraLiveOtaScreen =\n | \"initializing\"\n | \"checking\"\n | \"finishing\"\n | \"update_available\"\n | \"battery_required\"\n | \"wifi_required\"\n | \"up_to_date\"\n | \"dev_build\"\n | \"unofficial_client\"\n | \"check_failed\"\n | \"update_info_unavailable\"\n | \"starting\"\n | \"preparing_hotspot\"\n | \"updating\"\n | \"restarting\"\n | \"verifying\"\n | \"complete\"\n | \"failed\"\n | \"disconnected\"\n\nexport type MentraLiveOtaErrorCode =\n | \"check_failed\"\n | \"update_info_unavailable\"\n | \"install_failed\"\n | \"bes_restart_required\"\n\nexport type MentraLiveOtaError = {\n code: MentraLiveOtaErrorCode\n message: string\n}\n\nexport type MentraLiveOtaTransport = \"wifi\" | \"hotspot\"\nexport type MentraLiveOtaHotspotPhase = \"idle\" | \"downloading\" | \"starting_hotspot\" | \"joining_hotspot\" | \"serving\"\nexport type MentraLiveOtaInstallPhase = \"download\" | \"install\"\nexport type MentraLiveOtaStep = \"apk\" | \"mtk\" | \"bes\"\n\nexport type MentraLiveOtaReleaseTransition = {\n /** Current glasses software label. Temporarily backed by the reported ASG app version. */\n fromVersion: string | null\n /** Exact coordinated release identity for the selected OTA pin. */\n toVersion: string\n}\n\nexport type MentraLiveOtaState = {\n screen: MentraLiveOtaScreen\n connected: boolean\n batteryLevel: number | null\n transport: MentraLiveOtaTransport | null\n updateRequired: boolean\n versionChange: boolean\n versionChangeConverged: boolean\n versionChangePhase: \"installing\" | \"restarting\" | \"verifying\" | null\n wifiConnected: boolean\n wifiStatusKnown: boolean\n hotspotSupported: boolean\n hotspotPhase: MentraLiveOtaHotspotPhase\n hotspotArtifactPercent: number | null\n /**\n * Current phone download context. Index is zero-based; percent applies to this file only.\n * Optional for source compatibility; this hook returns null when no file is active.\n */\n hotspotArtifact?: {kind: MentraLiveOtaStep; index: number; totalCount: number} | null\n phase: MentraLiveOtaInstallPhase | null\n step: MentraLiveOtaStep | null\n currentStep: number | null\n totalSteps: number | null\n progress: number | null\n installingApkOnly: boolean\n firmwareRestarting: boolean\n error: MentraLiveOtaError | null\n canInstall: boolean\n canRetry: boolean\n canFinish: boolean\n canDismiss: boolean\n canDiscard: boolean\n canOpenWifiSetup: boolean\n continueDisabled: boolean\n /** True only after an approved update session reaches a final no-update check. */\n completedUpdate: boolean\n /** Release labels for the offered or just-completed coordinated update. */\n releaseTransition: MentraLiveOtaReleaseTransition | null\n /** Release notes crossed by this update, newest first. Populated on completion. */\n changelogs: ReleaseChangelog[]\n /** Sideloaded glasses client package, set only on the `unofficial_client` screen. */\n glassesPackageName: string | null\n}\n\nexport type UseMentraLiveOtaOptions = {\n /** Entry page. `progress` exists for interrupted-session recovery. */\n initialPage?: MentraLiveOtaFlowPage\n /** Start Engine's OTA-only projections. Full Engine hosts should pass false. */\n initializeRuntime?: boolean\n /** Called after the final check or when an optional update is dismissed. */\n onFinished?: () => void\n /** Host-owned Wi-Fi setup for glasses without hotspot OTA support. */\n onOpenWifiSetup?: () => void\n /** Lets a host coordinate its connection overlay with OTA firmware restarts. */\n onFirmwareRestartingChange?: (restarting: boolean, progressActive: boolean) => void\n}\n\nexport type MentraLiveOtaController = {\n state: MentraLiveOtaState\n check: () => void\n retryCheck: () => void\n install: () => void\n retryInstall: () => void\n finish: () => void\n discard: () => void\n openWifiSetup: () => void\n}\n\ntype CheckState = \"checking\" | \"update_available\" | \"no_update\" | \"dev_build\" | \"unofficial_client\" | \"error\"\n\nconst AUTO_CHAIN_NETWORK_RETRY_DELAY_MS = 5000\nconst AUTO_CHAIN_COMPLETE_DELAY_MS = 750\nexport const MINIMUM_OTA_BATTERY_LEVEL = 25\n\nfunction releaseRangeTargetVersion(result: OtaCheckCurrentGlassesResult): string | null {\n return result.releaseVersion ?? result.updateInfo?.versionName ?? result.latestVersionInfo?.versionName ?? null\n}\n\nfunction currentReleaseVersion(appVersion: string | null): string | null {\n const version = appVersion?.trim()\n return version || null\n}\n\nfunction releaseTransitionFromRange(range: OtaAutoChainReleaseRange | null): MentraLiveOtaReleaseTransition | null {\n if (!range?.releaseVersion) return null\n return {fromVersion: range.fromVersion, toVersion: range.releaseVersion}\n}\n\nfunction releaseChangelogsForActiveChain(): ReleaseChangelog[] {\n const range = otaAutoChainReleaseRange()\n if (!range?.toVersion) return []\n try {\n return ota.getReleaseChangelogs(range.fromVersion, range.toVersion)\n } catch {\n try {\n return ota.getReleaseChangelogs(null, range.toVersion)\n } catch {\n return []\n }\n }\n}\n\nfunction installProgress(snapshot: OtaInstallSnapshot): number | null {\n if (snapshot.displayState !== \"updating\") return null\n const {otaStatus} = snapshot\n const isDownload = otaStatus?.phase === \"download\"\n const totalSteps = otaStatus?.totalSteps ?? 1\n const rawPercent = isDownload\n ? (otaStatus?.stepPercent ?? 0)\n : totalSteps >= 2\n ? (otaStatus?.overallPercent ?? 0)\n : (otaStatus?.stepPercent ?? 0)\n return Math.min(Math.max(rawPercent, snapshot.mtkInstallStallSimulatedPercent ?? 0, 0), 100)\n}\n\nfunction progressScreen(snapshot: OtaInstallSnapshot): MentraLiveOtaScreen {\n if (snapshot.versionChangePhase === \"restarting\") return \"restarting\"\n if (snapshot.versionChangePhase === \"verifying\") return \"verifying\"\n switch (snapshot.displayState) {\n case \"starting\":\n return snapshot.hotspotPhase === \"idle\" || snapshot.hotspotPhase === \"serving\" ? \"starting\" : \"preparing_hotspot\"\n case \"updating\":\n return \"updating\"\n case \"restarting\":\n return \"restarting\"\n case \"complete\":\n return \"complete\"\n case \"failed\":\n return \"failed\"\n default:\n return \"disconnected\"\n }\n}\n\n/**\n * Headless Mentra Live OTA flow. Engine owns checking, hotspot staging,\n * APK/MTK/BES sequencing, restart recovery, retries, and verification; the host\n * renders semantic state and invokes these idempotent actions.\n */\nexport function useMentraLiveOta(options: UseMentraLiveOtaOptions = {}): MentraLiveOtaController {\n const {\n initialPage = \"check\",\n initializeRuntime = true,\n onFinished,\n onFirmwareRestartingChange,\n onOpenWifiSetup,\n } = options\n const otaSnapshot = useEngineSnapshot(ota.snapshot, ota.onSnapshot)\n const installSnapshot = useEngineSnapshot(ota.installSession.snapshot, ota.installSession.onSnapshot)\n const [page, setPage] = useState<MentraLiveOtaFlowPage>(initialPage)\n const [runtimeReady, setRuntimeReady] = useState(!initializeRuntime)\n const [checkState, setCheckState] = useState<CheckState>(\"checking\")\n const [isUpdateRequired, setIsUpdateRequired] = useState(true)\n const [isVersionChange, setIsVersionChange] = useState(false)\n const [errorKind, setErrorKind] = useState<\"network\" | \"pin_unavailable\">(\"network\")\n const [unofficialClientPackage, setUnofficialClientPackage] = useState<string | null>(null)\n const [updateFingerprint, setUpdateFingerprint] = useState<string | null>(null)\n const [offeredReleaseTransition, setOfferedReleaseTransition] = useState<MentraLiveOtaReleaseTransition | null>(null)\n const [completedReleaseTransition, setCompletedReleaseTransition] = useState<MentraLiveOtaReleaseTransition | null>(\n null,\n )\n const [completedUpdate, setCompletedUpdate] = useState(false)\n const [completedChangelogs, setCompletedChangelogs] = useState<ReleaseChangelog[]>([])\n const [batteryBlocked, setBatteryBlocked] = useState(false)\n const [checkGeneration, setCheckGeneration] = useState(0)\n const performCheckGenerationRef = useRef(0)\n const activeCheckKeyRef = useRef<string | null>(null)\n const checkStartedRef = useRef(false)\n const checkCompletedRef = useRef(false)\n const selectedCheckResultRef = useRef<OtaCheckCurrentGlassesResult | null>(null)\n const autoChainAdvancedRef = useRef(false)\n const installActionPendingRef = useRef(false)\n const onFinishedRef = useRef(onFinished)\n const onOpenWifiSetupRef = useRef(onOpenWifiSetup)\n const onFirmwareRestartingChangeRef = useRef(onFirmwareRestartingChange)\n onFinishedRef.current = onFinished\n onOpenWifiSetupRef.current = onOpenWifiSetup\n onFirmwareRestartingChangeRef.current = onFirmwareRestartingChange\n\n useEffect(() => {\n if (!initializeRuntime) {\n setRuntimeReady(true)\n return\n }\n let cancelled = false\n setRuntimeReady(false)\n void ota.initialize().finally(() => {\n if (!cancelled) setRuntimeReady(true)\n })\n return () => {\n cancelled = true\n }\n }, [initializeRuntime])\n\n const returnToCheck = useCallback(() => {\n installActionPendingRef.current = false\n autoChainAdvancedRef.current = false\n setCheckState(\"checking\")\n setPage(\"check\")\n setCheckGeneration((generation) => generation + 1)\n }, [])\n\n const navigateToProgress = useCallback(() => {\n installActionPendingRef.current = true\n ota.clearProgress()\n setPage(\"progress\")\n }, [])\n\n const continueApprovedChain = useCallback(\n (result: OtaCheckCurrentGlassesResult): boolean => {\n if (installActionPendingRef.current || !isOtaAutoChainActive() || !result.updateInfo) return false\n const snapshot = ota.snapshot()\n if (!snapshot.wifiStatusKnown || (!snapshot.wifiConnected && snapshot.hotspotOtaVersion !== 1)) return false\n\n const admission = tryAdvanceOtaAutoChain(\n otaAutoChainFingerprint(result),\n result.updateInfo.isDowngrade === true,\n releaseRangeTargetVersion(result),\n result.releaseVersion,\n )\n if (!admission.advance) return false\n\n checkCompletedRef.current = true\n ota.installSession.prepare(result)\n navigateToProgress()\n return true\n },\n [navigateToProgress],\n )\n\n useEffect(() => {\n if (!runtimeReady || page !== \"check\") return\n const MIN_DISPLAY_TIME_MS = 1100\n const MAX_WAIT_FOR_VERSION_INFO_MS = 10_000\n const checkKey = String(checkGeneration)\n if (activeCheckKeyRef.current !== checkKey) {\n activeCheckKeyRef.current = checkKey\n checkStartedRef.current = false\n checkCompletedRef.current = false\n selectedCheckResultRef.current = null\n installActionPendingRef.current = false\n setCheckState(\"checking\")\n }\n\n const myGeneration = ++performCheckGenerationRef.current\n let cancelled = false\n let reconnectTimeout: ReturnType<typeof setTimeout> | null = null\n\n const performCheck = async () => {\n if (checkCompletedRef.current) return\n if (isOtaAutoChainActive() && !otaSnapshot.ready) {\n const remainingMs = otaAutoChainReconnectWaitRemaining()\n if (remainingMs === null) return\n reconnectTimeout = setTimeout(() => {\n if (cancelled || myGeneration !== performCheckGenerationRef.current || ota.snapshot().ready) return\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setCheckState(\"error\")\n }, remainingMs)\n return\n }\n if (!otaSnapshot.connected) {\n if (checkStartedRef.current) {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setCheckState(\"error\")\n return\n }\n checkCompletedRef.current = true\n onFinishedRef.current?.()\n return\n }\n\n clearOtaAutoChainReconnectWait()\n checkStartedRef.current = true\n const startTime = Date.now()\n try {\n const checkOptions = {\n waitForBuildNumberMs: MAX_WAIT_FOR_VERSION_INFO_MS,\n waitForBesVersionMs: 5000,\n waitForMtkVersionMs: 2000,\n refreshVersionInfo: true,\n fixClockBeforeCheck: false,\n }\n let result = await ota.checkForUpdates(checkOptions)\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n if (!result.hasCheckCompleted && result.checkFailureReason === \"network\" && isOtaAutoChainActive()) {\n await new Promise((resolve) => setTimeout(resolve, AUTO_CHAIN_NETWORK_RETRY_DELAY_MS))\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n result = await ota.checkForUpdates(checkOptions)\n }\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n selectedCheckResultRef.current = result\n await new Promise((resolve) => setTimeout(resolve, Math.max(0, MIN_DISPLAY_TIME_MS - (Date.now() - startTime))))\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n\n if (result.skippedReason === \"disconnected\") {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setCheckState(\"error\")\n return\n }\n if (result.skippedReason === \"missing_build\") {\n checkCompletedRef.current = true\n if (isOtaAutoChainActive()) {\n stopOtaAutoChain()\n setCheckState(\"error\")\n } else {\n onFinishedRef.current?.()\n }\n return\n }\n if (result.skippedReason === \"dev_build\") {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n ota.clearUpdateAvailable()\n setCheckState(\"dev_build\")\n return\n }\n if (result.skippedReason === \"unofficial_client\") {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n ota.clearUpdateAvailable()\n setUnofficialClientPackage(result.packageName ?? null)\n setCheckState(\"unofficial_client\")\n return\n }\n if (!result.hasCheckCompleted) {\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setErrorKind(result.checkFailureReason === \"pin_unavailable\" ? \"pin_unavailable\" : \"network\")\n setCheckState(\"error\")\n return\n }\n if (result.updateAvailable && result.updateInfo) {\n setIsUpdateRequired(result.isRequired)\n setIsVersionChange(result.updateInfo.isDowngrade === true)\n const fingerprint = otaAutoChainFingerprint(result)\n setUpdateFingerprint(fingerprint)\n if (!isOtaAutoChainActive()) {\n const fromVersion = currentReleaseVersion(ota.snapshot().appVersion)\n setOfferedReleaseTransition(result.releaseVersion ? {fromVersion, toVersion: result.releaseVersion} : null)\n }\n if (isOtaAutoChainActive() && !ota.snapshot().wifiStatusKnown) {\n checkCompletedRef.current = true\n return\n }\n if (continueApprovedChain(result)) return\n checkCompletedRef.current = true\n setCheckState(\"update_available\")\n return\n }\n const completedApprovedSession = isOtaAutoChainActive()\n if (completedApprovedSession) {\n setCompletedChangelogs(releaseChangelogsForActiveChain())\n setCompletedReleaseTransition(releaseTransitionFromRange(otaAutoChainReleaseRange()))\n }\n setCompletedUpdate(completedApprovedSession)\n stopOtaAutoChain()\n checkCompletedRef.current = true\n ota.clearUpdateAvailable()\n setCheckState(\"no_update\")\n } catch (error) {\n console.error(\"OTA check failed:\", error)\n await new Promise((resolve) => setTimeout(resolve, Math.max(0, MIN_DISPLAY_TIME_MS - (Date.now() - startTime))))\n if (cancelled || myGeneration !== performCheckGenerationRef.current) return\n stopOtaAutoChain()\n checkCompletedRef.current = true\n setErrorKind(\"network\")\n setCheckState(\"error\")\n }\n }\n\n void performCheck()\n return () => {\n cancelled = true\n if (reconnectTimeout) clearTimeout(reconnectTimeout)\n }\n }, [\n checkGeneration,\n continueApprovedChain,\n otaSnapshot.connected,\n otaSnapshot.ready,\n otaSnapshot.wifiStatusKnown,\n page,\n runtimeReady,\n ])\n\n useEffect(() => {\n if (\n !runtimeReady ||\n page !== \"check\" ||\n (checkState !== \"checking\" && checkState !== \"update_available\") ||\n !otaSnapshot.wifiStatusKnown ||\n !isOtaAutoChainActive()\n ) {\n return\n }\n const result = selectedCheckResultRef.current\n if (!result?.updateAvailable || !result.updateInfo) return\n if (!otaSnapshot.wifiConnected && otaSnapshot.hotspotOtaVersion !== 1) {\n setCheckState(\"update_available\")\n return\n }\n continueApprovedChain(result)\n }, [\n checkState,\n continueApprovedChain,\n otaSnapshot.hotspotOtaVersion,\n otaSnapshot.wifiConnected,\n otaSnapshot.wifiStatusKnown,\n page,\n runtimeReady,\n ])\n\n useEffect(() => {\n if (!runtimeReady || page !== \"progress\") return\n ota.installSession.attach()\n return () => ota.installSession.detach()\n }, [page, runtimeReady])\n\n const firmwareRestarting =\n page === \"progress\" &&\n ((!installSnapshot.connected && installSnapshot.displayState === \"restarting\") ||\n installSnapshot.versionChangePhase === \"restarting\")\n\n useEffect(() => {\n if (page !== \"progress\") return\n onFirmwareRestartingChangeRef.current?.(firmwareRestarting, true)\n }, [firmwareRestarting, page])\n\n useEffect(() => {\n if (page !== \"progress\") return\n return () => {\n onFirmwareRestartingChangeRef.current?.(false, false)\n }\n }, [page])\n\n useEffect(() => {\n if (\n page !== \"progress\" ||\n installSnapshot.displayState !== \"complete\" ||\n !installSnapshot.connected ||\n !isOtaAutoChainActive() ||\n autoChainAdvancedRef.current\n ) {\n return\n }\n const timeout = setTimeout(async () => {\n if (!isOtaAutoChainActive()) return\n autoChainAdvancedRef.current = true\n await ota.installSession.finish()\n returnToCheck()\n }, AUTO_CHAIN_COMPLETE_DELAY_MS)\n return () => clearTimeout(timeout)\n }, [installSnapshot.connected, installSnapshot.displayState, page, returnToCheck])\n\n const check = useCallback(() => {\n setBatteryBlocked(false)\n setOfferedReleaseTransition(null)\n setCompletedReleaseTransition(null)\n setCompletedUpdate(false)\n setCompletedChangelogs([])\n setPage(\"check\")\n setCheckState(\"checking\")\n setCheckGeneration((generation) => generation + 1)\n }, [])\n\n const install = useCallback(() => {\n if (installActionPendingRef.current || page !== \"check\") return\n const result = selectedCheckResultRef.current\n if (!result) {\n setErrorKind(\"network\")\n setCheckState(\"error\")\n return\n }\n const snapshot = ota.snapshot()\n if (snapshot.batteryLevel !== null && snapshot.batteryLevel < MINIMUM_OTA_BATTERY_LEVEL) {\n setBatteryBlocked(true)\n return\n }\n if (!snapshot.wifiStatusKnown) {\n check()\n return\n }\n if (!snapshot.wifiConnected && snapshot.hotspotOtaVersion !== 1) {\n onOpenWifiSetupRef.current?.()\n return\n }\n ota.installSession.prepare(result)\n setBatteryBlocked(false)\n setCompletedUpdate(false)\n setCompletedChangelogs([])\n if (updateFingerprint) {\n const fromVersion = offeredReleaseTransition\n ? offeredReleaseTransition.fromVersion\n : currentReleaseVersion(snapshot.appVersion)\n beginOtaAutoChain(updateFingerprint, isVersionChange, {\n fromVersion,\n toVersion: releaseRangeTargetVersion(result),\n releaseVersion: result.releaseVersion,\n })\n }\n navigateToProgress()\n }, [check, isVersionChange, navigateToProgress, offeredReleaseTransition, page, updateFingerprint])\n\n useEffect(() => {\n if (\n batteryBlocked &&\n (otaSnapshot.batteryLevel === null || otaSnapshot.batteryLevel >= MINIMUM_OTA_BATTERY_LEVEL)\n ) {\n setBatteryBlocked(false)\n }\n }, [batteryBlocked, otaSnapshot.batteryLevel])\n\n const retryInstall = useCallback(() => {\n if (page !== \"progress\") return\n onFirmwareRestartingChangeRef.current?.(false, true)\n ota.installSession.retry()\n }, [page])\n\n const finish = useCallback(async () => {\n if (page === \"check\") {\n onFinishedRef.current?.()\n return\n }\n const restartStillInProgress =\n installSnapshot.displayState === \"restarting\" ||\n installSnapshot.versionChangePhase === \"restarting\" ||\n installSnapshot.versionChangePhase === \"verifying\"\n if (restartStillInProgress) return\n const requiresGlassesReboot = shouldRequireGlassesRebootForBesFailure(\n installSnapshot.otaStatus,\n installSnapshot.otaProgress,\n installSnapshot.errorMsg,\n )\n if (requiresGlassesReboot) stopOtaAutoChain()\n await ota.installSession.finish()\n returnToCheck()\n }, [installSnapshot, page, returnToCheck])\n\n const discard = useCallback(async () => {\n if (page !== \"progress\") return\n stopOtaAutoChain()\n await ota.installSession.discard()\n returnToCheck()\n }, [page, returnToCheck])\n\n const openWifiSetup = useCallback(() => {\n if (page === \"progress\") stopOtaAutoChain()\n onOpenWifiSetupRef.current?.()\n }, [page])\n\n const state = useMemo<MentraLiveOtaState>(() => {\n const hotspotSupported = otaSnapshot.hotspotOtaVersion === 1\n const canInstall = otaSnapshot.wifiStatusKnown && (otaSnapshot.wifiConnected || hotspotSupported)\n const autoChainActive = isOtaAutoChainActive()\n if (!runtimeReady) {\n return {\n screen: \"initializing\",\n connected: otaSnapshot.connected,\n batteryLevel: otaSnapshot.batteryLevel,\n transport: null,\n updateRequired: isUpdateRequired,\n versionChange: isVersionChange,\n versionChangeConverged: false,\n versionChangePhase: null,\n wifiConnected: otaSnapshot.wifiConnected,\n wifiStatusKnown: otaSnapshot.wifiStatusKnown,\n hotspotSupported,\n hotspotPhase: \"idle\",\n hotspotArtifactPercent: null,\n hotspotArtifact: null,\n phase: null,\n step: null,\n currentStep: null,\n totalSteps: null,\n progress: null,\n installingApkOnly: false,\n firmwareRestarting: false,\n error: null,\n canInstall: false,\n canRetry: false,\n canFinish: false,\n canDismiss: false,\n canDiscard: false,\n canOpenWifiSetup: false,\n continueDisabled: false,\n completedUpdate: false,\n releaseTransition: null,\n changelogs: [],\n glassesPackageName: null,\n }\n }\n\n if (page === \"check\") {\n const wifiRequired = otaSnapshot.wifiStatusKnown && !otaSnapshot.wifiConnected && !hotspotSupported\n let screen: MentraLiveOtaScreen\n if (checkState === \"checking\") screen = autoChainActive ? \"finishing\" : \"checking\"\n else if (checkState === \"update_available\") {\n screen = wifiRequired ? \"wifi_required\" : batteryBlocked ? \"battery_required\" : \"update_available\"\n } else if (checkState === \"no_update\") screen = \"up_to_date\"\n else if (checkState === \"dev_build\") screen = \"dev_build\"\n else if (checkState === \"unofficial_client\") screen = \"unofficial_client\"\n else screen = errorKind === \"pin_unavailable\" ? \"update_info_unavailable\" : \"check_failed\"\n\n let error: MentraLiveOtaError | null = null\n if (screen === \"check_failed\") {\n error = {\n code: \"check_failed\",\n message: \"Couldn't check for updates. Please check your connection and try again.\",\n }\n } else if (screen === \"update_info_unavailable\") {\n error = {code: \"update_info_unavailable\", message: \"Update information for this app version is unavailable.\"}\n }\n return {\n screen,\n connected: otaSnapshot.connected,\n batteryLevel: otaSnapshot.batteryLevel,\n transport: otaSnapshot.wifiConnected ? \"wifi\" : hotspotSupported ? \"hotspot\" : null,\n updateRequired: isUpdateRequired,\n versionChange: isVersionChange,\n versionChangeConverged: false,\n versionChangePhase: null,\n wifiConnected: otaSnapshot.wifiConnected,\n wifiStatusKnown: otaSnapshot.wifiStatusKnown,\n hotspotSupported,\n hotspotPhase: \"idle\",\n hotspotArtifactPercent: null,\n hotspotArtifact: null,\n phase: null,\n step: null,\n currentStep: null,\n totalSteps: null,\n progress: null,\n installingApkOnly: false,\n firmwareRestarting: false,\n error,\n canInstall: screen === \"update_available\" && canInstall,\n canRetry: screen === \"check_failed\",\n canFinish:\n screen === \"up_to_date\" ||\n screen === \"dev_build\" ||\n screen === \"unofficial_client\" ||\n screen === \"update_info_unavailable\",\n canDismiss:\n (screen === \"update_available\" || screen === \"wifi_required\" || screen === \"battery_required\") &&\n !isUpdateRequired &&\n !autoChainActive,\n canDiscard: false,\n canOpenWifiSetup: screen === \"wifi_required\",\n continueDisabled: false,\n completedUpdate: screen === \"up_to_date\" && completedUpdate,\n releaseTransition:\n screen === \"update_available\" || screen === \"wifi_required\"\n ? autoChainActive\n ? releaseTransitionFromRange(otaAutoChainReleaseRange())\n : offeredReleaseTransition\n : screen === \"up_to_date\"\n ? completedReleaseTransition\n : null,\n changelogs: screen === \"up_to_date\" ? completedChangelogs : [],\n glassesPackageName: screen === \"unofficial_client\" ? unofficialClientPackage : null,\n }\n }\n\n const requiresGlassesReboot = shouldRequireGlassesRebootForBesFailure(\n installSnapshot.otaStatus,\n installSnapshot.otaProgress,\n installSnapshot.errorMsg,\n )\n const showChangeWifi = shouldShowChangeWifiForOtaDownloadFailure(\n installSnapshot.otaStatus,\n installSnapshot.otaProgress,\n installSnapshot.errorMsg,\n )\n const displayedError = requiresGlassesReboot\n ? BES_INSTALL_RESTART_MESSAGE\n : installSnapshot.errorMsg || getOtaErrorMessage(installSnapshot.otaStatus?.error)\n const progressState = progressScreen(installSnapshot)\n const screen = progressState === \"complete\" && autoChainActive ? \"finishing\" : progressState\n const error =\n screen === \"failed\"\n ? {\n code: requiresGlassesReboot ? (\"bes_restart_required\" as const) : (\"install_failed\" as const),\n message: displayedError,\n }\n : null\n const totalSteps = installSnapshot.otaStatus?.totalSteps ?? null\n const artifact = installSnapshot.hotspotArtifact\n const changelogs = screen === \"complete\" ? releaseChangelogsForActiveChain() : []\n return {\n screen,\n connected: installSnapshot.connected,\n batteryLevel: otaSnapshot.batteryLevel,\n transport: installSnapshot.transport,\n updateRequired: isUpdateRequired,\n versionChange: installSnapshot.isVersionChange,\n versionChangeConverged: installSnapshot.versionChangeConverged,\n versionChangePhase: installSnapshot.versionChangePhase,\n wifiConnected: otaSnapshot.wifiConnected,\n wifiStatusKnown: otaSnapshot.wifiStatusKnown,\n hotspotSupported,\n hotspotPhase: installSnapshot.hotspotPhase,\n hotspotArtifactPercent: installSnapshot.hotspotArtifactPercent,\n hotspotArtifact: artifact ? {kind: artifact.kind, index: artifact.index, totalCount: artifact.totalCount} : null,\n phase: installSnapshot.otaStatus?.phase ?? installSnapshot.otaProgress?.stage ?? null,\n step: installSnapshot.otaStatus?.stepType ?? null,\n currentStep: installSnapshot.otaStatus?.currentStep ?? null,\n totalSteps,\n progress: installProgress(installSnapshot),\n installingApkOnly:\n installSnapshot.otaStatus?.stepType === \"apk\" &&\n installSnapshot.otaStatus.phase === \"install\" &&\n totalSteps === 1,\n firmwareRestarting,\n error,\n canInstall: false,\n canRetry: screen === \"failed\" && !requiresGlassesReboot,\n canFinish: screen === \"complete\" || (screen === \"failed\" && requiresGlassesReboot),\n canDismiss: false,\n canDiscard: screen === \"disconnected\",\n canOpenWifiSetup: screen === \"failed\" && showChangeWifi,\n continueDisabled: installSnapshot.continueButtonDisabled,\n completedUpdate: false,\n releaseTransition: releaseTransitionFromRange(otaAutoChainReleaseRange()),\n changelogs,\n glassesPackageName: null,\n }\n }, [\n unofficialClientPackage,\n checkState,\n batteryBlocked,\n completedChangelogs,\n completedReleaseTransition,\n completedUpdate,\n errorKind,\n firmwareRestarting,\n installSnapshot,\n isUpdateRequired,\n isVersionChange,\n otaSnapshot,\n offeredReleaseTransition,\n page,\n runtimeReady,\n ])\n\n return useMemo(\n () => ({state, check, retryCheck: check, install, retryInstall, finish, discard, openWifiSetup}),\n [check, discard, finish, install, openWifiSetup, retryInstall, state],\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaArtifactDownloader.d.ts","sourceRoot":"","sources":["../../src/services/OtaArtifactDownloader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,4BAA4B,EAAc,MAAM,yBAAyB,CAAA;AAEtF;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;AAEnD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,eAAe,CAAA;IACrB,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAA;IACX,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,eAAe,CAAA;IACrB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,gBAAiB,SAAQ,KAAK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AAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,gBAAiB,SAAQ,KAAK;aAEvB,IAAI,EAAE,0BAA0B,GAAG,wBAAwB,GAAG,kBAAkB;gBAAhF,IAAI,EAAE,0BAA0B,GAAG,wBAAwB,GAAG,kBAAkB,EAChG,OAAO,EAAE,MAAM;CAKlB;AAID,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,4BAA4B,GAAG,oBAAoB,EAAE,CAwD1F;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,oBAAoB,EAAE,EAC5B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,2BAA2B,KAAK,IAAI,EAC5D,cAAc,CAAC,EAAE,CACf,KAAK,EAAE,oBAAoB,EAC3B,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,KAC/D,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAAC,GACjC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAoFhC;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,mBAAmB,EAAE,EAChC,OAAO,EAAE,MAAM,GACd,MAAM,CA6BR;AAED,gGAAgG;AAChG,wBAAsB,gBAAgB,CAAC,WAAW,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAYhF"}
|
|
@@ -78,6 +78,16 @@ export async function prepareArtifacts(plan, onProgress, nativeDownload) {
|
|
|
78
78
|
const prepared = [];
|
|
79
79
|
for (let index = 0; index < plan.length; index++) {
|
|
80
80
|
const entry = plan[index];
|
|
81
|
+
// Announce each file before cache verification or native download callbacks,
|
|
82
|
+
// so the previous file's 100% cannot linger under the next file's label.
|
|
83
|
+
onProgress?.({
|
|
84
|
+
kind: entry.kind,
|
|
85
|
+
index,
|
|
86
|
+
totalCount: plan.length,
|
|
87
|
+
artifactPercent: 0,
|
|
88
|
+
bytesWritten: 0,
|
|
89
|
+
contentLength: 0,
|
|
90
|
+
});
|
|
81
91
|
const cachedPath = `${directory}/${entry.sha256}`;
|
|
82
92
|
if (await RNFS.exists(cachedPath)) {
|
|
83
93
|
const cachedHash = (await RNFS.hash(cachedPath, "sha256")).toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaArtifactDownloader.js","sourceRoot":"","sources":["../../src/services/OtaArtifactDownloader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AA2CnD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAEvB;IADlB,YACkB,IAAgF,EAChG,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAA;QAHE,SAAI,GAAJ,IAAI,CAA4E;QAIhG,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;IAChC,CAAC;CACF;AAED,MAAM,WAAW,GAAG,uBAAuB,CAAA;AAE3C,MAAM,UAAU,qBAAqB;IACnC,OAAO,GAAG,IAAI,CAAC,qBAAqB,gBAAgB,CAAA;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAoC;IAChE,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACzB,MAAM,IAAI,gBAAgB,CAAC,kBAAkB,EAAE,uCAAuC,CAAC,CAAA;IACzF,CAAC;IACD,IAAI,QAAqB,CAAA;IACzB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAC5C,CAAC;IAAC,MAAM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,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,6EAA6E;IAC/E,CAAC;AACH,CAAC","sourcesContent":["import * as RNFS from \"@dr.pogodin/react-native-fs\"\nimport type {OtaCheckCurrentGlassesResult, VersionJson} from \"./OtaUpdateCheckService\"\n\n/**\n * Phone-side artifact staging for hotspot-served OTA (OS-1676).\n *\n * When the glasses have no WiFi, the phone downloads the OTA artifacts itself (over\n * whatever network it is on — the user's tap on \"update\" is the consent) and serves them\n * to the glasses via the LocalOtaServer over the glasses' hotspot. This module owns:\n *\n * - planning which artifacts the pending update actually needs (from the raw manifest the\n * update check fetched, so the glasses re-parse byte-identical version data),\n * - downloading them with .part staging and sha256 verification, keyed on disk by hash so\n * retries and the post-APK continuation reuse verified files,\n * - rewriting the manifest's URL fields to point at the phone server, and\n * - cleanup once the update completes or the manifest moves on.\n */\n\nexport type OtaArtifactKind = \"apk\" | \"mtk\" | \"bes\"\n\nexport interface OtaArtifactPlanEntry {\n kind: OtaArtifactKind\n /** URL this artifact is fetched from, exactly as it appears in the raw manifest. */\n url: string\n /** Required content hash from the manifest. */\n sha256: string\n}\n\nexport interface PreparedOtaArtifact extends OtaArtifactPlanEntry {\n filePath: string\n}\n\nexport interface OtaArtifactDownloadProgress {\n kind: OtaArtifactKind\n /** 0-based index of the artifact being downloaded. */\n index: number\n totalCount: number\n /** Percent of the current artifact, 0-100 (0 when the server sent no length). */\n artifactPercent: number\n bytesWritten: number\n contentLength: number\n}\n\nexport class OtaArtifactError extends Error {\n constructor(\n public readonly code: \"artifact_download_failed\" | \"artifact_verify_failed\" | \"manifest_invalid\",\n message: string,\n ) {\n super(message)\n this.name = \"OtaArtifactError\"\n }\n}\n\nconst ASG_PACKAGE = \"com.mentra.asg_client\"\n\nexport function otaArtifactsDirectory(): string {\n return `${RNFS.DocumentDirectoryPath}/ota_artifacts`\n}\n\n/**\n * Derive the artifact list the pending update needs from a completed check.\n * Works off the raw manifest body (not the normalized check fields) so the URLs and\n * hashes match exactly what the glasses will re-parse.\n */\nexport function planArtifacts(result: OtaCheckCurrentGlassesResult): OtaArtifactPlanEntry[] {\n if (!result.manifestBody) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Check result carries no manifest body\")\n }\n let manifest: VersionJson\n try {\n manifest = JSON.parse(result.manifestBody)\n } catch {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest body is not valid JSON\")\n }\n\n const entries: OtaArtifactPlanEntry[] = []\n\n if (result.updates.includes(\"apk\")) {\n const app = manifest.apps?.[ASG_PACKAGE] as unknown as Record<string, unknown> | undefined\n const url = typeof app?.apkUrl === \"string\" ? app.apkUrl : null\n if (!url) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest has no apkUrl for the pending APK update\")\n }\n entries.push({\n kind: \"apk\",\n url,\n sha256: requireSha256(app, \"APK\"),\n })\n }\n\n if (result.updates.includes(\"mtk\") && result.mtkPatch) {\n const candidates = [...(manifest.mtk_patches ?? []), ...(manifest.mtk_full_ota ? [manifest.mtk_full_ota] : [])]\n const raw = candidates.find((entry) => firmwareUrl(entry) === firmwareUrl(result.mtkPatch!)) as unknown as\n | Record<string, unknown>\n | undefined\n const url = firmwareUrl(raw) ?? firmwareUrl(result.mtkPatch)\n if (!url) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest has no URL for the pending MTK patch\")\n }\n entries.push({\n kind: \"mtk\",\n url,\n sha256: requireSha256(raw, \"MTK\"),\n })\n }\n\n if (result.updates.includes(\"bes\") && manifest.bes_firmware) {\n const raw = manifest.bes_firmware as unknown as Record<string, unknown>\n const url = firmwareUrl(raw)\n if (!url) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest has no URL for the pending BES firmware\")\n }\n entries.push({\n kind: \"bes\",\n url,\n sha256: requireSha256(raw, \"BES\"),\n })\n }\n\n return entries\n}\n\n/**\n * Download every planned artifact into the on-disk hash-keyed store, reusing files that\n * already verify. Sequential on purpose: progress is legible and the hotspot window that\n * follows is the slow part, not phone-side parallelism.\n */\nexport async function prepareArtifacts(\n plan: OtaArtifactPlanEntry[],\n onProgress?: (progress: OtaArtifactDownloadProgress) => void,\n nativeDownload?: (\n entry: OtaArtifactPlanEntry,\n destination: string,\n onProgress?: (bytesWritten: number, contentLength: number) => void,\n ) => Promise<{statusCode: number}>,\n): Promise<PreparedOtaArtifact[]> {\n const directory = otaArtifactsDirectory()\n await RNFS.mkdir(directory, {NSURLIsExcludedFromBackupKey: true})\n\n const prepared: PreparedOtaArtifact[] = []\n for (let index = 0; index < plan.length; index++) {\n const entry = plan[index]\n\n const cachedPath = `${directory}/${entry.sha256}`\n if (await RNFS.exists(cachedPath)) {\n const cachedHash = (await RNFS.hash(cachedPath, \"sha256\")).toLowerCase()\n if (cachedHash === entry.sha256) {\n prepared.push({...entry, filePath: cachedPath})\n continue\n }\n await safeUnlink(cachedPath)\n }\n\n const partPath = `${directory}/download-${index}.part`\n await safeUnlink(partPath)\n try {\n const reportProgress = (bytesWritten: number, contentLength: number) => {\n onProgress?.({\n kind: entry.kind,\n index,\n totalCount: plan.length,\n artifactPercent: contentLength > 0 ? Math.round((bytesWritten / contentLength) * 100) : 0,\n bytesWritten,\n contentLength,\n })\n }\n const downloadResult = nativeDownload\n ? await nativeDownload(entry, partPath, reportProgress)\n : await RNFS.downloadFile({\n fromUrl: entry.url,\n toFile: partPath,\n connectionTimeout: 30_000,\n readTimeout: 30_000,\n progressDivider: 5,\n progress: (res: RNFS.DownloadProgressCallbackResultT) => {\n reportProgress(res.bytesWritten, res.contentLength)\n },\n }).promise\n if (downloadResult.statusCode !== 200) {\n throw new OtaArtifactError(\n \"artifact_download_failed\",\n `Download of ${entry.kind} artifact failed with HTTP ${downloadResult.statusCode}`,\n )\n }\n\n const actualSha256 = (await RNFS.hash(partPath, \"sha256\")).toLowerCase()\n if (actualSha256 !== entry.sha256) {\n throw new OtaArtifactError(\n \"artifact_verify_failed\",\n `${entry.kind} artifact hash mismatch: expected ${entry.sha256}, got ${actualSha256}`,\n )\n }\n\n const finalPath = `${directory}/${entry.sha256}`\n await safeUnlink(finalPath)\n await RNFS.moveFile(partPath, finalPath)\n prepared.push({...entry, filePath: finalPath})\n } catch (error) {\n await safeUnlink(partPath)\n if (error instanceof OtaArtifactError) {\n throw error\n }\n throw new OtaArtifactError(\n \"artifact_download_failed\",\n `Download of ${entry.kind} artifact failed: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n return prepared\n}\n\n/**\n * Point the manifest's artifact URLs at the phone server, leaving every other field\n * semantically identical to what the update check saw. Entries we host get\n * `<baseUrl>/artifacts/<sha256>`; entries the update does not need keep their CDN URLs.\n * Only URL fields change: target versions, sizes, and manifest hashes remain untouched.\n */\nexport function rewriteManifestForLocalServer(\n manifestBody: string,\n artifacts: PreparedOtaArtifact[],\n baseUrl: string,\n): string {\n let manifest: VersionJson\n try {\n manifest = JSON.parse(manifestBody)\n } catch {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest body is not valid JSON\")\n }\n const byUrl = new Map(artifacts.map((artifact) => [artifact.url, artifact]))\n const localUrl = (artifact: PreparedOtaArtifact) => `${baseUrl}/artifacts/${artifact.sha256}`\n\n for (const app of Object.values(manifest.apps ?? {})) {\n const record = app as unknown as Record<string, unknown>\n const artifact = typeof record.apkUrl === \"string\" ? byUrl.get(record.apkUrl) : undefined\n if (artifact) {\n record.apkUrl = localUrl(artifact)\n }\n }\n\n for (const patch of manifest.mtk_patches ?? []) {\n rewriteFirmwareEntry(patch as unknown as Record<string, unknown>, byUrl, localUrl)\n }\n if (manifest.mtk_full_ota) {\n rewriteFirmwareEntry(manifest.mtk_full_ota as unknown as Record<string, unknown>, byUrl, localUrl)\n }\n if (manifest.bes_firmware) {\n rewriteFirmwareEntry(manifest.bes_firmware as unknown as Record<string, unknown>, byUrl, localUrl)\n }\n\n return JSON.stringify(manifest)\n}\n\n/** Delete every stored artifact whose hash is not in `keepSha256s` (plus stray .part files). */\nexport async function cleanupArtifacts(keepSha256s: string[] = []): Promise<void> {\n const directory = otaArtifactsDirectory()\n if (!(await RNFS.exists(directory))) {\n return\n }\n const keep = new Set(keepSha256s.map((sha) => sha.toLowerCase()))\n const items = await RNFS.readDir(directory)\n for (const item of items) {\n if (!item.isFile()) continue\n if (keep.has(item.name.toLowerCase())) continue\n await safeUnlink(item.path)\n }\n}\n\nfunction rewriteFirmwareEntry(\n entry: Record<string, unknown>,\n byUrl: Map<string, PreparedOtaArtifact>,\n localUrl: (artifact: PreparedOtaArtifact) => string,\n): void {\n const url = firmwareUrl(entry)\n const artifact = url ? byUrl.get(url) : undefined\n if (!artifact) {\n return\n }\n entry.url = localUrl(artifact)\n // Overwrite the legacy key too when present, so no glasses build can prefer a stale\n // CDN URL over the local one.\n if (typeof entry.firmwareUrl === \"string\") {\n entry.firmwareUrl = localUrl(artifact)\n }\n}\n\nfunction firmwareUrl(entry: unknown): string | null {\n if (!entry || typeof entry !== \"object\") {\n return null\n }\n const record = entry as Record<string, unknown>\n if (typeof record.url === \"string\" && record.url.length > 0) {\n return record.url\n }\n if (typeof record.firmwareUrl === \"string\" && record.firmwareUrl.length > 0) {\n return record.firmwareUrl\n }\n return null\n}\n\nfunction requireSha256(entry: Record<string, unknown> | undefined, label: string): string {\n const sha256 = typeof entry?.sha256 === \"string\" ? entry.sha256.trim().toLowerCase() : \"\"\n if (!/^[a-f0-9]{64}$/.test(sha256)) {\n throw new OtaArtifactError(\"manifest_invalid\", `${label} artifact has no valid manifest sha256`)\n }\n return sha256\n}\n\nasync function safeUnlink(path: string): Promise<void> {\n try {\n if (await RNFS.exists(path)) {\n await RNFS.unlink(path)\n }\n } catch {\n // Best-effort: a leftover file only wastes space and is c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AM,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,6EAA6E;IAC/E,CAAC;AACH,CAAC","sourcesContent":["import * as RNFS from \"@dr.pogodin/react-native-fs\"\nimport type {OtaCheckCurrentGlassesResult, VersionJson} from \"./OtaUpdateCheckService\"\n\n/**\n * Phone-side artifact staging for hotspot-served OTA (OS-1676).\n *\n * When the glasses have no WiFi, the phone downloads the OTA artifacts itself (over\n * whatever network it is on — the user's tap on \"update\" is the consent) and serves them\n * to the glasses via the LocalOtaServer over the glasses' hotspot. This module owns:\n *\n * - planning which artifacts the pending update actually needs (from the raw manifest the\n * update check fetched, so the glasses re-parse byte-identical version data),\n * - downloading them with .part staging and sha256 verification, keyed on disk by hash so\n * retries and the post-APK continuation reuse verified files,\n * - rewriting the manifest's URL fields to point at the phone server, and\n * - cleanup once the update completes or the manifest moves on.\n */\n\nexport type OtaArtifactKind = \"apk\" | \"mtk\" | \"bes\"\n\nexport interface OtaArtifactPlanEntry {\n kind: OtaArtifactKind\n /** URL this artifact is fetched from, exactly as it appears in the raw manifest. */\n url: string\n /** Required content hash from the manifest. */\n sha256: string\n}\n\nexport interface PreparedOtaArtifact extends OtaArtifactPlanEntry {\n filePath: string\n}\n\nexport interface OtaArtifactDownloadProgress {\n kind: OtaArtifactKind\n /** 0-based index of the artifact being downloaded. */\n index: number\n totalCount: number\n /** Percent of the current artifact, 0-100 (0 when the server sent no length). */\n artifactPercent: number\n bytesWritten: number\n contentLength: number\n}\n\nexport class OtaArtifactError extends Error {\n constructor(\n public readonly code: \"artifact_download_failed\" | \"artifact_verify_failed\" | \"manifest_invalid\",\n message: string,\n ) {\n super(message)\n this.name = \"OtaArtifactError\"\n }\n}\n\nconst ASG_PACKAGE = \"com.mentra.asg_client\"\n\nexport function otaArtifactsDirectory(): string {\n return `${RNFS.DocumentDirectoryPath}/ota_artifacts`\n}\n\n/**\n * Derive the artifact list the pending update needs from a completed check.\n * Works off the raw manifest body (not the normalized check fields) so the URLs and\n * hashes match exactly what the glasses will re-parse.\n */\nexport function planArtifacts(result: OtaCheckCurrentGlassesResult): OtaArtifactPlanEntry[] {\n if (!result.manifestBody) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Check result carries no manifest body\")\n }\n let manifest: VersionJson\n try {\n manifest = JSON.parse(result.manifestBody)\n } catch {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest body is not valid JSON\")\n }\n\n const entries: OtaArtifactPlanEntry[] = []\n\n if (result.updates.includes(\"apk\")) {\n const app = manifest.apps?.[ASG_PACKAGE] as unknown as Record<string, unknown> | undefined\n const url = typeof app?.apkUrl === \"string\" ? app.apkUrl : null\n if (!url) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest has no apkUrl for the pending APK update\")\n }\n entries.push({\n kind: \"apk\",\n url,\n sha256: requireSha256(app, \"APK\"),\n })\n }\n\n if (result.updates.includes(\"mtk\") && result.mtkPatch) {\n const candidates = [...(manifest.mtk_patches ?? []), ...(manifest.mtk_full_ota ? [manifest.mtk_full_ota] : [])]\n const raw = candidates.find((entry) => firmwareUrl(entry) === firmwareUrl(result.mtkPatch!)) as unknown as\n | Record<string, unknown>\n | undefined\n const url = firmwareUrl(raw) ?? firmwareUrl(result.mtkPatch)\n if (!url) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest has no URL for the pending MTK patch\")\n }\n entries.push({\n kind: \"mtk\",\n url,\n sha256: requireSha256(raw, \"MTK\"),\n })\n }\n\n if (result.updates.includes(\"bes\") && manifest.bes_firmware) {\n const raw = manifest.bes_firmware as unknown as Record<string, unknown>\n const url = firmwareUrl(raw)\n if (!url) {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest has no URL for the pending BES firmware\")\n }\n entries.push({\n kind: \"bes\",\n url,\n sha256: requireSha256(raw, \"BES\"),\n })\n }\n\n return entries\n}\n\n/**\n * Download every planned artifact into the on-disk hash-keyed store, reusing files that\n * already verify. Sequential on purpose: progress is legible and the hotspot window that\n * follows is the slow part, not phone-side parallelism.\n */\nexport async function prepareArtifacts(\n plan: OtaArtifactPlanEntry[],\n onProgress?: (progress: OtaArtifactDownloadProgress) => void,\n nativeDownload?: (\n entry: OtaArtifactPlanEntry,\n destination: string,\n onProgress?: (bytesWritten: number, contentLength: number) => void,\n ) => Promise<{statusCode: number}>,\n): Promise<PreparedOtaArtifact[]> {\n const directory = otaArtifactsDirectory()\n await RNFS.mkdir(directory, {NSURLIsExcludedFromBackupKey: true})\n\n const prepared: PreparedOtaArtifact[] = []\n for (let index = 0; index < plan.length; index++) {\n const entry = plan[index]\n // Announce each file before cache verification or native download callbacks,\n // so the previous file's 100% cannot linger under the next file's label.\n onProgress?.({\n kind: entry.kind,\n index,\n totalCount: plan.length,\n artifactPercent: 0,\n bytesWritten: 0,\n contentLength: 0,\n })\n\n const cachedPath = `${directory}/${entry.sha256}`\n if (await RNFS.exists(cachedPath)) {\n const cachedHash = (await RNFS.hash(cachedPath, \"sha256\")).toLowerCase()\n if (cachedHash === entry.sha256) {\n prepared.push({...entry, filePath: cachedPath})\n continue\n }\n await safeUnlink(cachedPath)\n }\n\n const partPath = `${directory}/download-${index}.part`\n await safeUnlink(partPath)\n try {\n const reportProgress = (bytesWritten: number, contentLength: number) => {\n onProgress?.({\n kind: entry.kind,\n index,\n totalCount: plan.length,\n artifactPercent: contentLength > 0 ? Math.round((bytesWritten / contentLength) * 100) : 0,\n bytesWritten,\n contentLength,\n })\n }\n const downloadResult = nativeDownload\n ? await nativeDownload(entry, partPath, reportProgress)\n : await RNFS.downloadFile({\n fromUrl: entry.url,\n toFile: partPath,\n connectionTimeout: 30_000,\n readTimeout: 30_000,\n progressDivider: 5,\n progress: (res: RNFS.DownloadProgressCallbackResultT) => {\n reportProgress(res.bytesWritten, res.contentLength)\n },\n }).promise\n if (downloadResult.statusCode !== 200) {\n throw new OtaArtifactError(\n \"artifact_download_failed\",\n `Download of ${entry.kind} artifact failed with HTTP ${downloadResult.statusCode}`,\n )\n }\n\n const actualSha256 = (await RNFS.hash(partPath, \"sha256\")).toLowerCase()\n if (actualSha256 !== entry.sha256) {\n throw new OtaArtifactError(\n \"artifact_verify_failed\",\n `${entry.kind} artifact hash mismatch: expected ${entry.sha256}, got ${actualSha256}`,\n )\n }\n\n const finalPath = `${directory}/${entry.sha256}`\n await safeUnlink(finalPath)\n await RNFS.moveFile(partPath, finalPath)\n prepared.push({...entry, filePath: finalPath})\n } catch (error) {\n await safeUnlink(partPath)\n if (error instanceof OtaArtifactError) {\n throw error\n }\n throw new OtaArtifactError(\n \"artifact_download_failed\",\n `Download of ${entry.kind} artifact failed: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n return prepared\n}\n\n/**\n * Point the manifest's artifact URLs at the phone server, leaving every other field\n * semantically identical to what the update check saw. Entries we host get\n * `<baseUrl>/artifacts/<sha256>`; entries the update does not need keep their CDN URLs.\n * Only URL fields change: target versions, sizes, and manifest hashes remain untouched.\n */\nexport function rewriteManifestForLocalServer(\n manifestBody: string,\n artifacts: PreparedOtaArtifact[],\n baseUrl: string,\n): string {\n let manifest: VersionJson\n try {\n manifest = JSON.parse(manifestBody)\n } catch {\n throw new OtaArtifactError(\"manifest_invalid\", \"Manifest body is not valid JSON\")\n }\n const byUrl = new Map(artifacts.map((artifact) => [artifact.url, artifact]))\n const localUrl = (artifact: PreparedOtaArtifact) => `${baseUrl}/artifacts/${artifact.sha256}`\n\n for (const app of Object.values(manifest.apps ?? {})) {\n const record = app as unknown as Record<string, unknown>\n const artifact = typeof record.apkUrl === \"string\" ? byUrl.get(record.apkUrl) : undefined\n if (artifact) {\n record.apkUrl = localUrl(artifact)\n }\n }\n\n for (const patch of manifest.mtk_patches ?? []) {\n rewriteFirmwareEntry(patch as unknown as Record<string, unknown>, byUrl, localUrl)\n }\n if (manifest.mtk_full_ota) {\n rewriteFirmwareEntry(manifest.mtk_full_ota as unknown as Record<string, unknown>, byUrl, localUrl)\n }\n if (manifest.bes_firmware) {\n rewriteFirmwareEntry(manifest.bes_firmware as unknown as Record<string, unknown>, byUrl, localUrl)\n }\n\n return JSON.stringify(manifest)\n}\n\n/** Delete every stored artifact whose hash is not in `keepSha256s` (plus stray .part files). */\nexport async function cleanupArtifacts(keepSha256s: string[] = []): Promise<void> {\n const directory = otaArtifactsDirectory()\n if (!(await RNFS.exists(directory))) {\n return\n }\n const keep = new Set(keepSha256s.map((sha) => sha.toLowerCase()))\n const items = await RNFS.readDir(directory)\n for (const item of items) {\n if (!item.isFile()) continue\n if (keep.has(item.name.toLowerCase())) continue\n await safeUnlink(item.path)\n }\n}\n\nfunction rewriteFirmwareEntry(\n entry: Record<string, unknown>,\n byUrl: Map<string, PreparedOtaArtifact>,\n localUrl: (artifact: PreparedOtaArtifact) => string,\n): void {\n const url = firmwareUrl(entry)\n const artifact = url ? byUrl.get(url) : undefined\n if (!artifact) {\n return\n }\n entry.url = localUrl(artifact)\n // Overwrite the legacy key too when present, so no glasses build can prefer a stale\n // CDN URL over the local one.\n if (typeof entry.firmwareUrl === \"string\") {\n entry.firmwareUrl = localUrl(artifact)\n }\n}\n\nfunction firmwareUrl(entry: unknown): string | null {\n if (!entry || typeof entry !== \"object\") {\n return null\n }\n const record = entry as Record<string, unknown>\n if (typeof record.url === \"string\" && record.url.length > 0) {\n return record.url\n }\n if (typeof record.firmwareUrl === \"string\" && record.firmwareUrl.length > 0) {\n return record.firmwareUrl\n }\n return null\n}\n\nfunction requireSha256(entry: Record<string, unknown> | undefined, label: string): string {\n const sha256 = typeof entry?.sha256 === \"string\" ? entry.sha256.trim().toLowerCase() : \"\"\n if (!/^[a-f0-9]{64}$/.test(sha256)) {\n throw new OtaArtifactError(\"manifest_invalid\", `${label} artifact has no valid manifest sha256`)\n }\n return sha256\n}\n\nasync function safeUnlink(path: string): Promise<void> {\n try {\n if (await RNFS.exists(path)) {\n await RNFS.unlink(path)\n }\n } catch {\n // Best-effort: a leftover file only wastes space and is cleaned up next run.\n }\n}\n"]}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { type OtaProgress, type OtaStatus } from "@mentra/bluetooth-sdk";
|
|
21
21
|
import { type HotspotOtaPhase } from "./HotspotOtaTransport";
|
|
22
|
+
import type { OtaArtifactDownloadProgress } from "./OtaArtifactDownloader";
|
|
22
23
|
import type { OtaCheckCurrentGlassesResult } from "./OtaUpdateCheckService";
|
|
23
24
|
import { type DisplayState } from "./otaDisplayState";
|
|
24
25
|
/** Read model the host progress screen renders from. */
|
|
@@ -49,6 +50,7 @@ export interface OtaInstallSnapshot {
|
|
|
49
50
|
/** Pre-ota_start phone staging/join state for a hotspot attempt. */
|
|
50
51
|
hotspotPhase: HotspotOtaPhase;
|
|
51
52
|
hotspotArtifactPercent: number | null;
|
|
53
|
+
hotspotArtifact: OtaArtifactDownloadProgress | null;
|
|
52
54
|
/** Transport selected from the checked glasses capabilities and Wi-Fi state. */
|
|
53
55
|
transport: "wifi" | "hotspot";
|
|
54
56
|
}
|
|
@@ -59,6 +61,7 @@ declare class OtaInstallCoordinator {
|
|
|
59
61
|
private hotspotManifestUrl;
|
|
60
62
|
private hotspotPhase;
|
|
61
63
|
private hotspotArtifactPercent;
|
|
64
|
+
private hotspotArtifact;
|
|
62
65
|
private errorMsg;
|
|
63
66
|
private sawReconnectEdge;
|
|
64
67
|
private continueButtonDisabled;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaInstallCoordinator.d.ts","sourceRoot":"","sources":["../../src/services/OtaInstallCoordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAqB,EAAC,KAAK,WAAW,EAAE,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAIpF,OAAO,EAAsB,KAAK,eAAe,EAAC,MAAM,uBAAuB,CAAA;AAC/E,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAqB,KAAK,YAAY,EAAC,MAAM,mBAAmB,CAAA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B,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,wBAAwB;IAWhC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,iBAAiB;CAQ1B;AAED,oGAAoG;AACpG,eAAO,MAAM,qBAAqB,uBAA8B,CAAA"}
|
|
@@ -92,9 +92,11 @@ function latestPercentForStuck(otaStatus, otaProgress) {
|
|
|
92
92
|
* reply that cancels the fallback.
|
|
93
93
|
*/
|
|
94
94
|
function hasRecoveringOtaReply(otaStatus, otaProgress) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
// OtaService projects status into legacy progress too: idle becomes STARTED.
|
|
96
|
+
// Neither that projection nor progress retained across reboot proves activity.
|
|
97
|
+
if (otaStatus)
|
|
98
|
+
return otaStatus.status !== "idle";
|
|
99
|
+
return !!otaProgress;
|
|
98
100
|
}
|
|
99
101
|
class OtaInstallCoordinator {
|
|
100
102
|
attached = false;
|
|
@@ -103,6 +105,7 @@ class OtaInstallCoordinator {
|
|
|
103
105
|
hotspotManifestUrl = null;
|
|
104
106
|
hotspotPhase = "idle";
|
|
105
107
|
hotspotArtifactPercent = null;
|
|
108
|
+
hotspotArtifact = null;
|
|
106
109
|
// Genuinely session-local state (was component state/refs).
|
|
107
110
|
errorMsg = "";
|
|
108
111
|
sawReconnectEdge = false;
|
|
@@ -207,6 +210,7 @@ class OtaInstallCoordinator {
|
|
|
207
210
|
this.hotspotManifestUrl = null;
|
|
208
211
|
this.hotspotPhase = "idle";
|
|
209
212
|
this.hotspotArtifactPercent = null;
|
|
213
|
+
this.hotspotArtifact = null;
|
|
210
214
|
return this.selectedTransport;
|
|
211
215
|
}
|
|
212
216
|
/**
|
|
@@ -407,6 +411,7 @@ class OtaInstallCoordinator {
|
|
|
407
411
|
versionChangePhase: this.deriveVersionChangePhase(connected),
|
|
408
412
|
hotspotPhase: this.hotspotPhase,
|
|
409
413
|
hotspotArtifactPercent: this.hotspotArtifactPercent,
|
|
414
|
+
hotspotArtifact: this.hotspotArtifact ? { ...this.hotspotArtifact } : null,
|
|
410
415
|
transport: this.selectedTransport,
|
|
411
416
|
};
|
|
412
417
|
}
|
|
@@ -1313,7 +1318,9 @@ class OtaInstallCoordinator {
|
|
|
1313
1318
|
}
|
|
1314
1319
|
this.hotspotManifestUrl = await hotspotOtaTransport.prepare(this.preparedCheckResult, (progress) => {
|
|
1315
1320
|
this.hotspotPhase = progress.phase;
|
|
1316
|
-
this.
|
|
1321
|
+
this.hotspotArtifact = progress.artifact ? { ...progress.artifact } : null;
|
|
1322
|
+
this.hotspotArtifactPercent =
|
|
1323
|
+
progress.artifact && progress.artifact.contentLength > 0 ? progress.artifact.artifactPercent : null;
|
|
1317
1324
|
this.emitInternalChange();
|
|
1318
1325
|
});
|
|
1319
1326
|
}
|
|
@@ -1389,6 +1396,7 @@ class OtaInstallCoordinator {
|
|
|
1389
1396
|
this.hotspotManifestUrl = null;
|
|
1390
1397
|
this.hotspotPhase = "idle";
|
|
1391
1398
|
this.hotspotArtifactPercent = null;
|
|
1399
|
+
this.hotspotArtifact = null;
|
|
1392
1400
|
this.emitInternalChange();
|
|
1393
1401
|
}
|
|
1394
1402
|
/**
|