@mentra/engine 3.1.0-dev.9 → 3.1.0-dev.91
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/README.md +23 -5
- package/build/bluetooth-sdk/ota-transport.d.ts +2 -0
- package/build/bluetooth-sdk/ota-transport.d.ts.map +1 -0
- package/build/bluetooth-sdk/ota-transport.js +2 -0
- package/build/bluetooth-sdk/ota-transport.js.map +1 -0
- package/build/engine.d.ts +5 -2
- package/build/engine.d.ts.map +1 -1
- package/build/facades/ota.d.ts +11 -6
- package/build/facades/ota.d.ts.map +1 -1
- package/build/facades/ota.js +9 -5
- package/build/facades/ota.js.map +1 -1
- package/build/facades/pairing.d.ts +4 -0
- package/build/facades/pairing.d.ts.map +1 -1
- package/build/facades/pairing.js +81 -7
- package/build/facades/pairing.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/react/MentraLiveOtaFlow.d.ts +8 -2
- package/build/react/MentraLiveOtaFlow.d.ts.map +1 -1
- package/build/react/MentraLiveOtaFlow.js +256 -354
- package/build/react/MentraLiveOtaFlow.js.map +1 -1
- package/build/react/index.d.ts +1 -0
- package/build/react/index.d.ts.map +1 -1
- package/build/react/index.js +1 -0
- package/build/react/index.js.map +1 -1
- package/build/react/useMentraLiveOta.d.ts +84 -0
- package/build/react/useMentraLiveOta.d.ts.map +1 -0
- package/build/react/useMentraLiveOta.js +627 -0
- package/build/react/useMentraLiveOta.js.map +1 -0
- package/build/services/BlobStore.d.ts +2 -0
- package/build/services/BlobStore.d.ts.map +1 -1
- package/build/services/BlobStore.js +63 -10
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/GlassesStatusProjection.d.ts +15 -2
- package/build/services/GlassesStatusProjection.d.ts.map +1 -1
- package/build/services/GlassesStatusProjection.js +3 -3
- package/build/services/GlassesStatusProjection.js.map +1 -1
- package/build/services/HotspotOtaTransport.d.ts.map +1 -1
- package/build/services/HotspotOtaTransport.js +8 -7
- package/build/services/HotspotOtaTransport.js.map +1 -1
- package/build/services/OtaAutoChain.d.ts +9 -2
- package/build/services/OtaAutoChain.d.ts.map +1 -1
- package/build/services/OtaAutoChain.js +10 -2
- package/build/services/OtaAutoChain.js.map +1 -1
- package/build/services/OtaInstallCoordinator.d.ts +26 -3
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +35 -13
- package/build/services/OtaInstallCoordinator.js.map +1 -1
- package/build/services/OtaService.d.ts.map +1 -1
- package/build/services/OtaService.js +1 -1
- package/build/services/OtaService.js.map +1 -1
- package/build/services/OtaUpdateCheckService.d.ts +4 -1
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +21 -5
- package/build/services/OtaUpdateCheckService.js.map +1 -1
- package/build/services/asg/localNetworkTransport.d.ts.map +1 -1
- package/build/services/asg/localNetworkTransport.js +13 -12
- package/build/services/asg/localNetworkTransport.js.map +1 -1
- package/build/services/glassesClockSync.js +1 -1
- package/build/services/glassesClockSync.js.map +1 -1
- package/build/services/otaInstallPolicy.d.ts +4 -0
- package/build/services/otaInstallPolicy.d.ts.map +1 -1
- package/build/services/otaInstallPolicy.js +4 -0
- package/build/services/otaInstallPolicy.js.map +1 -1
- package/build/services/otaReleaseVersion.d.ts +10 -0
- package/build/services/otaReleaseVersion.d.ts.map +1 -0
- package/build/services/otaReleaseVersion.js +14 -0
- package/build/services/otaReleaseVersion.js.map +1 -0
- package/build/stores/appVisibility.d.ts +3 -0
- package/build/stores/appVisibility.d.ts.map +1 -0
- package/build/stores/appVisibility.js +3 -0
- package/build/stores/appVisibility.js.map +1 -0
- package/build/stores/apps.d.ts.map +1 -1
- package/build/stores/apps.js +7 -1
- package/build/stores/apps.js.map +1 -1
- package/build/stores/core.d.ts +3 -3
- package/build/stores/core.d.ts.map +1 -1
- package/build/stores/core.js.map +1 -1
- package/build/stores/glasses.d.ts +10 -4
- package/build/stores/glasses.d.ts.map +1 -1
- package/build/stores/glasses.js.map +1 -1
- package/package.json +13 -6
- package/src/bluetooth-sdk/ota-transport.ts +1 -0
- package/src/facades/ota.ts +19 -6
- package/src/facades/pairing.ts +88 -12
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/index.ts +2 -0
- package/src/react/MentraLiveOtaFlow.tsx +378 -480
- package/src/react/index.ts +14 -0
- package/src/react/useMentraLiveOta.ts +793 -0
- package/src/services/BlobStore.ts +57 -10
- package/src/services/GlassesStatusProjection.ts +7 -6
- package/src/services/HotspotOtaTransport.ts +8 -7
- package/src/services/OtaAutoChain.ts +26 -2
- package/src/services/OtaInstallCoordinator.ts +37 -13
- package/src/services/OtaService.ts +1 -2
- package/src/services/OtaUpdateCheckService.ts +26 -8
- package/src/services/asg/localNetworkTransport.ts +20 -19
- package/src/services/glassesClockSync.ts +1 -1
- package/src/services/otaInstallPolicy.ts +4 -0
- package/src/services/otaReleaseVersion.ts +22 -0
- package/src/stores/appVisibility.ts +3 -0
- package/src/stores/apps.ts +7 -1
- package/src/stores/core.ts +4 -4
- package/src/stores/glasses.ts +13 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlassesStatusProjection.js","sourceRoot":"","sources":["../../src/services/GlassesStatusProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"GlassesStatusProjection.js","sourceRoot":"","sources":["../../src/services/GlassesStatusProjection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,YAAwC,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AAEjD,IAAI,MAAM,GAAsB,EAAE,CAAA;AACl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AAE,EAAE;QAChD,kBAAkB,GAAG,IAAI,CAAA;QACzB,YAAY,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IAC9C,CAAC,CAAC,CACH,CAAA;IAED,+EAA+E;IAC/E,+DAA+D;IAC/D,MAAM,CAAC,IAAI,CACT,YAAY,CAAC,sBAAsB,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9C,gBAAgB,GAAG,IAAI,CAAA;QACvB,eAAe,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QAClD,sBAAsB,EAAE,CAAC,OAAO,CAAC,CAAA;QACjC,IAAI,OAAO,CAAC,UAAU,EAAE,KAAK,KAAK,cAAc,EAAE,CAAC;YACjD,eAAe,CAAC,QAAQ,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAA;QACxD,CAAC;IACH,CAAC,CAAC,CACH,CAAA;IAED,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IACnG,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,eAAe,EAAE,CAAA;IACjB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAA;IAClC,MAAM,GAAG,EAAE,CAAA;IACX,sBAAsB,GAAG,IAAI,CAAA;IAC7B,gBAAgB,GAAG,IAAI,CAAA;AACzB,CAAC","sourcesContent":["/**\n * Glasses status projection — engine-owned. Subscribes to the native bluetooth-sdk\n * status events and projects them into the engine device stores, so engine's own\n * services (which react to those stores) work for ANY host — not just the first-party\n * Mentra app, where this used to live in MantleManager.\n *\n * This is the INBOUND mirror of GlassesSettingsSync: that pushes the settings store\n * OUT to the device; this pulls device status IN to the stores. It's the feed that\n * the rest of the engine runtime depends on (MicStateCoordinator, the settings-sync\n * on-connect trigger, the facade read-models all read these stores).\n *\n * Started by `engine.start()`. Idempotent.\n */\nimport BluetoothSdk, {type PublicGlassesStatus} from \"@mentra/bluetooth-sdk\"\nimport {useCoreStore} from \"../stores/core\"\nimport {useGlassesStore} from \"../stores/glasses\"\n\nlet unsubs: Array<() => void> = []\nlet projectionRunId = 0\nlet glassesStatusForwarder: ((status: Partial<PublicGlassesStatus>) => void) | null = null\nlet hydrationPromise: Promise<void> | null = null\n\nexport function startGlassesStatusProjection(\n forwarder?: (status: Partial<PublicGlassesStatus>) => void,\n): Promise<void> {\n if (forwarder) glassesStatusForwarder = forwarder\n if (unsubs.length) return hydrationPromise ?? Promise.resolve()\n\n const runId = ++projectionRunId\n let bluetoothEventSeen = false\n let glassesEventSeen = false\n\n const bluetoothHydration = BluetoothSdk.getBluetoothStatus()\n .then((status) => {\n if (runId !== projectionRunId || bluetoothEventSeen) return\n useCoreStore.getState().setCoreInfo(status)\n })\n .catch((error) => {\n console.warn(\"GlassesStatusProjection: getBluetoothStatus failed\", error)\n })\n\n const glassesHydration = BluetoothSdk.getGlassesStatus()\n .then((status) => {\n if (runId !== projectionRunId || glassesEventSeen) return\n useGlassesStore.getState().setGlassesInfo(status)\n })\n .catch((error) => {\n console.warn(\"GlassesStatusProjection: getGlassesStatus failed\", error)\n })\n\n // Bluetooth-adapter status -> core store.\n unsubs.push(\n BluetoothSdk.subscribeBluetoothStatus((changed) => {\n bluetoothEventSeen = true\n useCoreStore.getState().setCoreInfo(changed)\n }),\n )\n\n // Glasses status -> glasses store (+ optional full-runtime forwarding to local\n // miniapps; clear any stale OTA-available flag on disconnect).\n unsubs.push(\n BluetoothSdk.subscribeGlassesStatus((changed) => {\n glassesEventSeen = true\n useGlassesStore.getState().setGlassesInfo(changed)\n glassesStatusForwarder?.(changed)\n if (changed.connection?.state === \"disconnected\") {\n useGlassesStore.getState().setOtaUpdateAvailable(null)\n }\n }),\n )\n\n hydrationPromise = Promise.allSettled([bluetoothHydration, glassesHydration]).then(() => undefined)\n return hydrationPromise\n}\n\nexport function stopGlassesStatusProjection(): void {\n projectionRunId++\n unsubs.forEach((unsub) => unsub())\n unsubs = []\n glassesStatusForwarder = null\n hydrationPromise = null\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HotspotOtaTransport.d.ts","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HotspotOtaTransport.d.ts","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAML,KAAK,2BAA2B,EAEjC,MAAM,yBAAyB,CAAA;AAIhC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,aAAa,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,CAAA;AAEzG,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,eAAe,CAAA;IACtB,QAAQ,CAAC,EAAE,2BAA2B,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAC3B,gCAAgC,GAChC,sBAAsB,GACtB,qBAAqB,GACrB,uBAAuB,CAAA;AAE3B,qBAAa,wBAAyB,SAAQ,KAAK;aAE/B,IAAI,EAAE,mBAAmB;gBAAzB,IAAI,EAAE,mBAAmB,EACzC,OAAO,EAAE,MAAM;CAKlB;AAED,yFAAyF;AACzF,cAAM,mBAAmB;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,qBAAqB,CAAQ;IACrC,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,eAAe,CAA6B;IAE9C,OAAO,CACX,WAAW,EAAE,4BAA4B,EACzC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,GAClD,OAAO,CAAC,MAAM,CAAC;IAuElB,gGAAgG;YAClF,2BAA2B;IAczC,OAAO,CAAC,mBAAmB,CAa1B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CA4BhC;AAED,eAAO,MAAM,mBAAmB,qBAA4B,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import BluetoothSdk, { isEnabledHotspotStatus
|
|
1
|
+
import BluetoothSdk, { isEnabledHotspotStatus } from "@mentra/bluetooth-sdk";
|
|
2
|
+
import { otaServer } from "@mentra/bluetooth-sdk/ota-transport";
|
|
2
3
|
// One coordinator selects the native Android or iOS staging implementation at runtime.
|
|
3
4
|
// eslint-disable-next-line react-native/split-platform-components
|
|
4
5
|
import { PermissionsAndroid, Platform } from "react-native";
|
|
@@ -49,7 +50,7 @@ class HotspotOtaTransport {
|
|
|
49
50
|
let localAddress = scopedAddress;
|
|
50
51
|
if (Platform.OS === "ios") {
|
|
51
52
|
try {
|
|
52
|
-
localAddress = await
|
|
53
|
+
localAddress = await otaServer.waitForWifiAddress(hotspot.localIp, 15_000);
|
|
53
54
|
}
|
|
54
55
|
catch (error) {
|
|
55
56
|
throw new HotspotOtaTransportError("hotspot_join_failed", error instanceof Error ? error.message : String(error));
|
|
@@ -58,10 +59,10 @@ class HotspotOtaTransport {
|
|
|
58
59
|
const artifactPaths = Object.fromEntries(this.prepared.map((artifact) => [artifact.sha256, artifact.filePath]));
|
|
59
60
|
// Start exactly one native listener to learn its selected port, then atomically replace
|
|
60
61
|
// the placeholder with the immutable rewritten manifest before ota_start is sent.
|
|
61
|
-
const server = await
|
|
62
|
+
const server = await otaServer.start("{}", artifactPaths, localAddress);
|
|
62
63
|
this.serverStarted = true;
|
|
63
64
|
const manifest = rewriteManifestForLocalServer(checkResult.manifestBody, this.prepared, server.baseUrl);
|
|
64
|
-
const published = await
|
|
65
|
+
const published = await otaServer.start(manifest, artifactPaths, server.host);
|
|
65
66
|
if (published.manifestUrl !== server.manifestUrl) {
|
|
66
67
|
throw new Error("Local OTA server endpoint changed while publishing the manifest");
|
|
67
68
|
}
|
|
@@ -98,12 +99,12 @@ class HotspotOtaTransport {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
downloadIosArtifact = async (entry, destination, onProgress) => {
|
|
101
|
-
const subscription =
|
|
102
|
+
const subscription = otaServer.onArtifactDownloadProgress((event) => {
|
|
102
103
|
if (event.destination === destination)
|
|
103
104
|
onProgress?.(event.bytesWritten, event.contentLength);
|
|
104
105
|
});
|
|
105
106
|
try {
|
|
106
|
-
return await
|
|
107
|
+
return await otaServer.downloadArtifact(entry.url, destination);
|
|
107
108
|
}
|
|
108
109
|
finally {
|
|
109
110
|
subscription.remove();
|
|
@@ -124,7 +125,7 @@ class HotspotOtaTransport {
|
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
if (this.serverStarted)
|
|
127
|
-
await
|
|
128
|
+
await otaServer.stop().catch(() => { });
|
|
128
129
|
if (this.localNetworkConnected)
|
|
129
130
|
await localNetworkTransport.disconnect().catch(() => { });
|
|
130
131
|
await cleanupArtifacts().catch(() => { });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HotspotOtaTransport.js","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAC,sBAAsB,EAAE,eAAe,EAAC,MAAM,gCAAgC,CAAA;AACpG,uFAAuF;AACvF,kEAAkE;AAClE,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAA;AAEzD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,6BAA6B,GAG9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAC,uBAAuB,EAAC,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,6BAA6B,CAAA;AAejE,MAAM,OAAO,wB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otspotStatus, MentraOtaServer} from \"@mentra/bluetooth-sdk/internal\"\n// One coordinator selects the native Android or iOS staging implementation at runtime.\n// eslint-disable-next-line react-native/split-platform-components\nimport {PermissionsAndroid, Platform} from \"react-native\"\nimport type {OtaCheckCurrentGlassesResult} from \"./OtaUpdateCheckService\"\nimport {\n cleanupArtifacts,\n OtaArtifactError,\n planArtifacts,\n prepareArtifacts,\n rewriteManifestForLocalServer,\n type OtaArtifactDownloadProgress,\n type PreparedOtaArtifact,\n} from \"./OtaArtifactDownloader\"\nimport {disableHotspotWithRetry} from \"./HotspotShutdown\"\nimport {localNetworkTransport} from \"./asg/localNetworkTransport\"\n\nexport type HotspotOtaPhase = \"idle\" | \"downloading\" | \"starting_hotspot\" | \"joining_hotspot\" | \"serving\"\n\nexport type HotspotOtaProgress = {\n phase: HotspotOtaPhase\n artifact?: OtaArtifactDownloadProgress\n}\n\nexport type HotspotOtaErrorCode =\n | \"hotspot_wifi_permission_denied\"\n | \"hotspot_start_failed\"\n | \"hotspot_join_failed\"\n | \"hotspot_server_failed\"\n\nexport class HotspotOtaTransportError extends Error {\n constructor(\n public readonly code: HotspotOtaErrorCode,\n message: string,\n ) {\n super(message)\n this.name = \"HotspotOtaTransportError\"\n }\n}\n\n/** Owns the single phone-side endpoint and network lease for one hotspot OTA attempt. */\nclass HotspotOtaTransport {\n private active = false\n private prepared: PreparedOtaArtifact[] = []\n private hotspotRequested = false\n private localNetworkConnected = false\n private serverStarted = false\n private teardownPromise: Promise<void> | null = null\n\n async prepare(\n checkResult: OtaCheckCurrentGlassesResult,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n if (this.teardownPromise) await this.teardownPromise\n if (this.active) {\n throw new Error(\"A hotspot OTA transport is already active\")\n }\n if (!checkResult.manifestBody) {\n throw new Error(\"The selected OTA check has no manifest body\")\n }\n\n let phase: HotspotOtaPhase = \"downloading\"\n try {\n await this.ensureAndroidWifiPermission()\n onProgress?.({phase: \"downloading\"})\n this.prepared = await prepareArtifacts(\n planArtifacts(checkResult),\n (artifact) => onProgress?.({phase: \"downloading\", artifact}),\n Platform.OS === \"ios\" ? this.downloadIosArtifact : undefined,\n )\n\n phase = \"starting_hotspot\"\n onProgress?.({phase: \"starting_hotspot\"})\n this.hotspotRequested = true\n const hotspot = await BluetoothSdk.setHotspotState(true)\n if (!isEnabledHotspotStatus(hotspot)) {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", \"Mentra Live did not return hotspot credentials\")\n }\n phase = \"joining_hotspot\"\n onProgress?.({phase: \"joining_hotspot\"})\n const scopedAddress = await localNetworkTransport.connect(hotspot.ssid, hotspot.password)\n this.localNetworkConnected = true\n let localAddress = scopedAddress\n if (Platform.OS === \"ios\") {\n try {\n localAddress = await MentraOtaServer.waitForWifiAddress(hotspot.localIp, 15_000)\n } catch (error) {\n throw new HotspotOtaTransportError(\n \"hotspot_join_failed\",\n error instanceof Error ? error.message : String(error),\n )\n }\n }\n const artifactPaths = Object.fromEntries(this.prepared.map((artifact) => [artifact.sha256, artifact.filePath]))\n // Start exactly one native listener to learn its selected port, then atomically replace\n // the placeholder with the immutable rewritten manifest before ota_start is sent.\n const server = await MentraOtaServer.startOtaServer(\"{}\", artifactPaths, localAddress)\n this.serverStarted = true\n const manifest = rewriteManifestForLocalServer(checkResult.manifestBody, this.prepared, server.baseUrl)\n const published = await MentraOtaServer.startOtaServer(manifest, artifactPaths, server.host)\n if (published.manifestUrl !== server.manifestUrl) {\n throw new Error(\"Local OTA server endpoint changed while publishing the manifest\")\n }\n this.active = true\n onProgress?.({phase: \"serving\"})\n return published.manifestUrl\n } catch (error) {\n const joined = this.localNetworkConnected\n await this.teardown()\n if (error instanceof OtaArtifactError || error instanceof HotspotOtaTransportError) {\n throw error\n }\n const message = error instanceof Error ? error.message : String(error)\n if (phase === \"starting_hotspot\") {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", message)\n }\n if (phase === \"joining_hotspot\" && !joined) {\n throw new HotspotOtaTransportError(\"hotspot_join_failed\", message)\n }\n throw new HotspotOtaTransportError(\"hotspot_server_failed\", message)\n }\n }\n\n /** Android 13+ requires the nearby-WiFi runtime grant before WifiNetworkSpecifier is usable. */\n private async ensureAndroidWifiPermission(): Promise<void> {\n if (Platform.OS !== \"android\") return\n\n const permission = PermissionsAndroid.PERMISSIONS.NEARBY_WIFI_DEVICES\n if (await PermissionsAndroid.check(permission)) return\n const result = await PermissionsAndroid.request(permission)\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n throw new HotspotOtaTransportError(\n \"hotspot_wifi_permission_denied\",\n \"Nearby devices permission is required to connect to the glasses hotspot\",\n )\n }\n }\n\n private downloadIosArtifact = async (\n entry: {url: string},\n destination: string,\n onProgress?: (bytesWritten: number, contentLength: number) => void,\n ): Promise<{statusCode: number}> => {\n const subscription = MentraOtaServer.addListener(\"artifactDownloadProgress\", (event) => {\n if (event.destination === destination) onProgress?.(event.bytesWritten, event.contentLength)\n })\n try {\n return await MentraOtaServer.downloadArtifact(entry.url, destination)\n } finally {\n subscription.remove()\n }\n }\n\n async teardown(): Promise<void> {\n if (this.teardownPromise) return this.teardownPromise\n this.teardownPromise = (async () => {\n if (this.hotspotRequested) {\n const hotspotStopped = await disableHotspotWithRetry(() => BluetoothSdk.setHotspotState(false), {\n // A completed APK step has just replaced ASG. Let the new command path\n // settle before asking it to tear down the SystemUI-owned access point.\n initialDelayMs: this.serverStarted ? 750 : 0,\n })\n if (!hotspotStopped) {\n console.warn(\"[OTA_PROGRESS] glasses hotspot shutdown was not confirmed after bounded retries\")\n }\n }\n if (this.serverStarted) await MentraOtaServer.stopOtaServer().catch(() => {})\n if (this.localNetworkConnected) await localNetworkTransport.disconnect().catch(() => {})\n await cleanupArtifacts().catch(() => {})\n this.prepared = []\n this.active = false\n this.serverStarted = false\n this.localNetworkConnected = false\n this.hotspotRequested = false\n })()\n try {\n await this.teardownPromise\n } finally {\n this.teardownPromise = null\n }\n }\n}\n\nexport const hotspotOtaTransport = new HotspotOtaT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AAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YACxC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;YAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;YACnB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAA;YAC1B,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAA;YAClC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAA;QAC/B,CAAC,CAAC,EAAE,CAAA;QACJ,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,eAAe,CAAA;QAC5B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;QAC7B,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAA","sourcesContent":["import BluetoothSdk, {isEnabledHotspotStatus} from \"@mentra/bluetooth-sdk\"\nimport {otaServer} from \"@mentra/bluetooth-sdk/ota-transport\"\n// One coordinator selects the native Android or iOS staging implementation at runtime.\n// eslint-disable-next-line react-native/split-platform-components\nimport {PermissionsAndroid, Platform} from \"react-native\"\nimport type {OtaCheckCurrentGlassesResult} from \"./OtaUpdateCheckService\"\nimport {\n cleanupArtifacts,\n OtaArtifactError,\n planArtifacts,\n prepareArtifacts,\n rewriteManifestForLocalServer,\n type OtaArtifactDownloadProgress,\n type PreparedOtaArtifact,\n} from \"./OtaArtifactDownloader\"\nimport {disableHotspotWithRetry} from \"./HotspotShutdown\"\nimport {localNetworkTransport} from \"./asg/localNetworkTransport\"\n\nexport type HotspotOtaPhase = \"idle\" | \"downloading\" | \"starting_hotspot\" | \"joining_hotspot\" | \"serving\"\n\nexport type HotspotOtaProgress = {\n phase: HotspotOtaPhase\n artifact?: OtaArtifactDownloadProgress\n}\n\nexport type HotspotOtaErrorCode =\n | \"hotspot_wifi_permission_denied\"\n | \"hotspot_start_failed\"\n | \"hotspot_join_failed\"\n | \"hotspot_server_failed\"\n\nexport class HotspotOtaTransportError extends Error {\n constructor(\n public readonly code: HotspotOtaErrorCode,\n message: string,\n ) {\n super(message)\n this.name = \"HotspotOtaTransportError\"\n }\n}\n\n/** Owns the single phone-side endpoint and network lease for one hotspot OTA attempt. */\nclass HotspotOtaTransport {\n private active = false\n private prepared: PreparedOtaArtifact[] = []\n private hotspotRequested = false\n private localNetworkConnected = false\n private serverStarted = false\n private teardownPromise: Promise<void> | null = null\n\n async prepare(\n checkResult: OtaCheckCurrentGlassesResult,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n if (this.teardownPromise) await this.teardownPromise\n if (this.active) {\n throw new Error(\"A hotspot OTA transport is already active\")\n }\n if (!checkResult.manifestBody) {\n throw new Error(\"The selected OTA check has no manifest body\")\n }\n\n let phase: HotspotOtaPhase = \"downloading\"\n try {\n await this.ensureAndroidWifiPermission()\n onProgress?.({phase: \"downloading\"})\n this.prepared = await prepareArtifacts(\n planArtifacts(checkResult),\n (artifact) => onProgress?.({phase: \"downloading\", artifact}),\n Platform.OS === \"ios\" ? this.downloadIosArtifact : undefined,\n )\n\n phase = \"starting_hotspot\"\n onProgress?.({phase: \"starting_hotspot\"})\n this.hotspotRequested = true\n const hotspot = await BluetoothSdk.setHotspotState(true)\n if (!isEnabledHotspotStatus(hotspot)) {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", \"Mentra Live did not return hotspot credentials\")\n }\n phase = \"joining_hotspot\"\n onProgress?.({phase: \"joining_hotspot\"})\n const scopedAddress = await localNetworkTransport.connect(hotspot.ssid, hotspot.password)\n this.localNetworkConnected = true\n let localAddress = scopedAddress\n if (Platform.OS === \"ios\") {\n try {\n localAddress = await otaServer.waitForWifiAddress(hotspot.localIp, 15_000)\n } catch (error) {\n throw new HotspotOtaTransportError(\n \"hotspot_join_failed\",\n error instanceof Error ? error.message : String(error),\n )\n }\n }\n const artifactPaths = Object.fromEntries(this.prepared.map((artifact) => [artifact.sha256, artifact.filePath]))\n // Start exactly one native listener to learn its selected port, then atomically replace\n // the placeholder with the immutable rewritten manifest before ota_start is sent.\n const server = await otaServer.start(\"{}\", artifactPaths, localAddress)\n this.serverStarted = true\n const manifest = rewriteManifestForLocalServer(checkResult.manifestBody, this.prepared, server.baseUrl)\n const published = await otaServer.start(manifest, artifactPaths, server.host)\n if (published.manifestUrl !== server.manifestUrl) {\n throw new Error(\"Local OTA server endpoint changed while publishing the manifest\")\n }\n this.active = true\n onProgress?.({phase: \"serving\"})\n return published.manifestUrl\n } catch (error) {\n const joined = this.localNetworkConnected\n await this.teardown()\n if (error instanceof OtaArtifactError || error instanceof HotspotOtaTransportError) {\n throw error\n }\n const message = error instanceof Error ? error.message : String(error)\n if (phase === \"starting_hotspot\") {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", message)\n }\n if (phase === \"joining_hotspot\" && !joined) {\n throw new HotspotOtaTransportError(\"hotspot_join_failed\", message)\n }\n throw new HotspotOtaTransportError(\"hotspot_server_failed\", message)\n }\n }\n\n /** Android 13+ requires the nearby-WiFi runtime grant before WifiNetworkSpecifier is usable. */\n private async ensureAndroidWifiPermission(): Promise<void> {\n if (Platform.OS !== \"android\") return\n\n const permission = PermissionsAndroid.PERMISSIONS.NEARBY_WIFI_DEVICES\n if (await PermissionsAndroid.check(permission)) return\n const result = await PermissionsAndroid.request(permission)\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n throw new HotspotOtaTransportError(\n \"hotspot_wifi_permission_denied\",\n \"Nearby devices permission is required to connect to the glasses hotspot\",\n )\n }\n }\n\n private downloadIosArtifact = async (\n entry: {url: string},\n destination: string,\n onProgress?: (bytesWritten: number, contentLength: number) => void,\n ): Promise<{statusCode: number}> => {\n const subscription = otaServer.onArtifactDownloadProgress((event) => {\n if (event.destination === destination) onProgress?.(event.bytesWritten, event.contentLength)\n })\n try {\n return await otaServer.downloadArtifact(entry.url, destination)\n } finally {\n subscription.remove()\n }\n }\n\n async teardown(): Promise<void> {\n if (this.teardownPromise) return this.teardownPromise\n this.teardownPromise = (async () => {\n if (this.hotspotRequested) {\n const hotspotStopped = await disableHotspotWithRetry(() => BluetoothSdk.setHotspotState(false), {\n // A completed APK step has just replaced ASG. Let the new command path\n // settle before asking it to tear down the SystemUI-owned access point.\n initialDelayMs: this.serverStarted ? 750 : 0,\n })\n if (!hotspotStopped) {\n console.warn(\"[OTA_PROGRESS] glasses hotspot shutdown was not confirmed after bounded retries\")\n }\n }\n if (this.serverStarted) await otaServer.stop().catch(() => {})\n if (this.localNetworkConnected) await localNetworkTransport.disconnect().catch(() => {})\n await cleanupArtifacts().catch(() => {})\n this.prepared = []\n this.active = false\n this.serverStarted = false\n this.localNetworkConnected = false\n this.hotspotRequested = false\n })()\n try {\n await this.teardownPromise\n } finally {\n this.teardownPromise = null\n }\n }\n}\n\nexport const hotspotOtaTransport = new HotspotOtaTransport()\n"]}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { OtaCheckCurrentGlassesResult } from "./OtaUpdateCheckService";
|
|
2
2
|
export declare const MAX_OTA_AUTO_CHAIN_PASSES = 8;
|
|
3
3
|
export declare const OTA_AUTO_CHAIN_RECONNECT_TIMEOUT_MS = 120000;
|
|
4
|
+
export type OtaAutoChainReleaseRange = {
|
|
5
|
+
fromVersion: string | null;
|
|
6
|
+
toVersion: string | null;
|
|
7
|
+
/** Exact coordinated release identity for the OTA pin, absent for legacy manifests. */
|
|
8
|
+
releaseVersion?: string | null;
|
|
9
|
+
};
|
|
4
10
|
export type OtaAutoChainAdvanceResult = {
|
|
5
11
|
advance: true;
|
|
6
12
|
passCount: number;
|
|
@@ -15,8 +21,9 @@ export type OtaAutoChainAdvanceResult = {
|
|
|
15
21
|
*/
|
|
16
22
|
export declare function otaAutoChainFingerprint(result: OtaCheckCurrentGlassesResult): string;
|
|
17
23
|
/** Start a chain after the user explicitly approves its first update pass. */
|
|
18
|
-
export declare function beginOtaAutoChain(initialFingerprint: string, approvedDowngrade: boolean): void;
|
|
24
|
+
export declare function beginOtaAutoChain(initialFingerprint: string, approvedDowngrade: boolean, releaseRange: OtaAutoChainReleaseRange): void;
|
|
19
25
|
export declare function isOtaAutoChainActive(): boolean;
|
|
26
|
+
export declare function otaAutoChainReleaseRange(): OtaAutoChainReleaseRange | null;
|
|
20
27
|
/** End the current chain. Safe to call when no chain is active. */
|
|
21
28
|
export declare function stopOtaAutoChain(): void;
|
|
22
29
|
/**
|
|
@@ -30,5 +37,5 @@ export declare function clearOtaAutoChainReconnectWait(): void;
|
|
|
30
37
|
* Admit the next pass of an active chain. Repeated offers, unexpectedly
|
|
31
38
|
* destructive downgrades, and runaway chains fail closed and end automation.
|
|
32
39
|
*/
|
|
33
|
-
export declare function tryAdvanceOtaAutoChain(fingerprint: string, isDowngrade: boolean): OtaAutoChainAdvanceResult;
|
|
40
|
+
export declare function tryAdvanceOtaAutoChain(fingerprint: string, isDowngrade: boolean, targetVersion: string | null, releaseVersion?: string | null): OtaAutoChainAdvanceResult;
|
|
34
41
|
//# sourceMappingURL=OtaAutoChain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaAutoChain.d.ts","sourceRoot":"","sources":["../../src/services/OtaAutoChain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAA;AAEzE,eAAO,MAAM,yBAAyB,IAAI,CAAA;AAC1C,eAAO,MAAM,mCAAmC,SAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"OtaAutoChain.d.ts","sourceRoot":"","sources":["../../src/services/OtaAutoChain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAA;AAEzE,eAAO,MAAM,yBAAyB,IAAI,CAAA;AAC1C,eAAO,MAAM,mCAAmC,SAAU,CAAA;AAU1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,uFAAuF;IACvF,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,CAAA;AAED,MAAM,MAAM,yBAAyB,GACjC;IAAC,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,GAClC;IAAC,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,wBAAwB,CAAA;CAAC,CAAA;AAIhG;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,4BAA4B,GAAG,MAAM,CAkBpF;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAC/B,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,EAAE,OAAO,EAC1B,YAAY,EAAE,wBAAwB,GACrC,IAAI,CAQN;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,wBAAgB,wBAAwB,IAAI,wBAAwB,GAAG,IAAI,CAE1E;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,SAAoB,GAAG,MAAM,GAAG,IAAI,CAKzF;AAED,6EAA6E;AAC7E,wBAAgB,8BAA8B,IAAI,IAAI,CAErD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,OAAO,EACpB,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,cAAc,GAAE,MAAM,GAAG,IAAW,GACnC,yBAAyB,CAyB3B"}
|
|
@@ -26,10 +26,11 @@ export function otaAutoChainFingerprint(result) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
/** Start a chain after the user explicitly approves its first update pass. */
|
|
29
|
-
export function beginOtaAutoChain(initialFingerprint, approvedDowngrade) {
|
|
29
|
+
export function beginOtaAutoChain(initialFingerprint, approvedDowngrade, releaseRange) {
|
|
30
30
|
session = {
|
|
31
31
|
approvedDowngrade,
|
|
32
32
|
passCount: 1,
|
|
33
|
+
releaseRange: { ...releaseRange },
|
|
33
34
|
reconnectDeadline: null,
|
|
34
35
|
seenFingerprints: new Set([initialFingerprint]),
|
|
35
36
|
};
|
|
@@ -37,6 +38,9 @@ export function beginOtaAutoChain(initialFingerprint, approvedDowngrade) {
|
|
|
37
38
|
export function isOtaAutoChainActive() {
|
|
38
39
|
return session !== null;
|
|
39
40
|
}
|
|
41
|
+
export function otaAutoChainReleaseRange() {
|
|
42
|
+
return session ? { ...session.releaseRange } : null;
|
|
43
|
+
}
|
|
40
44
|
/** End the current chain. Safe to call when no chain is active. */
|
|
41
45
|
export function stopOtaAutoChain() {
|
|
42
46
|
session = null;
|
|
@@ -60,7 +64,7 @@ export function clearOtaAutoChainReconnectWait() {
|
|
|
60
64
|
* Admit the next pass of an active chain. Repeated offers, unexpectedly
|
|
61
65
|
* destructive downgrades, and runaway chains fail closed and end automation.
|
|
62
66
|
*/
|
|
63
|
-
export function tryAdvanceOtaAutoChain(fingerprint, isDowngrade) {
|
|
67
|
+
export function tryAdvanceOtaAutoChain(fingerprint, isDowngrade, targetVersion, releaseVersion = null) {
|
|
64
68
|
if (!session) {
|
|
65
69
|
return { advance: false, reason: "inactive" };
|
|
66
70
|
}
|
|
@@ -78,6 +82,10 @@ export function tryAdvanceOtaAutoChain(fingerprint, isDowngrade) {
|
|
|
78
82
|
}
|
|
79
83
|
session.seenFingerprints.add(fingerprint);
|
|
80
84
|
session.passCount += 1;
|
|
85
|
+
if (targetVersion)
|
|
86
|
+
session.releaseRange.toVersion = targetVersion;
|
|
87
|
+
if (releaseVersion)
|
|
88
|
+
session.releaseRange.releaseVersion = releaseVersion;
|
|
81
89
|
return { advance: true, passCount: session.passCount };
|
|
82
90
|
}
|
|
83
91
|
//# sourceMappingURL=OtaAutoChain.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaAutoChain.js","sourceRoot":"","sources":["../../src/services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AgB,EAAE,CAAA;QAClB,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,wBAAwB,EAAC,CAAA;IAC3D,CAAC;IAED,IAAI,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9C,gBAAgB,EAAE,CAAA;QAClB,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,IAAI,yBAAyB,EAAE,CAAC;QACnD,gBAAgB,EAAE,CAAA;QAClB,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAC,CAAA;IAC/C,CAAC;IAED,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACzC,OAAO,CAAC,SAAS,IAAI,CAAC,CAAA;IACtB,IAAI,aAAa;QAAE,OAAO,CAAC,YAAY,CAAC,SAAS,GAAG,aAAa,CAAA;IACjE,IAAI,cAAc;QAAE,OAAO,CAAC,YAAY,CAAC,cAAc,GAAG,cAAc,CAAA;IACxE,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAC,CAAA;AACtD,CAAC","sourcesContent":["import type {OtaCheckCurrentGlassesResult} from \"./OtaUpdateCheckService\"\n\nexport const MAX_OTA_AUTO_CHAIN_PASSES = 8\nexport const OTA_AUTO_CHAIN_RECONNECT_TIMEOUT_MS = 120_000\n\ntype OtaAutoChainSession = {\n approvedDowngrade: boolean\n passCount: number\n releaseRange: OtaAutoChainReleaseRange\n reconnectDeadline: number | null\n seenFingerprints: Set<string>\n}\n\nexport type OtaAutoChainReleaseRange = {\n fromVersion: string | null\n toVersion: string | null\n /** Exact coordinated release identity for the OTA pin, absent for legacy manifests. */\n releaseVersion?: string | null\n}\n\nexport type OtaAutoChainAdvanceResult =\n | {advance: true; passCount: number}\n | {advance: false; reason: \"inactive\" | \"duplicate\" | \"max_passes\" | \"downgrade_not_approved\"}\n\nlet session: OtaAutoChainSession | null = null\n\n/**\n * Identify the exact update offer that produced one OTA pass. Including the\n * observed versions and manifest body lets a changed manifest advance while a\n * stale post-install version_info response is rejected as a duplicate.\n */\nexport function otaAutoChainFingerprint(result: OtaCheckCurrentGlassesResult): string {\n return JSON.stringify({\n manifestUrl: result.manifestUrl ?? \"\",\n manifestBody: result.manifestBody ?? \"\",\n buildNumber: result.buildNumber ?? \"\",\n mtkFirmwareVersion: result.mtkFirmwareVersion ?? \"\",\n besFirmwareVersion: result.besFirmwareVersion ?? \"\",\n updates: result.updates,\n targetBuildNumber: result.updateInfo?.versionCode ?? result.latestVersionInfo?.versionCode ?? 0,\n targetBesVersion: result.besVersion ?? \"\",\n mtkPatch: result.mtkPatch\n ? {\n startFirmware: result.mtkPatch.start_firmware,\n endFirmware: result.mtkPatch.end_firmware,\n url: result.mtkPatch.url,\n }\n : null,\n })\n}\n\n/** Start a chain after the user explicitly approves its first update pass. */\nexport function beginOtaAutoChain(\n initialFingerprint: string,\n approvedDowngrade: boolean,\n releaseRange: OtaAutoChainReleaseRange,\n): void {\n session = {\n approvedDowngrade,\n passCount: 1,\n releaseRange: {...releaseRange},\n reconnectDeadline: null,\n seenFingerprints: new Set([initialFingerprint]),\n }\n}\n\nexport function isOtaAutoChainActive(): boolean {\n return session !== null\n}\n\nexport function otaAutoChainReleaseRange(): OtaAutoChainReleaseRange | null {\n return session ? {...session.releaseRange} : null\n}\n\n/** End the current chain. Safe to call when no chain is active. */\nexport function stopOtaAutoChain(): void {\n session = null\n}\n\n/**\n * Start (or continue) the bounded wait for glasses that are rebooting between\n * passes. Re-renders must not extend the original deadline indefinitely.\n */\nexport function otaAutoChainReconnectWaitRemaining(now = performance.now()): number | null {\n if (!session) return null\n\n session.reconnectDeadline ??= now + OTA_AUTO_CHAIN_RECONNECT_TIMEOUT_MS\n return Math.max(0, session.reconnectDeadline - now)\n}\n\n/** A successful reconnect allows a future pass to establish a fresh wait. */\nexport function clearOtaAutoChainReconnectWait(): void {\n if (session) session.reconnectDeadline = null\n}\n\n/**\n * Admit the next pass of an active chain. Repeated offers, unexpectedly\n * destructive downgrades, and runaway chains fail closed and end automation.\n */\nexport function tryAdvanceOtaAutoChain(\n fingerprint: string,\n isDowngrade: boolean,\n targetVersion: string | null,\n releaseVersion: string | null = null,\n): OtaAutoChainAdvanceResult {\n if (!session) {\n return {advance: false, reason: \"inactive\"}\n }\n\n if (isDowngrade && !session.approvedDowngrade) {\n stopOtaAutoChain()\n return {advance: false, reason: \"downgrade_not_approved\"}\n }\n\n if (session.seenFingerprints.has(fingerprint)) {\n stopOtaAutoChain()\n return {advance: false, reason: \"duplicate\"}\n }\n\n if (session.passCount >= MAX_OTA_AUTO_CHAIN_PASSES) {\n stopOtaAutoChain()\n return {advance: false, reason: \"max_passes\"}\n }\n\n session.seenFingerprints.add(fingerprint)\n session.passCount += 1\n if (targetVersion) session.releaseRange.toVersion = targetVersion\n if (releaseVersion) session.releaseRange.releaseVersion = releaseVersion\n return {advance: true, passCount: session.passCount}\n}\n"]}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* OtaInstallCoordinator — engine-owned OTA install state machine (WP 8B).
|
|
3
|
+
*
|
|
4
|
+
* Owns every timer/retry/sequencing rule that used to live in the host screen
|
|
5
|
+
* `mobile/src/app/ota/progress.tsx`: the global session timeout, serialized
|
|
6
|
+
* ota_start retries, the stuck-at-zero watchdog, the progress-stall watchdog keyed
|
|
7
|
+
* on a staleness signature, connect-edge arbitration (initial mount vs
|
|
8
|
+
* reconnect vs post-APK reboot), the ota_query_status reply fallback, the ping
|
|
9
|
+
* keepalive, the ota_start_ack / mtk_update_complete listeners, and terminal
|
|
10
|
+
* cleanup. The host progress screen is a pure renderer over
|
|
11
|
+
* `snapshot()`/`onSnapshot()` plus the `attach()/detach()/retry()/finish()`
|
|
12
|
+
* commands (exposed as `engine.ota.installSession`).
|
|
13
|
+
*
|
|
14
|
+
* The reaction pass mirrors the old component's effect ordering: a
|
|
15
|
+
* pass diffs the store-derived inputs (connected / otaStatus / otaProgress /
|
|
16
|
+
* displayState / stall signature) exactly like the old effect dep arrays, and
|
|
17
|
+
* state written mid-pass queues a follow-up pass — the same way a setState
|
|
18
|
+
* during React effects scheduled a re-render after the current effect batch.
|
|
19
|
+
*/
|
|
20
|
+
import { type OtaProgress, type OtaStatus } from "@mentra/bluetooth-sdk";
|
|
2
21
|
import { type HotspotOtaPhase } from "./HotspotOtaTransport";
|
|
3
22
|
import type { OtaCheckCurrentGlassesResult } from "./OtaUpdateCheckService";
|
|
4
23
|
import { type DisplayState } from "./otaDisplayState";
|
|
@@ -30,6 +49,8 @@ export interface OtaInstallSnapshot {
|
|
|
30
49
|
/** Pre-ota_start phone staging/join state for a hotspot attempt. */
|
|
31
50
|
hotspotPhase: HotspotOtaPhase;
|
|
32
51
|
hotspotArtifactPercent: number | null;
|
|
52
|
+
/** Transport selected from the checked glasses capabilities and Wi-Fi state. */
|
|
53
|
+
transport: "wifi" | "hotspot";
|
|
33
54
|
}
|
|
34
55
|
declare class OtaInstallCoordinator {
|
|
35
56
|
private attached;
|
|
@@ -65,6 +86,7 @@ declare class OtaInstallCoordinator {
|
|
|
65
86
|
private pingInterval;
|
|
66
87
|
private queryReplyTimeout;
|
|
67
88
|
private continueLockoutTimer;
|
|
89
|
+
private restartRecoveryTimeout;
|
|
68
90
|
private legacyApkSettleTimer;
|
|
69
91
|
private mtkStallDetectTimer;
|
|
70
92
|
private mtkSimTickTimer;
|
|
@@ -106,14 +128,14 @@ declare class OtaInstallCoordinator {
|
|
|
106
128
|
* stays in the screen): clear the selected update, and after an APK step
|
|
107
129
|
* clear the stale build number so the next check re-reads version_info.
|
|
108
130
|
*/
|
|
109
|
-
finish(): void
|
|
131
|
+
finish(): Promise<void>;
|
|
110
132
|
/**
|
|
111
133
|
* Abandon an interrupted session (the super-mode skip): terminal cleanup
|
|
112
134
|
* plus dropping the session's status/progress read-state, so
|
|
113
135
|
* deriveDisplayState doesn't resurrect the stale install when the host
|
|
114
136
|
* navigates away and back through /ota routes.
|
|
115
137
|
*/
|
|
116
|
-
discard(): void
|
|
138
|
+
discard(): Promise<void>;
|
|
117
139
|
snapshot(): OtaInstallSnapshot;
|
|
118
140
|
/**
|
|
119
141
|
* True while the recovery worker owns the downgrade transaction (after the apk install
|
|
@@ -257,6 +279,7 @@ declare class OtaInstallCoordinator {
|
|
|
257
279
|
private clearPingInterval;
|
|
258
280
|
private clearQueryReplyTimeout;
|
|
259
281
|
private clearContinueLockoutTimer;
|
|
282
|
+
private clearRestartRecoveryTimeout;
|
|
260
283
|
private clearLegacyApkSettleTimer;
|
|
261
284
|
private clearMtkSimulationTimers;
|
|
262
285
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaInstallCoordinator.d.ts","sourceRoot":"","sources":["../../src/services/OtaInstallCoordinator.ts"],"names":[],"mappings":"
|
|
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;AAwHvE,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,YAAY,CAAA;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;IAC3B,WA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;OAIG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,uBAAuB;IAuB/B,OAAO,CAAC,oBAAoB;IAuB5B,yEAAyE;IACzE,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,yBAAyB;YAyCnB,eAAe;YAsFf,wBAAwB;IAStC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,qBAAqB;IAmC7B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,iBAAiB;IAOzB,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"}
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
* state written mid-pass queues a follow-up pass — the same way a setState
|
|
18
18
|
* during React effects scheduled a re-render after the current effect batch.
|
|
19
19
|
*/
|
|
20
|
-
import BluetoothSdk from "@mentra/bluetooth-sdk
|
|
20
|
+
import BluetoothSdk from "@mentra/bluetooth-sdk";
|
|
21
21
|
import GlobalEventEmitter from "../utils/GlobalEventEmitter";
|
|
22
22
|
import { isGlassesConnected, useGlassesStore } from "../stores/glasses";
|
|
23
23
|
import { resolveOtaManifestUrl } from "./otaManifestUrl";
|
|
24
24
|
import { hotspotOtaTransport } from "./HotspotOtaTransport";
|
|
25
25
|
import { deriveDisplayState } from "./otaDisplayState";
|
|
26
|
-
import { BES_CONTINUE_LOCKOUT_MS, DOWNLOAD_STUCK_TIMEOUT_MS, GLOBAL_OTA_TIMEOUT_MS, LEGACY_APK_COMPLETION_SETTLE_MS, LEGACY_BES_CONTINUE_LOCKOUT_MS, LEGACY_DOWNLOAD_STUCK_TIMEOUT_MS, LEGACY_GLOBAL_OTA_TIMEOUT_MS, LEGACY_MTK_INSTALL_TIMEOUT_MS, LEGACY_MTK_SIM_CAP_PERCENT, LEGACY_MTK_SIM_FLOOR_PERCENT, LEGACY_MTK_SIM_TICK_MS, LEGACY_MTK_STALL_DETECT_MS, LEGACY_MTK_STALL_ZONE_MAX_PERCENT, LEGACY_MTK_STALL_ZONE_MIN_PERCENT, LEGACY_PING_INTERVAL_MS, LEGACY_PROGRESS_TIMEOUT_MS, LEGACY_RETRY_INTERVAL_MS, MAX_RETRIES, MTK_INSTALL_TIMEOUT_MS, OtaProgressMessages, PING_INTERVAL_MS, PROGRESS_TIMEOUT_MS, QUERY_REPLY_TIMEOUT_MS, RETRY_INTERVAL_MS, isLegacyShapedOtaSession, isLegacyShapedOtaStatus, selectOtaProtocolProfile, } from "./otaInstallPolicy";
|
|
26
|
+
import { BES_CONTINUE_LOCKOUT_MS, BES_RESTART_TIMEOUT_MS, DOWNLOAD_STUCK_TIMEOUT_MS, GLOBAL_OTA_TIMEOUT_MS, LEGACY_APK_COMPLETION_SETTLE_MS, LEGACY_BES_CONTINUE_LOCKOUT_MS, LEGACY_BES_RESTART_TIMEOUT_MS, LEGACY_DOWNLOAD_STUCK_TIMEOUT_MS, LEGACY_GLOBAL_OTA_TIMEOUT_MS, LEGACY_MTK_INSTALL_TIMEOUT_MS, LEGACY_MTK_SIM_CAP_PERCENT, LEGACY_MTK_SIM_FLOOR_PERCENT, LEGACY_MTK_SIM_TICK_MS, LEGACY_MTK_STALL_DETECT_MS, LEGACY_MTK_STALL_ZONE_MAX_PERCENT, LEGACY_MTK_STALL_ZONE_MIN_PERCENT, LEGACY_PING_INTERVAL_MS, LEGACY_PROGRESS_TIMEOUT_MS, LEGACY_RETRY_INTERVAL_MS, MAX_RETRIES, MTK_INSTALL_TIMEOUT_MS, OtaProgressMessages, PING_INTERVAL_MS, PROGRESS_TIMEOUT_MS, QUERY_REPLY_TIMEOUT_MS, RETRY_INTERVAL_MS, isLegacyShapedOtaSession, isLegacyShapedOtaStatus, selectOtaProtocolProfile, } from "./otaInstallPolicy";
|
|
27
27
|
function isTerminalForWatchdog(d) {
|
|
28
28
|
return d === "complete" || d === "failed" || d === "restarting";
|
|
29
29
|
}
|
|
@@ -156,6 +156,7 @@ class OtaInstallCoordinator {
|
|
|
156
156
|
pingInterval = null;
|
|
157
157
|
queryReplyTimeout = null;
|
|
158
158
|
continueLockoutTimer = null;
|
|
159
|
+
restartRecoveryTimeout = null;
|
|
159
160
|
legacyApkSettleTimer = null;
|
|
160
161
|
mtkStallDetectTimer = null;
|
|
161
162
|
mtkSimTickTimer = null;
|
|
@@ -306,7 +307,7 @@ class OtaInstallCoordinator {
|
|
|
306
307
|
void this.sendOtaStartWithWatchdogs();
|
|
307
308
|
}
|
|
308
309
|
else {
|
|
309
|
-
void BluetoothSdk.
|
|
310
|
+
void BluetoothSdk.queryOtaStatus().catch(() => { });
|
|
310
311
|
this.armQueryReplyFallback("retry");
|
|
311
312
|
}
|
|
312
313
|
}
|
|
@@ -349,16 +350,17 @@ class OtaInstallCoordinator {
|
|
|
349
350
|
* stays in the screen): clear the selected update, and after an APK step
|
|
350
351
|
* clear the stale build number so the next check re-reads version_info.
|
|
351
352
|
*/
|
|
352
|
-
finish() {
|
|
353
|
+
async finish() {
|
|
353
354
|
if (this.otaStartOwnership?.outcome !== "pending") {
|
|
354
355
|
this.otaStartOwnership = null;
|
|
355
356
|
}
|
|
356
357
|
useGlassesStore.getState().setOtaUpdateAvailable(null);
|
|
357
358
|
if (this.apkStepSeen) {
|
|
358
|
-
BluetoothSdk.updateGlasses({ buildNumber: "" });
|
|
359
359
|
useGlassesStore.getState().setGlassesInfo({ buildNumber: "" });
|
|
360
360
|
}
|
|
361
|
-
|
|
361
|
+
// The post-install check needs internet again. Do not let callers leave the
|
|
362
|
+
// terminal screen while Android still owns the no-internet hotspot route.
|
|
363
|
+
await this.teardownHotspotTransport();
|
|
362
364
|
}
|
|
363
365
|
/**
|
|
364
366
|
* Abandon an interrupted session (the super-mode skip): terminal cleanup
|
|
@@ -366,8 +368,8 @@ class OtaInstallCoordinator {
|
|
|
366
368
|
* deriveDisplayState doesn't resurrect the stale install when the host
|
|
367
369
|
* navigates away and back through /ota routes.
|
|
368
370
|
*/
|
|
369
|
-
discard() {
|
|
370
|
-
this.finish();
|
|
371
|
+
async discard() {
|
|
372
|
+
await this.finish();
|
|
371
373
|
const store = useGlassesStore.getState();
|
|
372
374
|
store.setOtaStatus(null);
|
|
373
375
|
store.setOtaProgress(null);
|
|
@@ -403,6 +405,7 @@ class OtaInstallCoordinator {
|
|
|
403
405
|
versionChangePhase: this.deriveVersionChangePhase(connected),
|
|
404
406
|
hotspotPhase: this.hotspotPhase,
|
|
405
407
|
hotspotArtifactPercent: this.hotspotArtifactPercent,
|
|
408
|
+
transport: this.selectedTransport,
|
|
406
409
|
};
|
|
407
410
|
}
|
|
408
411
|
/**
|
|
@@ -848,12 +851,24 @@ class OtaInstallCoordinator {
|
|
|
848
851
|
// (15s unified, 35s for legacy-shaped sessions — WP 8C-f).
|
|
849
852
|
if (displayStateChanged && displayState === "restarting") {
|
|
850
853
|
this.clearContinueLockoutTimer();
|
|
854
|
+
this.clearRestartRecoveryTimeout();
|
|
851
855
|
const lockoutMs = legacySession ? LEGACY_BES_CONTINUE_LOCKOUT_MS : BES_CONTINUE_LOCKOUT_MS;
|
|
856
|
+
const restartTimeoutMs = legacySession ? LEGACY_BES_RESTART_TIMEOUT_MS : BES_RESTART_TIMEOUT_MS;
|
|
852
857
|
this.setContinueButtonDisabled(true);
|
|
853
858
|
this.continueLockoutTimer = setTimeout(() => {
|
|
854
859
|
this.continueLockoutTimer = null;
|
|
855
860
|
this.setContinueButtonDisabled(false);
|
|
856
861
|
}, lockoutMs);
|
|
862
|
+
this.restartRecoveryTimeout = setTimeout(() => {
|
|
863
|
+
this.restartRecoveryTimeout = null;
|
|
864
|
+
if (this.computeDisplayStateNow() !== "restarting")
|
|
865
|
+
return;
|
|
866
|
+
console.log(`[OTA_PROGRESS] watchdog: glasses did not finish restarting in ${restartTimeoutMs}ms`);
|
|
867
|
+
this.setErrorMsg(OtaProgressMessages.restartTimeout);
|
|
868
|
+
}, restartTimeoutMs);
|
|
869
|
+
}
|
|
870
|
+
else if (displayStateChanged) {
|
|
871
|
+
this.clearRestartRecoveryTimeout();
|
|
857
872
|
}
|
|
858
873
|
// Legacy MTK install stall simulation (WP 8C-e): display-only. The simulation
|
|
859
874
|
// timers only ever touch the projected snapshot percent — they never feed back
|
|
@@ -908,7 +923,7 @@ class OtaInstallCoordinator {
|
|
|
908
923
|
if (this.otaStartOwnership?.outcome === "pending") {
|
|
909
924
|
void this.sendOtaStartWithWatchdogs();
|
|
910
925
|
}
|
|
911
|
-
void BluetoothSdk.
|
|
926
|
+
void BluetoothSdk.queryOtaStatus().catch(() => { });
|
|
912
927
|
this.armQueryReplyFallback("reconnect");
|
|
913
928
|
return true;
|
|
914
929
|
}
|
|
@@ -946,7 +961,7 @@ class OtaInstallCoordinator {
|
|
|
946
961
|
if (noSessionYet) {
|
|
947
962
|
if (!isIdleStatus && this.otaStartOwnership?.outcome === "acknowledged") {
|
|
948
963
|
console.log("[OTA_PROGRESS] initial mount, acknowledged session has no cached status — reconciling");
|
|
949
|
-
void BluetoothSdk.
|
|
964
|
+
void BluetoothSdk.queryOtaStatus().catch(() => { });
|
|
950
965
|
this.armQueryReplyFallback("initial-mount");
|
|
951
966
|
return;
|
|
952
967
|
}
|
|
@@ -961,7 +976,7 @@ class OtaInstallCoordinator {
|
|
|
961
976
|
}
|
|
962
977
|
else {
|
|
963
978
|
console.log("[OTA_PROGRESS] initial mount, session exists, sending ota_query_status");
|
|
964
|
-
void BluetoothSdk.
|
|
979
|
+
void BluetoothSdk.queryOtaStatus().catch(() => { });
|
|
965
980
|
this.armQueryReplyFallback("initial-mount");
|
|
966
981
|
}
|
|
967
982
|
}
|
|
@@ -988,7 +1003,7 @@ class OtaInstallCoordinator {
|
|
|
988
1003
|
this.clearProgressTimeout();
|
|
989
1004
|
this.onFirstActivity();
|
|
990
1005
|
this.onFirstNonZeroProgress();
|
|
991
|
-
void BluetoothSdk.
|
|
1006
|
+
void BluetoothSdk.queryOtaStatus().catch(() => { });
|
|
992
1007
|
useGlassesStore.getState().setMtkUpdatedThisSession(true);
|
|
993
1008
|
};
|
|
994
1009
|
// --- legacy (< 37) compatibility, ported from progress-legacy.tsx (WP 8C) ---
|
|
@@ -1148,7 +1163,7 @@ class OtaInstallCoordinator {
|
|
|
1148
1163
|
const s = useGlassesStore.getState().otaStatus;
|
|
1149
1164
|
if (s?.stepType === "apk" && s.phase === "install" && s.status === "in_progress") {
|
|
1150
1165
|
this.apkInstallPollInFlight = true;
|
|
1151
|
-
void BluetoothSdk.
|
|
1166
|
+
void BluetoothSdk.queryOtaStatus()
|
|
1152
1167
|
.catch(() => { })
|
|
1153
1168
|
.finally(() => {
|
|
1154
1169
|
this.apkInstallPollInFlight = false;
|
|
@@ -1452,6 +1467,12 @@ class OtaInstallCoordinator {
|
|
|
1452
1467
|
this.continueLockoutTimer = null;
|
|
1453
1468
|
}
|
|
1454
1469
|
}
|
|
1470
|
+
clearRestartRecoveryTimeout() {
|
|
1471
|
+
if (this.restartRecoveryTimeout) {
|
|
1472
|
+
clearTimeout(this.restartRecoveryTimeout);
|
|
1473
|
+
this.restartRecoveryTimeout = null;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1455
1476
|
clearLegacyApkSettleTimer() {
|
|
1456
1477
|
if (this.legacyApkSettleTimer) {
|
|
1457
1478
|
clearTimeout(this.legacyApkSettleTimer);
|
|
@@ -1487,6 +1508,7 @@ class OtaInstallCoordinator {
|
|
|
1487
1508
|
this.clearPingInterval();
|
|
1488
1509
|
this.clearLegacyApkSettleTimer();
|
|
1489
1510
|
this.clearMtkSimulationTimers();
|
|
1511
|
+
this.clearRestartRecoveryTimeout();
|
|
1490
1512
|
}
|
|
1491
1513
|
}
|
|
1492
1514
|
/** Singleton — one install session machine per app process (matches the single progress screen). */
|