@mentra/engine 3.5.0-dev.1444 → 3.5.0-dev.1462
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/services/HotspotOtaTransport.d.ts +1 -1
- package/build/services/HotspotOtaTransport.d.ts.map +1 -1
- package/build/services/HotspotOtaTransport.js +19 -1
- package/build/services/HotspotOtaTransport.js.map +1 -1
- package/build/services/OtaErrorMapping.d.ts.map +1 -1
- package/build/services/OtaErrorMapping.js +3 -0
- package/build/services/OtaErrorMapping.js.map +1 -1
- package/build/services/OtaInstallCoordinator.d.ts +7 -0
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +61 -9
- package/build/services/OtaInstallCoordinator.js.map +1 -1
- package/build/services/OtaUpdateCheckService.d.ts +3 -14
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +15 -25
- package/build/services/OtaUpdateCheckService.js.map +1 -1
- package/build/services/mtkDowngrade.d.ts +2 -8
- package/build/services/mtkDowngrade.d.ts.map +1 -1
- package/build/services/mtkDowngrade.js +3 -10
- package/build/services/mtkDowngrade.js.map +1 -1
- package/build/services/otaDisplayState.d.ts +2 -0
- package/build/services/otaDisplayState.d.ts.map +1 -1
- package/build/services/otaDisplayState.js +8 -1
- package/build/services/otaDisplayState.js.map +1 -1
- package/build/services/otaManifestPolicy.d.ts.map +1 -1
- package/build/services/otaManifestPolicy.js +4 -0
- package/build/services/otaManifestPolicy.js.map +1 -1
- package/build/services/otaManifestUrl.d.ts +2 -0
- package/build/services/otaManifestUrl.d.ts.map +1 -1
- package/build/services/otaManifestUrl.js +4 -0
- package/build/services/otaManifestUrl.js.map +1 -1
- package/package.json +8 -8
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/services/HotspotOtaTransport.ts +20 -1
- package/src/services/OtaErrorMapping.ts +4 -0
- package/src/services/OtaInstallCoordinator.ts +61 -9
- package/src/services/OtaUpdateCheckService.ts +11 -34
- package/src/services/mtkDowngrade.ts +3 -10
- package/src/services/otaDisplayState.ts +10 -0
- package/src/services/otaManifestPolicy.ts +3 -0
- package/src/services/otaManifestUrl.ts +5 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const ENGINE_RELEASE_METADATA = Object.freeze({
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"familyBaseVersion": "3.5.0",
|
|
4
|
-
"releaseIdentity": "3.5.0-dev.
|
|
5
|
-
"releaseSetId": "mentra-3.5.0-dev.
|
|
6
|
-
"sourceCommit": "
|
|
7
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
8
|
-
"otaManifestSha256": "
|
|
4
|
+
"releaseIdentity": "3.5.0-dev.1462",
|
|
5
|
+
"releaseSetId": "mentra-3.5.0-dev.1462",
|
|
6
|
+
"sourceCommit": "4dc658df98cc64e6d48d0bbaaf7cc7e10803a6f6",
|
|
7
|
+
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1462.json",
|
|
8
|
+
"otaManifestSha256": "2c1cb9011d6d725760a395c3a2f35fa1c6c6f31159cc729963fa404d9851c1c9"
|
|
9
9
|
});
|
|
10
10
|
//# sourceMappingURL=releaseMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,uBAAuB,GAAoC,MAAM,CAAC,MAAM,CAAC;IACpF,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,kIAAkI;IACpJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface EngineReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.5.0\",\n \"releaseIdentity\": \"3.5.0-dev.
|
|
1
|
+
{"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,uBAAuB,GAAoC,MAAM,CAAC,MAAM,CAAC;IACpF,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,kIAAkI;IACpJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface EngineReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.5.0\",\n \"releaseIdentity\": \"3.5.0-dev.1462\",\n \"releaseSetId\": \"mentra-3.5.0-dev.1462\",\n \"sourceCommit\": \"4dc658df98cc64e6d48d0bbaaf7cc7e10803a6f6\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1462.json\",\n \"otaManifestSha256\": \"2c1cb9011d6d725760a395c3a2f35fa1c6c6f31159cc729963fa404d9851c1c9\"\n})\n"]}
|
|
@@ -6,7 +6,7 @@ export type HotspotOtaProgress = {
|
|
|
6
6
|
phase: HotspotOtaPhase;
|
|
7
7
|
artifact?: OtaArtifactDownloadProgress;
|
|
8
8
|
};
|
|
9
|
-
export type HotspotOtaErrorCode = "hotspot_wifi_permission_denied" | "hotspot_wifi_disabled" | "hotspot_start_failed" | "hotspot_join_failed" | "hotspot_other_glasses" | "hotspot_server_failed";
|
|
9
|
+
export type HotspotOtaErrorCode = "hotspot_wifi_permission_denied" | "hotspot_wifi_disabled" | "hotspot_location_denied" | "hotspot_start_failed" | "hotspot_join_failed" | "hotspot_other_glasses" | "hotspot_server_failed";
|
|
10
10
|
export declare class HotspotOtaTransportError extends Error {
|
|
11
11
|
readonly code: HotspotOtaErrorCode;
|
|
12
12
|
readonly nativeError?: LocalNetworkErrorDetails | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HotspotOtaTransport.d.ts","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAML,KAAK,2BAA2B,EAEjC,MAAM,yBAAyB,CAAA;AAOhC,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAA;AAEpC,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,uBAAuB,GACvB,sBAAsB,GACtB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B;IAChD,OAAO,CAAC,UAAU,CAAI;IACtB,OAAO,CAAC,aAAa,CAAI;IAEnB,OAAO,CACX,WAAW,EAAE,4BAA4B,EACzC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,GAClD,OAAO,CAAC,MAAM,CAAC;YAqDJ,cAAc;IAyG5B,gGAAgG;YAClF,2BAA2B;IAczC;;;OAGG;YACW,wBAAwB;IActC;;;;OAIG;YACW,mBAAmB;IAUjC,OAAO,CAAC,mBAAmB,CAa1B;IAEK,QAAQ,CAAC,qBAAqB,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAoE5D;AAED,eAAO,MAAM,mBAAmB,qBAA4B,CAAA"}
|
|
@@ -16,6 +16,8 @@ import { joinedGlassesIdentity } from "./HotspotGlassesIdentity";
|
|
|
16
16
|
import { acquireGlassesHotspot } from "./GlassesHotspotLease";
|
|
17
17
|
import { disableHotspotWithRetry } from "./HotspotShutdown";
|
|
18
18
|
import { localNetworkErrorDetails, localNetworkTransport, } from "./asg/localNetworkTransport";
|
|
19
|
+
/** Mac causes that need Location Services and Mentra's Location access, not Wi-Fi. */
|
|
20
|
+
const MAC_LOCATION_CAUSE = /^(Location (access is|services are) required to |Mac hotspot Location authorization is unavailable)/;
|
|
19
21
|
/** Joins after the first that may land on other glasses before the update stops and says so. */
|
|
20
22
|
const WRONG_GLASSES_REJOINS = 2;
|
|
21
23
|
export class HotspotOtaTransportError extends Error {
|
|
@@ -48,6 +50,18 @@ class HotspotOtaTransport {
|
|
|
48
50
|
await this.teardownPromise;
|
|
49
51
|
if (ownerRevision !== otaDeviceSessionRevision())
|
|
50
52
|
throw new Error("The OTA glasses have changed");
|
|
53
|
+
// A teardown whose hotspot shutdown went unconfirmed (glasses whose replies are queued behind
|
|
54
|
+
// a file transfer) leaves its cleanup here. Retry it rather than refuse every later attempt.
|
|
55
|
+
if (this.releaseHotspot && !this.active && !this.preparing) {
|
|
56
|
+
try {
|
|
57
|
+
await this.teardown();
|
|
58
|
+
}
|
|
59
|
+
catch (cleanupError) {
|
|
60
|
+
console.warn("[OTA_PROGRESS] leftover cleanup failed", localNetworkErrorDetails(cleanupError));
|
|
61
|
+
}
|
|
62
|
+
if (ownerRevision !== otaDeviceSessionRevision())
|
|
63
|
+
throw new Error("The OTA glasses have changed");
|
|
64
|
+
}
|
|
51
65
|
if (this.releaseHotspot ||
|
|
52
66
|
this.active ||
|
|
53
67
|
this.preparing ||
|
|
@@ -173,7 +187,11 @@ class HotspotOtaTransport {
|
|
|
173
187
|
if (Platform.OS === "android" && (await WifiManager.isEnabled().catch(() => true)) === false) {
|
|
174
188
|
throw new HotspotOtaTransportError("hotspot_wifi_disabled", "Phone Wi-Fi is off");
|
|
175
189
|
}
|
|
176
|
-
|
|
190
|
+
const nativeError = localNetworkErrorDetails(error);
|
|
191
|
+
if (MAC_LOCATION_CAUSE.test(nativeError.message ?? "")) {
|
|
192
|
+
throw new HotspotOtaTransportError("hotspot_location_denied", message, nativeError);
|
|
193
|
+
}
|
|
194
|
+
throw new HotspotOtaTransportError("hotspot_join_failed", message, nativeError);
|
|
177
195
|
}
|
|
178
196
|
throw new HotspotOtaTransportError("hotspot_server_failed", message);
|
|
179
197
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HotspotOtaTransport.js","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAC,sBAAsB,EAAC,MAAM,uBAAuB,CAAA;AAC1E,OAAO,OAAO,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,qCAAqC,CAAA;AAC7D,uFAAuF;AACvF,kEAAkE;AAClE,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAA;AACzD,OAAO,WAAW,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAA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mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAA","sourcesContent":["import BluetoothSdk, {isEnabledHotspotStatus} from \"@mentra/bluetooth-sdk\"\nimport NetInfo from \"@react-native-community/netinfo\"\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 WifiManager from \"react-native-wifi-reborn\"\nimport {getUiSeams} from \"../runtime/bootstrap\"\nimport {BgTimer} from \"../utils/timers\"\nimport {otaDeviceSessionRevision} from \"./OtaDeviceSession\"\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 {useGlassesStore} from \"../stores/glasses\"\nimport {usableSerial} from \"./fleet/glassesIdentity\"\nimport {keepHotspotUpWhileJoining} from \"./GlassesHotspotJoin\"\nimport {joinedGlassesIdentity} from \"./HotspotGlassesIdentity\"\nimport {acquireGlassesHotspot} from \"./GlassesHotspotLease\"\nimport {disableHotspotWithRetry} from \"./HotspotShutdown\"\nimport {\n localNetworkErrorDetails,\n localNetworkTransport,\n type LocalNetworkErrorDetails,\n} 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_wifi_disabled\"\n | \"hotspot_start_failed\"\n | \"hotspot_join_failed\"\n | \"hotspot_other_glasses\"\n | \"hotspot_server_failed\"\n\n/** Joins after the first that may land on other glasses before the update stops and says so. */\nconst WRONG_GLASSES_REJOINS = 2\n\nexport class HotspotOtaTransportError extends Error {\n constructor(\n public readonly code: HotspotOtaErrorCode,\n message: string,\n public readonly nativeError?: LocalNetworkErrorDetails,\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 readonly networkOwner = Symbol(\"hotspot-ota\")\n private releaseHotspot: (() => void) | null = null\n private active = false\n private prepared: PreparedOtaArtifact[] = []\n private hotspotRequested = false\n private localNetworkConnected = false\n private localNetworkRequested = false\n private serverStarted = false\n private teardownPromise: Promise<void> | null = null\n private preparing: Promise<string> | null = null\n private generation = 0\n private ownerRevision = 0\n\n async prepare(\n checkResult: OtaCheckCurrentGlassesResult,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n const ownerRevision = otaDeviceSessionRevision()\n if (this.teardownPromise) await this.teardownPromise\n if (ownerRevision !== otaDeviceSessionRevision()) throw new Error(\"The OTA glasses have changed\")\n if (\n this.releaseHotspot ||\n this.active ||\n this.preparing ||\n this.localNetworkRequested ||\n this.serverStarted ||\n this.hotspotRequested ||\n this.prepared.length\n ) {\n throw new Error(\"A hotspot OTA transport is active or still needs cleanup\")\n }\n if (!checkResult.manifestBody) throw new Error(\"The selected OTA check has no manifest body\")\n // Refusal happens before downloading or changing the glasses AP.\n this.releaseHotspot = acquireGlassesHotspot()\n this.ownerRevision = ownerRevision\n const generation = ++this.generation\n const assertCurrent = () => {\n if (generation !== this.generation || ownerRevision !== otaDeviceSessionRevision()) {\n throw new Error(\"The OTA glasses have changed\")\n }\n }\n const preparation = this.prepareAttempt(checkResult, assertCurrent, onProgress)\n this.preparing = preparation\n try {\n return await preparation\n } catch (error) {\n // Remove our promise before waiting on teardown, which joins preparation.\n if (this.preparing === preparation) this.preparing = null\n try {\n await this.teardown(ownerRevision === otaDeviceSessionRevision())\n } catch (cleanupError) {\n console.warn(\"[OTA_PROGRESS] cleanup failed\", localNetworkErrorDetails(cleanupError))\n }\n throw error\n } finally {\n if (this.preparing === preparation) this.preparing = null\n }\n }\n\n private async prepareAttempt(\n checkResult: OtaCheckCurrentGlassesResult,\n assertCurrent: () => void,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n const manifestBody = checkResult.manifestBody\n if (!manifestBody) throw new Error(\"The selected OTA check has no manifest body\")\n let phase: HotspotOtaPhase = \"downloading\"\n try {\n await this.ensureAndroidWifiPermission()\n assertCurrent()\n await this.ensureAndroidWifiEnabled()\n assertCurrent()\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 assertCurrent()\n phase = \"starting_hotspot\"\n onProgress?.({phase: \"starting_hotspot\"})\n assertCurrent()\n this.hotspotRequested = true\n const hotspot = await BluetoothSdk.setHotspotState(true)\n assertCurrent()\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 assertCurrent()\n const bluetoothSerial = usableSerial(useGlassesStore.getState())\n let localAddress: string | undefined\n for (let join = 1; ; join++) {\n this.localNetworkRequested = true\n localAddress = await keepHotspotUpWhileJoining(\n localNetworkTransport.connect(this.networkOwner, hotspot.ssid, hotspot.password, {\n assertCurrent,\n gateway: hotspot.localIp,\n // The glasses download from our listener; OTA asks their server only who they are.\n purpose: \"incoming-server\",\n }),\n {\n enable: () => BluetoothSdk.setHotspotState(true),\n cancel: () => void localNetworkTransport.disconnect(this.networkOwner).catch(() => undefined),\n },\n )\n this.localNetworkConnected = true\n assertCurrent()\n // Near many pairs, the network joined may belong to other glasses; the update must reach these.\n if ((await joinedGlassesIdentity(hotspot.localIp, bluetoothSerial)) !== \"other_glasses\") break\n assertCurrent()\n console.warn(`[OTA_PROGRESS] the hotspot joined belongs to other glasses (join ${join}) - leaving it`)\n this.localNetworkConnected = false\n await localNetworkTransport.disconnect(this.networkOwner)\n this.localNetworkRequested = false\n assertCurrent()\n if (join > WRONG_GLASSES_REJOINS) {\n throw new HotspotOtaTransportError(\n \"hotspot_other_glasses\",\n \"The hotspot joined belongs to other glasses, not the connected pair\",\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 assertCurrent()\n const manifest = rewriteManifestForLocalServer(manifestBody, this.prepared, server.baseUrl)\n const published = await otaServer.start(manifest, artifactPaths, server.host)\n assertCurrent()\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 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 // Wi-Fi turned off after the preflight fails the same instant way; name the real cause.\n if (Platform.OS === \"android\" && (await WifiManager.isEnabled().catch(() => true)) === false) {\n throw new HotspotOtaTransportError(\"hotspot_wifi_disabled\", \"Phone Wi-Fi is off\")\n }\n throw new HotspotOtaTransportError(\"hotspot_join_failed\", message, localNetworkErrorDetails(error))\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 /**\n * WifiNetworkSpecifier fails as Unavailable at once while the radio is off, which reads as a\n * broken glasses hotspot. Ask before downloading, through the host's Wi-Fi prompt when it has one.\n */\n private async ensureAndroidWifiEnabled(): Promise<void> {\n if (Platform.OS !== \"android\") return\n // A probe that throws is unknown, not off: the join still reports its own failure.\n if (await WifiManager.isEnabled().catch(() => true)) return\n const result = await getUiSeams()\n .requestPhoneWifiEnable?.()\n .catch(() => null)\n if (result?.enabled === true) {\n await this.waitForWifiInternet()\n return\n }\n throw new HotspotOtaTransportError(\"hotspot_wifi_disabled\", \"Phone Wi-Fi is off\")\n }\n\n /**\n * A radio just turned on joins a saved network a few seconds later, and Android then drops\n * cellular as the default network, aborting any download started on it. Let that happen\n * first. Without a joinable network, download over the current one after the bound.\n */\n private async waitForWifiInternet(timeoutMs = 15_000): Promise<void> {\n const deadline = Date.now() + timeoutMs\n while (Date.now() < deadline) {\n const state = await NetInfo.fetch().catch(() => null)\n if (state?.type === \"wifi\" && state.isConnected && state.isInternetReachable !== false) return\n await new Promise<void>((resolve) => BgTimer.setTimeout(resolve, 500))\n }\n console.log(\"[OTA_PROGRESS] Wi-Fi is on but not the internet route yet; downloading anyway\")\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(disableGlassesHotspot = true): Promise<void> {\n this.generation += 1\n if (this.teardownPromise) return this.teardownPromise\n this.teardownPromise = (async () => {\n if (!this.releaseHotspot) return\n // The join has no time limit: cancel a pending one so preparation can settle. The\n // reservation stays held until the cleanup below has finished.\n if (this.preparing && this.localNetworkRequested && !this.localNetworkConnected) {\n void localNetworkTransport.disconnect(this.networkOwner).catch(() => undefined)\n }\n await this.preparing?.catch(() => {})\n const errors: unknown[] = []\n if (disableGlassesHotspot && this.ownerRevision === otaDeviceSessionRevision() && this.hotspotRequested) {\n try {\n const hotspotStopped = await disableHotspotWithRetry(\n () =>\n this.ownerRevision === otaDeviceSessionRevision()\n ? BluetoothSdk.setHotspotState(false)\n : Promise.resolve({state: \"enabled\" as const}),\n {\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 )\n if (hotspotStopped) this.hotspotRequested = false\n else errors.push(new Error(\"The glasses hotspot shutdown was not confirmed\"))\n } catch (error) {\n errors.push(error)\n }\n } else this.hotspotRequested = false\n if (this.serverStarted) {\n try {\n await otaServer.stop()\n this.serverStarted = false\n } catch (error) {\n errors.push(error)\n }\n }\n if (this.localNetworkRequested) {\n try {\n await localNetworkTransport.disconnect(this.networkOwner, true)\n this.localNetworkRequested = false\n this.localNetworkConnected = false\n } catch (error) {\n errors.push(error)\n }\n }\n if (!this.serverStarted) {\n // A server that has not stopped can still read these files.\n try {\n await cleanupArtifacts()\n this.prepared = []\n } catch (error) {\n errors.push(error)\n }\n }\n this.active = false\n if (errors.length) throw errors[0]\n this.releaseHotspot()\n this.releaseHotspot = null\n })()\n try {\n await this.teardownPromise\n } finally {\n this.teardownPromise = null\n }\n }\n}\n\nexport const hotspotOtaTransport = new HotspotOtaTransport()\n"]}
|
|
1
|
+
{"version":3,"file":"HotspotOtaTransport.js","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAC,sBAAsB,EA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AAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC/B,IAAI,CAAC;oBACH,MAAM,qBAAqB,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;oBAC/D,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAA;oBAClC,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAA;gBACpC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACpB,CAAC;YACH,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;gBACxB,4DAA4D;gBAC5D,IAAI,CAAC;oBACH,MAAM,gBAAgB,EAAE,CAAA;oBACxB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;gBACpB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACpB,CAAC;YACH,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;YACnB,IAAI,MAAM,CAAC,MAAM;gBAAE,MAAM,MAAM,CAAC,CAAC,CAAC,CAAA;YAClC,IAAI,CAAC,cAAc,EAAE,CAAA;YACrB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC5B,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 NetInfo from \"@react-native-community/netinfo\"\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 WifiManager from \"react-native-wifi-reborn\"\nimport {getUiSeams} from \"../runtime/bootstrap\"\nimport {BgTimer} from \"../utils/timers\"\nimport {otaDeviceSessionRevision} from \"./OtaDeviceSession\"\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 {useGlassesStore} from \"../stores/glasses\"\nimport {usableSerial} from \"./fleet/glassesIdentity\"\nimport {keepHotspotUpWhileJoining} from \"./GlassesHotspotJoin\"\nimport {joinedGlassesIdentity} from \"./HotspotGlassesIdentity\"\nimport {acquireGlassesHotspot} from \"./GlassesHotspotLease\"\nimport {disableHotspotWithRetry} from \"./HotspotShutdown\"\nimport {\n localNetworkErrorDetails,\n localNetworkTransport,\n type LocalNetworkErrorDetails,\n} 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_wifi_disabled\"\n | \"hotspot_location_denied\"\n | \"hotspot_start_failed\"\n | \"hotspot_join_failed\"\n | \"hotspot_other_glasses\"\n | \"hotspot_server_failed\"\n\n/** Mac causes that need Location Services and Mentra's Location access, not Wi-Fi. */\nconst MAC_LOCATION_CAUSE =\n /^(Location (access is|services are) required to |Mac hotspot Location authorization is unavailable)/\n\n/** Joins after the first that may land on other glasses before the update stops and says so. */\nconst WRONG_GLASSES_REJOINS = 2\n\nexport class HotspotOtaTransportError extends Error {\n constructor(\n public readonly code: HotspotOtaErrorCode,\n message: string,\n public readonly nativeError?: LocalNetworkErrorDetails,\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 readonly networkOwner = Symbol(\"hotspot-ota\")\n private releaseHotspot: (() => void) | null = null\n private active = false\n private prepared: PreparedOtaArtifact[] = []\n private hotspotRequested = false\n private localNetworkConnected = false\n private localNetworkRequested = false\n private serverStarted = false\n private teardownPromise: Promise<void> | null = null\n private preparing: Promise<string> | null = null\n private generation = 0\n private ownerRevision = 0\n\n async prepare(\n checkResult: OtaCheckCurrentGlassesResult,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n const ownerRevision = otaDeviceSessionRevision()\n if (this.teardownPromise) await this.teardownPromise\n if (ownerRevision !== otaDeviceSessionRevision()) throw new Error(\"The OTA glasses have changed\")\n // A teardown whose hotspot shutdown went unconfirmed (glasses whose replies are queued behind\n // a file transfer) leaves its cleanup here. Retry it rather than refuse every later attempt.\n if (this.releaseHotspot && !this.active && !this.preparing) {\n try {\n await this.teardown()\n } catch (cleanupError) {\n console.warn(\"[OTA_PROGRESS] leftover cleanup failed\", localNetworkErrorDetails(cleanupError))\n }\n if (ownerRevision !== otaDeviceSessionRevision()) throw new Error(\"The OTA glasses have changed\")\n }\n if (\n this.releaseHotspot ||\n this.active ||\n this.preparing ||\n this.localNetworkRequested ||\n this.serverStarted ||\n this.hotspotRequested ||\n this.prepared.length\n ) {\n throw new Error(\"A hotspot OTA transport is active or still needs cleanup\")\n }\n if (!checkResult.manifestBody) throw new Error(\"The selected OTA check has no manifest body\")\n // Refusal happens before downloading or changing the glasses AP.\n this.releaseHotspot = acquireGlassesHotspot()\n this.ownerRevision = ownerRevision\n const generation = ++this.generation\n const assertCurrent = () => {\n if (generation !== this.generation || ownerRevision !== otaDeviceSessionRevision()) {\n throw new Error(\"The OTA glasses have changed\")\n }\n }\n const preparation = this.prepareAttempt(checkResult, assertCurrent, onProgress)\n this.preparing = preparation\n try {\n return await preparation\n } catch (error) {\n // Remove our promise before waiting on teardown, which joins preparation.\n if (this.preparing === preparation) this.preparing = null\n try {\n await this.teardown(ownerRevision === otaDeviceSessionRevision())\n } catch (cleanupError) {\n console.warn(\"[OTA_PROGRESS] cleanup failed\", localNetworkErrorDetails(cleanupError))\n }\n throw error\n } finally {\n if (this.preparing === preparation) this.preparing = null\n }\n }\n\n private async prepareAttempt(\n checkResult: OtaCheckCurrentGlassesResult,\n assertCurrent: () => void,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n const manifestBody = checkResult.manifestBody\n if (!manifestBody) throw new Error(\"The selected OTA check has no manifest body\")\n let phase: HotspotOtaPhase = \"downloading\"\n try {\n await this.ensureAndroidWifiPermission()\n assertCurrent()\n await this.ensureAndroidWifiEnabled()\n assertCurrent()\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 assertCurrent()\n phase = \"starting_hotspot\"\n onProgress?.({phase: \"starting_hotspot\"})\n assertCurrent()\n this.hotspotRequested = true\n const hotspot = await BluetoothSdk.setHotspotState(true)\n assertCurrent()\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 assertCurrent()\n const bluetoothSerial = usableSerial(useGlassesStore.getState())\n let localAddress: string | undefined\n for (let join = 1; ; join++) {\n this.localNetworkRequested = true\n localAddress = await keepHotspotUpWhileJoining(\n localNetworkTransport.connect(this.networkOwner, hotspot.ssid, hotspot.password, {\n assertCurrent,\n gateway: hotspot.localIp,\n // The glasses download from our listener; OTA asks their server only who they are.\n purpose: \"incoming-server\",\n }),\n {\n enable: () => BluetoothSdk.setHotspotState(true),\n cancel: () => void localNetworkTransport.disconnect(this.networkOwner).catch(() => undefined),\n },\n )\n this.localNetworkConnected = true\n assertCurrent()\n // Near many pairs, the network joined may belong to other glasses; the update must reach these.\n if ((await joinedGlassesIdentity(hotspot.localIp, bluetoothSerial)) !== \"other_glasses\") break\n assertCurrent()\n console.warn(`[OTA_PROGRESS] the hotspot joined belongs to other glasses (join ${join}) - leaving it`)\n this.localNetworkConnected = false\n await localNetworkTransport.disconnect(this.networkOwner)\n this.localNetworkRequested = false\n assertCurrent()\n if (join > WRONG_GLASSES_REJOINS) {\n throw new HotspotOtaTransportError(\n \"hotspot_other_glasses\",\n \"The hotspot joined belongs to other glasses, not the connected pair\",\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 assertCurrent()\n const manifest = rewriteManifestForLocalServer(manifestBody, this.prepared, server.baseUrl)\n const published = await otaServer.start(manifest, artifactPaths, server.host)\n assertCurrent()\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 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 // Wi-Fi turned off after the preflight fails the same instant way; name the real cause.\n if (Platform.OS === \"android\" && (await WifiManager.isEnabled().catch(() => true)) === false) {\n throw new HotspotOtaTransportError(\"hotspot_wifi_disabled\", \"Phone Wi-Fi is off\")\n }\n const nativeError = localNetworkErrorDetails(error)\n if (MAC_LOCATION_CAUSE.test(nativeError.message ?? \"\")) {\n throw new HotspotOtaTransportError(\"hotspot_location_denied\", message, nativeError)\n }\n throw new HotspotOtaTransportError(\"hotspot_join_failed\", message, nativeError)\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 /**\n * WifiNetworkSpecifier fails as Unavailable at once while the radio is off, which reads as a\n * broken glasses hotspot. Ask before downloading, through the host's Wi-Fi prompt when it has one.\n */\n private async ensureAndroidWifiEnabled(): Promise<void> {\n if (Platform.OS !== \"android\") return\n // A probe that throws is unknown, not off: the join still reports its own failure.\n if (await WifiManager.isEnabled().catch(() => true)) return\n const result = await getUiSeams()\n .requestPhoneWifiEnable?.()\n .catch(() => null)\n if (result?.enabled === true) {\n await this.waitForWifiInternet()\n return\n }\n throw new HotspotOtaTransportError(\"hotspot_wifi_disabled\", \"Phone Wi-Fi is off\")\n }\n\n /**\n * A radio just turned on joins a saved network a few seconds later, and Android then drops\n * cellular as the default network, aborting any download started on it. Let that happen\n * first. Without a joinable network, download over the current one after the bound.\n */\n private async waitForWifiInternet(timeoutMs = 15_000): Promise<void> {\n const deadline = Date.now() + timeoutMs\n while (Date.now() < deadline) {\n const state = await NetInfo.fetch().catch(() => null)\n if (state?.type === \"wifi\" && state.isConnected && state.isInternetReachable !== false) return\n await new Promise<void>((resolve) => BgTimer.setTimeout(resolve, 500))\n }\n console.log(\"[OTA_PROGRESS] Wi-Fi is on but not the internet route yet; downloading anyway\")\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(disableGlassesHotspot = true): Promise<void> {\n this.generation += 1\n if (this.teardownPromise) return this.teardownPromise\n this.teardownPromise = (async () => {\n if (!this.releaseHotspot) return\n // The join has no time limit: cancel a pending one so preparation can settle. The\n // reservation stays held until the cleanup below has finished.\n if (this.preparing && this.localNetworkRequested && !this.localNetworkConnected) {\n void localNetworkTransport.disconnect(this.networkOwner).catch(() => undefined)\n }\n await this.preparing?.catch(() => {})\n const errors: unknown[] = []\n if (disableGlassesHotspot && this.ownerRevision === otaDeviceSessionRevision() && this.hotspotRequested) {\n try {\n const hotspotStopped = await disableHotspotWithRetry(\n () =>\n this.ownerRevision === otaDeviceSessionRevision()\n ? BluetoothSdk.setHotspotState(false)\n : Promise.resolve({state: \"enabled\" as const}),\n {\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 )\n if (hotspotStopped) this.hotspotRequested = false\n else errors.push(new Error(\"The glasses hotspot shutdown was not confirmed\"))\n } catch (error) {\n errors.push(error)\n }\n } else this.hotspotRequested = false\n if (this.serverStarted) {\n try {\n await otaServer.stop()\n this.serverStarted = false\n } catch (error) {\n errors.push(error)\n }\n }\n if (this.localNetworkRequested) {\n try {\n await localNetworkTransport.disconnect(this.networkOwner, true)\n this.localNetworkRequested = false\n this.localNetworkConnected = false\n } catch (error) {\n errors.push(error)\n }\n }\n if (!this.serverStarted) {\n // A server that has not stopped can still read these files.\n try {\n await cleanupArtifacts()\n this.prepared = []\n } catch (error) {\n errors.push(error)\n }\n }\n this.active = false\n if (errors.length) throw errors[0]\n this.releaseHotspot()\n this.releaseHotspot = null\n })()\n try {\n await this.teardownPromise\n } finally {\n this.teardownPromise = null\n }\n }\n}\n\nexport const hotspotOtaTransport = new HotspotOtaTransport()\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaErrorMapping.d.ts","sourceRoot":"","sources":["../../src/services/OtaErrorMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BxE,CAAA;AAED,eAAO,MAAM,kCAAkC,4BAA4B,CAAA;AAC3E,eAAO,MAAM,0BAA0B,qBAAqB,CAAA;AAC5D,eAAO,MAAM,uCAAuC,gCAAgC,CAAA;AACpF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,oBAAoB,CAAA;AAc1D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"OtaErrorMapping.d.ts","sourceRoot":"","sources":["../../src/services/OtaErrorMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0BxE,CAAA;AAED,eAAO,MAAM,kCAAkC,4BAA4B,CAAA;AAC3E,eAAO,MAAM,0BAA0B,qBAAqB,CAAA;AAC5D,eAAO,MAAM,uCAAuC,gCAAgC,CAAA;AACpF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,oBAAoB,CAAA;AAc1D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CA8BxE;AAED,qGAAqG;AACrG,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6DnE,CAAA;AAED,eAAO,MAAM,2BAA2B,QAAkE,CAAA;AAE1G;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAO7D;AAmBD;;;;;;GAMG;AACH,wBAAgB,yCAAyC,CACvD,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EACvC,WAAW,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAC3C,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAcT;AAED,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,uCAAuC,CACrD,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,EACvC,YAAY,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAC5C,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAQT"}
|
|
@@ -77,6 +77,8 @@ export function phoneOtaErrorCopyKey(error, os) {
|
|
|
77
77
|
return "ota:errorPhoneNearbyPermission";
|
|
78
78
|
case "hotspot_wifi_disabled":
|
|
79
79
|
return "ota:errorPhoneWifiOff";
|
|
80
|
+
case "hotspot_location_denied":
|
|
81
|
+
return "ota:errorMacLocation";
|
|
80
82
|
case "hotspot_start_failed":
|
|
81
83
|
return "ota:errorGlassesHotspotStart";
|
|
82
84
|
case "hotspot_join_failed":
|
|
@@ -128,6 +130,7 @@ export const OTA_ERROR_ENGLISH_COPY = {
|
|
|
128
130
|
"ota:errorPhoneVerify": "The update file could not be verified. Please try again later.",
|
|
129
131
|
"ota:errorPhoneNearbyPermission": "Allow nearby devices access so your phone can connect to your glasses.",
|
|
130
132
|
"ota:errorPhoneWifiOff": "Turn on your phone’s Wi-Fi so it can connect to your glasses, then try again.",
|
|
133
|
+
"ota:errorMacLocation": "This Mac needs Location access to find your glasses’ Wi-Fi. In System Settings, open Privacy & Security, turn on Location Services and allow Mentra, then try again.",
|
|
131
134
|
"ota:errorGlassesHotspotStart": "Your glasses could not start the connection needed for the update. Please try again.",
|
|
132
135
|
"ota:errorPhoneHotspotJoin": "Your phone could not connect to your glasses for the update. Please try again.",
|
|
133
136
|
"ota:errorPhoneOtherGlasses": "Your phone reached another pair of glasses instead of yours. Move away from other glasses or turn them off, then try again.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaErrorMapping.js","sourceRoot":"","sources":["../../src/services/OtaErrorMapping.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAqC;IAC3E,UAAU,EAAE,oBAAoB;IAChC,iBAAiB,EAAE,2BAA2B;IAC9C,eAAe,EAAE,yBAAyB;IAC1C,gBAAgB,EAAE,0BAA0B;IAC5C,UAAU,EAAE,oBAAoB;IAChC,2BAA2B,EAAE,oCAAoC;IACjE,+BAA+B,EAAE,wCAAwC;IACzE,8BAA8B,EAAE,uCAAuC;IACvE,uBAAuB,EAAE,gCAAgC;IACzD,wBAAwB,EAAE,iCAAiC;IAC3D,mBAAmB,EAAE,4BAA4B;IACjD,WAAW,EAAE,qBAAqB;IAClC,UAAU,EAAE,oBAAoB;IAChC,SAAS,EAAE,mBAAmB;IAC9B,eAAe,EAAE,yBAAyB;IAC1C,oBAAoB,EAAE,8BAA8B;IACpD,kBAAkB,EAAE,2BAA2B;IAC/C,sBAAsB,EAAE,+BAA+B;IACvD,iBAAiB,EAAE,0BAA0B;IAC7C,cAAc,EAAE,wBAAwB;IACxC,+BAA+B,EAAE,sCAAsC;IACvE,yBAAyB,EAAE,kCAAkC;IAC7D,wB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IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import type {OtaProgress, OtaStatus} from \"../facades/ota\"\n\n/**\n * Copy keys for OTA failures the glasses report by code (`ota_status.error`), plus the\n * phone-side BES restart instruction. Hosts translate these keys; the engine's own\n * English copy for each key lives in `OTA_ERROR_ENGLISH_COPY`.\n *\n * The glasses-side producers are `sendProgressToPhone(..., \"FAILED\", errorCode)` in the\n * ASG client's OtaHelper (download classification, install failures, and the downgrade\n * handoff to the recovery worker). Keep this table in sync with those codes; anything\n * else falls back to `OTA_ERROR_UNKNOWN_GLASSES_COPY_KEY`. Raw codes remain in private\n * incident evidence rather than the product failure page.\n */\nexport const OTA_GLASSES_ERROR_COPY_KEYS: Readonly<Record<string, string>> = {\n dns_failed: \"ota:errorDnsFailed\",\n connection_failed: \"ota:errorConnectionFailed\",\n connect_timeout: \"ota:errorConnectTimeout\",\n download_timeout: \"ota:errorDownloadTimeout\",\n http_error: \"ota:errorHttpError\",\n downgrade_recovery_disabled: \"ota:errorDowngradeRecoveryDisabled\",\n downgrade_recovery_incompatible: \"ota:errorDowngradeRecoveryIncompatible\",\n downgrade_recovery_unavailable: \"ota:errorDowngradeRecoveryUnavailable\",\n downgrade_recovery_busy: \"ota:errorDowngradeRecoveryBusy\",\n downgrade_status_unknown: \"ota:errorDowngradeStatusUnknown\",\n downgrade_not_owned: \"ota:errorDowngradeNotOwned\",\n no_internet: \"ota:errorNoInternet\",\n clock_skew: \"ota:errorClockSkew\",\n ssl_error: \"ota:errorSslError\",\n download_failed: \"ota:errorDownloadFailed\",\n insufficient_storage: \"ota:errorInsufficientStorage\",\n firmware_too_large: \"ota:errorFirmwareTooLarge\",\n firmware_verify_failed: \"ota:errorFirmwareVerifyFailed\",\n apk_verify_failed: \"ota:errorApkVerifyFailed\",\n install_failed: \"ota:errorInstallFailed\",\n apk_restart_guard_not_persisted: \"ota:errorApkRestartGuardNotPersisted\",\n downgrade_handoff_refused: \"ota:errorDowngradeHandoffRefused\",\n downgrade_handoff_failed: \"ota:errorDowngradeHandoffFailed\",\n downgrade_transaction_stalled: \"ota:errorDowngradeTransactionStalled\",\n bes_not_started: \"ota:errorBesNotStarted\",\n}\n\nexport const OTA_ERROR_UNKNOWN_GLASSES_COPY_KEY = \"ota:errorGlassesUnknown\"\nexport const OTA_ERROR_GENERIC_COPY_KEY = \"ota:errorGeneric\"\nexport const OTA_ERROR_BES_RESTART_REQUIRED_COPY_KEY = \"ota:errorBesRestartRequired\"\n/**\n * The glasses could not start the BES install: mh_ota was never sent, so the BES stayed in normal\n * mode and a retry is safe without restarting the glasses.\n */\nexport const OTA_BES_NOT_STARTED_ERROR = \"bes_not_started\"\n\nconst PHONE_ARTIFACT_COPY_KEYS: Readonly<Record<string, string>> = {\n internet: \"ota:errorPhoneInternet\",\n connection: \"ota:errorPhoneConnection\",\n server: \"ota:errorPhoneDownloadServer\",\n timeout: \"ota:errorPhoneDownloadTimeout\",\n storage: \"ota:errorPhoneStorage\",\n save: \"ota:errorPhoneSave\",\n secure_connection: \"ota:errorPhoneSecureConnection\",\n download: \"ota:errorPhoneDownload\",\n verify: \"ota:errorPhoneVerify\",\n}\n\n/**\n * A known failed stage is useful; it is not evidence of an internet outage. `os` picks the iOS\n * join copy: iOS cannot read the Wi-Fi radio, so its join failure is where we point at it.\n */\nexport function phoneOtaErrorCopyKey(error: unknown, os?: string): string {\n if (typeof error !== \"object\" || error === null) return OTA_ERROR_GENERIC_COPY_KEY\n const detail = error as {code?: unknown; failure?: {category?: unknown}}\n switch (detail.code) {\n case \"artifact_download_failed\":\n case \"artifact_verify_failed\": {\n const category = detail.failure?.category\n if (typeof category === \"string\" && hasOwn(PHONE_ARTIFACT_COPY_KEYS, category))\n return PHONE_ARTIFACT_COPY_KEYS[category]\n return detail.code === \"artifact_verify_failed\" ? \"ota:errorPhoneVerify\" : \"ota:errorPhoneDownload\"\n }\n case \"manifest_invalid\":\n return \"ota:errorPhoneVerify\"\n case \"hotspot_wifi_permission_denied\":\n return \"ota:errorPhoneNearbyPermission\"\n case \"hotspot_wifi_disabled\":\n return \"ota:errorPhoneWifiOff\"\n case \"hotspot_start_failed\":\n return \"ota:errorGlassesHotspotStart\"\n case \"hotspot_join_failed\":\n return os === \"ios\" ? \"ota:errorPhoneHotspotJoinIos\" : \"ota:errorPhoneHotspotJoin\"\n case \"hotspot_other_glasses\":\n return \"ota:errorPhoneOtherGlasses\"\n case \"hotspot_server_failed\":\n return \"ota:errorPhoneShareUpdate\"\n default:\n return OTA_ERROR_GENERIC_COPY_KEY\n }\n}\n\n/** English copy for every OTA error key above. Mirrored in the Mentra App's `ota` i18n namespace. */\nexport const OTA_ERROR_ENGLISH_COPY: Readonly<Record<string, string>> = {\n \"ota:errorDnsFailed\": \"Could not find the update server — retry, or check glasses Wi-Fi if this continues\",\n \"ota:errorConnectionFailed\": \"Could not connect to the update server — please retry\",\n \"ota:errorConnectTimeout\": \"The update server took too long to connect — please retry\",\n \"ota:errorDownloadTimeout\": \"The update stopped responding — please retry\",\n \"ota:errorHttpError\": \"The update server returned an error — retry later or contact support\",\n \"ota:errorDowngradeRecoveryDisabled\":\n \"The recovery service is disabled. Contact support to restore it before changing versions.\",\n \"ota:errorDowngradeRecoveryIncompatible\":\n \"The recovery service is incompatible. Contact support to restore it before changing versions.\",\n \"ota:errorDowngradeRecoveryUnavailable\":\n \"The recovery service is not ready. Wait a moment and retry; contact support if this continues.\",\n \"ota:errorDowngradeRecoveryBusy\":\n \"Another glasses recovery is still running. Keep your glasses nearby and retry after it finishes.\",\n \"ota:errorDowngradeStatusUnknown\":\n \"Still checking the version change on your glasses. Keep them nearby. Contact support if this continues.\",\n \"ota:errorDowngradeNotOwned\": \"The version change did not finish. Recovery has stopped; you can safely retry.\",\n \"ota:errorNoInternet\": \"Glasses Wi-Fi has no internet connection\",\n \"ota:errorClockSkew\": \"Glasses clock is wrong — syncing time from your phone, then retrying update check\",\n \"ota:errorSslError\": \"Secure connection failed — try a different Wi-Fi network\",\n \"ota:errorDownloadFailed\": \"The update could not be downloaded to your glasses. Please try again.\",\n \"ota:errorInsufficientStorage\": \"Not enough storage on your glasses — free up space before trying again\",\n \"ota:errorFirmwareTooLarge\": \"Firmware file is unexpectedly large — please contact support\",\n \"ota:errorFirmwareVerifyFailed\": \"Firmware verification failed — please try again or contact support\",\n \"ota:errorApkVerifyFailed\": \"Update verification failed — please try again or contact support\",\n \"ota:errorInstallFailed\": \"The update could not be installed on your glasses. Please try again.\",\n \"ota:errorApkRestartGuardNotPersisted\":\n \"Your glasses could not save the update before restarting. Restart your glasses and try again.\",\n \"ota:errorDowngradeHandoffRefused\":\n \"Your glasses could not start the version change. Restart your glasses and try again.\",\n \"ota:errorDowngradeHandoffFailed\":\n \"The recovery service on your glasses did not respond. Restart your glasses and try again.\",\n \"ota:errorDowngradeTransactionStalled\":\n \"The version change on your glasses did not finish. Restart your glasses and try again.\",\n \"ota:errorGlassesUnknown\": \"Something went wrong. Please try again.\",\n \"ota:errorGeneric\": \"Something went wrong. Please try again.\",\n \"ota:errorPhoneInternet\": \"Your phone could not connect to the internet. Check its connection and try again.\",\n \"ota:errorPhoneConnection\": \"Your phone could not reach the update server. Check its connection and try again.\",\n \"ota:errorPhoneDownloadServer\": \"The update server could not provide the download. Please try again later.\",\n \"ota:errorPhoneDownloadTimeout\": \"The update download took too long. Please try again.\",\n \"ota:errorPhoneStorage\": \"There is not enough space on your phone for the update. Free up space and try again.\",\n \"ota:errorPhoneSave\": \"Your phone could not save the update. Please try again.\",\n \"ota:errorPhoneSecureConnection\":\n \"Your phone could not make a secure connection to the update server. Please try again later.\",\n \"ota:errorPhoneDownload\": \"The update could not be downloaded to your phone. Please try again.\",\n \"ota:errorPhoneVerify\": \"The update file could not be verified. Please try again later.\",\n \"ota:errorPhoneNearbyPermission\": \"Allow nearby devices access so your phone can connect to your glasses.\",\n \"ota:errorPhoneWifiOff\": \"Turn on your phone’s Wi-Fi so it can connect to your glasses, then try again.\",\n \"ota:errorGlassesHotspotStart\":\n \"Your glasses could not start the connection needed for the update. Please try again.\",\n \"ota:errorPhoneHotspotJoin\": \"Your phone could not connect to your glasses for the update. Please try again.\",\n \"ota:errorPhoneOtherGlasses\":\n \"Your phone reached another pair of glasses instead of yours. Move away from other glasses or turn them off, then try again.\",\n \"ota:errorPhoneHotspotJoinIos\":\n \"Your phone could not connect to your glasses for the update. Make sure your phone’s Wi-Fi is on, then try again.\",\n \"ota:errorPhoneShareUpdate\": \"Your phone could not send the update to your glasses. Please try again.\",\n \"ota:errorBesRestartRequired\": \"Restart your glasses to safely exit firmware update mode before trying again\",\n \"ota:errorBesNotStarted\": \"Your glasses could not start the firmware update. Keep them nearby and try again.\",\n \"ota:errorCode\": \"Error code: {{code}}\",\n}\n\nexport const BES_INSTALL_RESTART_MESSAGE = OTA_ERROR_ENGLISH_COPY[OTA_ERROR_BES_RESTART_REQUIRED_COPY_KEY]\n\n/**\n * Copy key for a glasses-reported failure code. Unknown codes get the generic\n * glasses-error copy; a missing code gets the plain generic copy.\n */\nexport function otaErrorCopyKey(error?: string | null): string {\n if (!error) return OTA_ERROR_GENERIC_COPY_KEY\n // Own-property lookup: a code that happens to name an inherited Object member\n // (\"constructor\", \"toString\", ...) is unknown, not a mapped key.\n return hasOwn(OTA_GLASSES_ERROR_COPY_KEYS, error)\n ? OTA_GLASSES_ERROR_COPY_KEYS[error]\n : OTA_ERROR_UNKNOWN_GLASSES_COPY_KEY\n}\n\nfunction hasOwn(table: Readonly<Record<string, string>>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(table, key)\n}\n\nfunction isDownloadPhaseSnapshot(\n otaStatus: OtaStatus | null | undefined,\n otaProgress: OtaProgress | null | undefined,\n): boolean {\n if (otaStatus?.phase === \"download\") {\n return true\n }\n if (otaProgress?.stage === \"download\") {\n return true\n }\n return false\n}\n\n/**\n * Offer Change WiFi whenever the OTA flow failed while the glasses were in the\n * download step (any download failure — network, SSL, size cap, verify, etc.).\n *\n * Also covers phone-side watchdog failures that fire while the store still shows\n * an active download phase (stall / global timeout mid-download).\n */\nexport function shouldShowChangeWifiForOtaDownloadFailure(\n otaStatus: OtaStatus | null | undefined,\n otaProgress: OtaProgress | null | undefined,\n localErrorMessage: string,\n): boolean {\n if (otaStatus?.error === \"insufficient_storage\" || otaProgress?.errorMessage === \"insufficient_storage\") {\n return false\n }\n if (otaStatus?.status === \"failed\" && otaStatus.phase === \"download\") {\n return true\n }\n if (otaProgress?.status === \"FAILED\" && otaProgress.stage === \"download\") {\n return true\n }\n if (localErrorMessage && isDownloadPhaseSnapshot(otaStatus, otaProgress)) {\n return true\n }\n return false\n}\n\n/** English message for a glasses-reported failure code. Never echoes the raw code. */\nexport function getOtaErrorMessage(error?: string | null): string {\n return OTA_ERROR_ENGLISH_COPY[otaErrorCopyKey(error)]\n}\n\n/**\n * Once a BES install has started, any failure conservatively requires a glasses restart, since a\n * generic failure or silence may mean BES entered its raw OTA parser. The one exception is the\n * glasses reporting `bes_not_started`: they never asked the BES to enter OTA mode, so a retry is\n * safe.\n */\nexport function shouldRequireGlassesRebootForBesFailure(\n otaStatus: OtaStatus | null | undefined,\n _otaProgress: OtaProgress | null | undefined,\n localErrorMessage: string,\n): boolean {\n if (otaStatus?.stepType !== \"bes\" || otaStatus.phase !== \"install\") {\n return false\n }\n if (otaStatus.status === \"failed\" && otaStatus.error === OTA_BES_NOT_STARTED_ERROR) {\n return false\n }\n return otaStatus.status === \"failed\" || Boolean(localErrorMessage)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"OtaErrorMapping.js","sourceRoot":"","sources":["../../src/services/OtaErrorMapping.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAqC;IAC3E,UAAU,EAAE,oBAAoB;IAChC,iBAAiB,EAAE,2BAA2B;IAC9C,eAAe,EAAE,yBAAyB;IAC1C,gBAAgB,EAAE,0BAA0B;IAC5C,UAAU,EAAE,oBAAoB;IAChC,2BAA2B,EAAE,oCAAoC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AC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CAAC,KAAqB;IACtD,OAAO,sBAAsB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uCAAuC,CACrD,SAAuC,EACvC,YAA4C,EAC5C,iBAAyB;IAEzB,IAAI,SAAS,EAAE,QAAQ,KAAK,KAAK,IAAI,SAAS,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACnE,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,SAAS,CAAC,KAAK,KAAK,yBAAyB,EAAE,CAAC;QACnF,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import type {OtaProgress, OtaStatus} from \"../facades/ota\"\n\n/**\n * Copy keys for OTA failures the glasses report by code (`ota_status.error`), plus the\n * phone-side BES restart instruction. Hosts translate these keys; the engine's own\n * English copy for each key lives in `OTA_ERROR_ENGLISH_COPY`.\n *\n * The glasses-side producers are `sendProgressToPhone(..., \"FAILED\", errorCode)` in the\n * ASG client's OtaHelper (download classification, install failures, and the downgrade\n * handoff to the recovery worker). Keep this table in sync with those codes; anything\n * else falls back to `OTA_ERROR_UNKNOWN_GLASSES_COPY_KEY`. Raw codes remain in private\n * incident evidence rather than the product failure page.\n */\nexport const OTA_GLASSES_ERROR_COPY_KEYS: Readonly<Record<string, string>> = {\n dns_failed: \"ota:errorDnsFailed\",\n connection_failed: \"ota:errorConnectionFailed\",\n connect_timeout: \"ota:errorConnectTimeout\",\n download_timeout: \"ota:errorDownloadTimeout\",\n http_error: \"ota:errorHttpError\",\n downgrade_recovery_disabled: \"ota:errorDowngradeRecoveryDisabled\",\n downgrade_recovery_incompatible: \"ota:errorDowngradeRecoveryIncompatible\",\n downgrade_recovery_unavailable: \"ota:errorDowngradeRecoveryUnavailable\",\n downgrade_recovery_busy: \"ota:errorDowngradeRecoveryBusy\",\n downgrade_status_unknown: \"ota:errorDowngradeStatusUnknown\",\n downgrade_not_owned: \"ota:errorDowngradeNotOwned\",\n no_internet: \"ota:errorNoInternet\",\n clock_skew: \"ota:errorClockSkew\",\n ssl_error: \"ota:errorSslError\",\n download_failed: \"ota:errorDownloadFailed\",\n insufficient_storage: \"ota:errorInsufficientStorage\",\n firmware_too_large: \"ota:errorFirmwareTooLarge\",\n firmware_verify_failed: \"ota:errorFirmwareVerifyFailed\",\n apk_verify_failed: \"ota:errorApkVerifyFailed\",\n install_failed: \"ota:errorInstallFailed\",\n apk_restart_guard_not_persisted: \"ota:errorApkRestartGuardNotPersisted\",\n downgrade_handoff_refused: \"ota:errorDowngradeHandoffRefused\",\n downgrade_handoff_failed: \"ota:errorDowngradeHandoffFailed\",\n downgrade_transaction_stalled: \"ota:errorDowngradeTransactionStalled\",\n bes_not_started: \"ota:errorBesNotStarted\",\n}\n\nexport const OTA_ERROR_UNKNOWN_GLASSES_COPY_KEY = \"ota:errorGlassesUnknown\"\nexport const OTA_ERROR_GENERIC_COPY_KEY = \"ota:errorGeneric\"\nexport const OTA_ERROR_BES_RESTART_REQUIRED_COPY_KEY = \"ota:errorBesRestartRequired\"\n/**\n * The glasses could not start the BES install: mh_ota was never sent, so the BES stayed in normal\n * mode and a retry is safe without restarting the glasses.\n */\nexport const OTA_BES_NOT_STARTED_ERROR = \"bes_not_started\"\n\nconst PHONE_ARTIFACT_COPY_KEYS: Readonly<Record<string, string>> = {\n internet: \"ota:errorPhoneInternet\",\n connection: \"ota:errorPhoneConnection\",\n server: \"ota:errorPhoneDownloadServer\",\n timeout: \"ota:errorPhoneDownloadTimeout\",\n storage: \"ota:errorPhoneStorage\",\n save: \"ota:errorPhoneSave\",\n secure_connection: \"ota:errorPhoneSecureConnection\",\n download: \"ota:errorPhoneDownload\",\n verify: \"ota:errorPhoneVerify\",\n}\n\n/**\n * A known failed stage is useful; it is not evidence of an internet outage. `os` picks the iOS\n * join copy: iOS cannot read the Wi-Fi radio, so its join failure is where we point at it.\n */\nexport function phoneOtaErrorCopyKey(error: unknown, os?: string): string {\n if (typeof error !== \"object\" || error === null) return OTA_ERROR_GENERIC_COPY_KEY\n const detail = error as {code?: unknown; failure?: {category?: unknown}}\n switch (detail.code) {\n case \"artifact_download_failed\":\n case \"artifact_verify_failed\": {\n const category = detail.failure?.category\n if (typeof category === \"string\" && hasOwn(PHONE_ARTIFACT_COPY_KEYS, category))\n return PHONE_ARTIFACT_COPY_KEYS[category]\n return detail.code === \"artifact_verify_failed\" ? \"ota:errorPhoneVerify\" : \"ota:errorPhoneDownload\"\n }\n case \"manifest_invalid\":\n return \"ota:errorPhoneVerify\"\n case \"hotspot_wifi_permission_denied\":\n return \"ota:errorPhoneNearbyPermission\"\n case \"hotspot_wifi_disabled\":\n return \"ota:errorPhoneWifiOff\"\n case \"hotspot_location_denied\":\n return \"ota:errorMacLocation\"\n case \"hotspot_start_failed\":\n return \"ota:errorGlassesHotspotStart\"\n case \"hotspot_join_failed\":\n return os === \"ios\" ? \"ota:errorPhoneHotspotJoinIos\" : \"ota:errorPhoneHotspotJoin\"\n case \"hotspot_other_glasses\":\n return \"ota:errorPhoneOtherGlasses\"\n case \"hotspot_server_failed\":\n return \"ota:errorPhoneShareUpdate\"\n default:\n return OTA_ERROR_GENERIC_COPY_KEY\n }\n}\n\n/** English copy for every OTA error key above. Mirrored in the Mentra App's `ota` i18n namespace. */\nexport const OTA_ERROR_ENGLISH_COPY: Readonly<Record<string, string>> = {\n \"ota:errorDnsFailed\": \"Could not find the update server — retry, or check glasses Wi-Fi if this continues\",\n \"ota:errorConnectionFailed\": \"Could not connect to the update server — please retry\",\n \"ota:errorConnectTimeout\": \"The update server took too long to connect — please retry\",\n \"ota:errorDownloadTimeout\": \"The update stopped responding — please retry\",\n \"ota:errorHttpError\": \"The update server returned an error — retry later or contact support\",\n \"ota:errorDowngradeRecoveryDisabled\":\n \"The recovery service is disabled. Contact support to restore it before changing versions.\",\n \"ota:errorDowngradeRecoveryIncompatible\":\n \"The recovery service is incompatible. Contact support to restore it before changing versions.\",\n \"ota:errorDowngradeRecoveryUnavailable\":\n \"The recovery service is not ready. Wait a moment and retry; contact support if this continues.\",\n \"ota:errorDowngradeRecoveryBusy\":\n \"Another glasses recovery is still running. Keep your glasses nearby and retry after it finishes.\",\n \"ota:errorDowngradeStatusUnknown\":\n \"Still checking the version change on your glasses. Keep them nearby. Contact support if this continues.\",\n \"ota:errorDowngradeNotOwned\": \"The version change did not finish. Recovery has stopped; you can safely retry.\",\n \"ota:errorNoInternet\": \"Glasses Wi-Fi has no internet connection\",\n \"ota:errorClockSkew\": \"Glasses clock is wrong — syncing time from your phone, then retrying update check\",\n \"ota:errorSslError\": \"Secure connection failed — try a different Wi-Fi network\",\n \"ota:errorDownloadFailed\": \"The update could not be downloaded to your glasses. Please try again.\",\n \"ota:errorInsufficientStorage\": \"Not enough storage on your glasses — free up space before trying again\",\n \"ota:errorFirmwareTooLarge\": \"Firmware file is unexpectedly large — please contact support\",\n \"ota:errorFirmwareVerifyFailed\": \"Firmware verification failed — please try again or contact support\",\n \"ota:errorApkVerifyFailed\": \"Update verification failed — please try again or contact support\",\n \"ota:errorInstallFailed\": \"The update could not be installed on your glasses. Please try again.\",\n \"ota:errorApkRestartGuardNotPersisted\":\n \"Your glasses could not save the update before restarting. Restart your glasses and try again.\",\n \"ota:errorDowngradeHandoffRefused\":\n \"Your glasses could not start the version change. Restart your glasses and try again.\",\n \"ota:errorDowngradeHandoffFailed\":\n \"The recovery service on your glasses did not respond. Restart your glasses and try again.\",\n \"ota:errorDowngradeTransactionStalled\":\n \"The version change on your glasses did not finish. Restart your glasses and try again.\",\n \"ota:errorGlassesUnknown\": \"Something went wrong. Please try again.\",\n \"ota:errorGeneric\": \"Something went wrong. Please try again.\",\n \"ota:errorPhoneInternet\": \"Your phone could not connect to the internet. Check its connection and try again.\",\n \"ota:errorPhoneConnection\": \"Your phone could not reach the update server. Check its connection and try again.\",\n \"ota:errorPhoneDownloadServer\": \"The update server could not provide the download. Please try again later.\",\n \"ota:errorPhoneDownloadTimeout\": \"The update download took too long. Please try again.\",\n \"ota:errorPhoneStorage\": \"There is not enough space on your phone for the update. Free up space and try again.\",\n \"ota:errorPhoneSave\": \"Your phone could not save the update. Please try again.\",\n \"ota:errorPhoneSecureConnection\":\n \"Your phone could not make a secure connection to the update server. Please try again later.\",\n \"ota:errorPhoneDownload\": \"The update could not be downloaded to your phone. Please try again.\",\n \"ota:errorPhoneVerify\": \"The update file could not be verified. Please try again later.\",\n \"ota:errorPhoneNearbyPermission\": \"Allow nearby devices access so your phone can connect to your glasses.\",\n \"ota:errorPhoneWifiOff\": \"Turn on your phone’s Wi-Fi so it can connect to your glasses, then try again.\",\n \"ota:errorMacLocation\":\n \"This Mac needs Location access to find your glasses’ Wi-Fi. In System Settings, open Privacy & Security, turn on Location Services and allow Mentra, then try again.\",\n \"ota:errorGlassesHotspotStart\":\n \"Your glasses could not start the connection needed for the update. Please try again.\",\n \"ota:errorPhoneHotspotJoin\": \"Your phone could not connect to your glasses for the update. Please try again.\",\n \"ota:errorPhoneOtherGlasses\":\n \"Your phone reached another pair of glasses instead of yours. Move away from other glasses or turn them off, then try again.\",\n \"ota:errorPhoneHotspotJoinIos\":\n \"Your phone could not connect to your glasses for the update. Make sure your phone’s Wi-Fi is on, then try again.\",\n \"ota:errorPhoneShareUpdate\": \"Your phone could not send the update to your glasses. Please try again.\",\n \"ota:errorBesRestartRequired\": \"Restart your glasses to safely exit firmware update mode before trying again\",\n \"ota:errorBesNotStarted\": \"Your glasses could not start the firmware update. Keep them nearby and try again.\",\n \"ota:errorCode\": \"Error code: {{code}}\",\n}\n\nexport const BES_INSTALL_RESTART_MESSAGE = OTA_ERROR_ENGLISH_COPY[OTA_ERROR_BES_RESTART_REQUIRED_COPY_KEY]\n\n/**\n * Copy key for a glasses-reported failure code. Unknown codes get the generic\n * glasses-error copy; a missing code gets the plain generic copy.\n */\nexport function otaErrorCopyKey(error?: string | null): string {\n if (!error) return OTA_ERROR_GENERIC_COPY_KEY\n // Own-property lookup: a code that happens to name an inherited Object member\n // (\"constructor\", \"toString\", ...) is unknown, not a mapped key.\n return hasOwn(OTA_GLASSES_ERROR_COPY_KEYS, error)\n ? OTA_GLASSES_ERROR_COPY_KEYS[error]\n : OTA_ERROR_UNKNOWN_GLASSES_COPY_KEY\n}\n\nfunction hasOwn(table: Readonly<Record<string, string>>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(table, key)\n}\n\nfunction isDownloadPhaseSnapshot(\n otaStatus: OtaStatus | null | undefined,\n otaProgress: OtaProgress | null | undefined,\n): boolean {\n if (otaStatus?.phase === \"download\") {\n return true\n }\n if (otaProgress?.stage === \"download\") {\n return true\n }\n return false\n}\n\n/**\n * Offer Change WiFi whenever the OTA flow failed while the glasses were in the\n * download step (any download failure — network, SSL, size cap, verify, etc.).\n *\n * Also covers phone-side watchdog failures that fire while the store still shows\n * an active download phase (stall / global timeout mid-download).\n */\nexport function shouldShowChangeWifiForOtaDownloadFailure(\n otaStatus: OtaStatus | null | undefined,\n otaProgress: OtaProgress | null | undefined,\n localErrorMessage: string,\n): boolean {\n if (otaStatus?.error === \"insufficient_storage\" || otaProgress?.errorMessage === \"insufficient_storage\") {\n return false\n }\n if (otaStatus?.status === \"failed\" && otaStatus.phase === \"download\") {\n return true\n }\n if (otaProgress?.status === \"FAILED\" && otaProgress.stage === \"download\") {\n return true\n }\n if (localErrorMessage && isDownloadPhaseSnapshot(otaStatus, otaProgress)) {\n return true\n }\n return false\n}\n\n/** English message for a glasses-reported failure code. Never echoes the raw code. */\nexport function getOtaErrorMessage(error?: string | null): string {\n return OTA_ERROR_ENGLISH_COPY[otaErrorCopyKey(error)]\n}\n\n/**\n * Once a BES install has started, any failure conservatively requires a glasses restart, since a\n * generic failure or silence may mean BES entered its raw OTA parser. The one exception is the\n * glasses reporting `bes_not_started`: they never asked the BES to enter OTA mode, so a retry is\n * safe.\n */\nexport function shouldRequireGlassesRebootForBesFailure(\n otaStatus: OtaStatus | null | undefined,\n _otaProgress: OtaProgress | null | undefined,\n localErrorMessage: string,\n): boolean {\n if (otaStatus?.stepType !== \"bes\" || otaStatus.phase !== \"install\") {\n return false\n }\n if (otaStatus.status === \"failed\" && otaStatus.error === OTA_BES_NOT_STARTED_ERROR) {\n return false\n }\n return otaStatus.status === \"failed\" || Boolean(localErrorMessage)\n}\n"]}
|
|
@@ -67,6 +67,7 @@ declare class OtaInstallCoordinator {
|
|
|
67
67
|
private versionChangeTarget;
|
|
68
68
|
private versionChangeInstallStarted;
|
|
69
69
|
private versionChangeConverged;
|
|
70
|
+
private versionChangeAfterReboot;
|
|
70
71
|
private legacyApkSettleHold;
|
|
71
72
|
private mtkSimulatedPercent;
|
|
72
73
|
private lastRealMtkProgress;
|
|
@@ -204,6 +205,12 @@ declare class OtaInstallCoordinator {
|
|
|
204
205
|
*/
|
|
205
206
|
private handleLegacyInstallCompleteEdge;
|
|
206
207
|
private isBesRestartExpected;
|
|
208
|
+
/**
|
|
209
|
+
* Firmware pass of a downgrade whose glasses hand the pin off after the firmware reboot: note
|
|
210
|
+
* the staging, then treat the firmware's completion as the handoff point. From there the detour
|
|
211
|
+
* wait owns the reboot and reconnects, and completion is exact-version convergence.
|
|
212
|
+
*/
|
|
213
|
+
private runVersionChangeAfterRebootPass;
|
|
207
214
|
/** Complete only after a protocol-authorized BES restart traverses disconnect -> reconnect. */
|
|
208
215
|
private completeBesRestartRecovery;
|
|
209
216
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtaInstallCoordinator.d.ts","sourceRoot":"","sources":["../../src/services/OtaInstallCoordinator.ts"],"names":[],"mappings":"AAoBA,OAAqB,EAAC,KAAK,WAAW,EAAE,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAI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,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"}
|
|
@@ -153,6 +153,11 @@ class OtaInstallCoordinator {
|
|
|
153
153
|
versionChangeInstallStarted = false;
|
|
154
154
|
// Latched when a reconnect reports buildNumber === versionChangeTarget.
|
|
155
155
|
versionChangeConverged = false;
|
|
156
|
+
// Set when the glasses download the pin as the first step of a firmware pass: they hand it
|
|
157
|
+
// to recovery themselves after the firmware reboot (the detour only lands on the new MTK
|
|
158
|
+
// slot), so the firmware's completion starts the detour wait instead of ending the pass.
|
|
159
|
+
// Older glasses plan no apk step next to firmware in a downgrade and keep the two passes.
|
|
160
|
+
versionChangeAfterReboot = false;
|
|
156
161
|
// Holds a legacy apk install FINISHED out of "complete" for the settle window.
|
|
157
162
|
legacyApkSettleHold = false;
|
|
158
163
|
// Display-only legacy MTK install stall simulation.
|
|
@@ -473,6 +478,7 @@ class OtaInstallCoordinator {
|
|
|
473
478
|
besRestartRecovery: this.besRestartRecovery,
|
|
474
479
|
versionChangeConverged: this.versionChangeConverged,
|
|
475
480
|
versionChangeSession: this.versionChangeSession,
|
|
481
|
+
versionChangeAfterReboot: this.versionChangeAfterReboot && this.isInVersionChangeDetour(),
|
|
476
482
|
}),
|
|
477
483
|
errorMsg: this.errorMsg,
|
|
478
484
|
errorCopyKey: this.errorCopyKey,
|
|
@@ -561,6 +567,7 @@ class OtaInstallCoordinator {
|
|
|
561
567
|
this.versionChangeTarget = null;
|
|
562
568
|
this.versionChangeInstallStarted = false;
|
|
563
569
|
this.versionChangeConverged = false;
|
|
570
|
+
this.versionChangeAfterReboot = false;
|
|
564
571
|
this.legacyApkSettleHold = false;
|
|
565
572
|
this.mtkSimulatedPercent = null;
|
|
566
573
|
this.lastRealMtkProgress = 0;
|
|
@@ -739,7 +746,8 @@ class OtaInstallCoordinator {
|
|
|
739
746
|
this.handleLegacyInstallCompleteEdge(otaStatus);
|
|
740
747
|
}
|
|
741
748
|
const legacySession = this.isLegacySessionShapeNow();
|
|
742
|
-
|
|
749
|
+
this.runVersionChangeAfterRebootPass(otaStatus);
|
|
750
|
+
if (!this.isInVersionChangeDetour() && this.isBesRestartExpected(otaStatus, otaProgress, legacySession)) {
|
|
743
751
|
this.besRestartExpected = true;
|
|
744
752
|
}
|
|
745
753
|
// Port the legacy route's actual reboot invariant before deriving display
|
|
@@ -763,6 +771,7 @@ class OtaInstallCoordinator {
|
|
|
763
771
|
besRestartRecovery: this.besRestartRecovery,
|
|
764
772
|
versionChangeConverged: this.versionChangeConverged,
|
|
765
773
|
versionChangeSession: this.versionChangeSession,
|
|
774
|
+
versionChangeAfterReboot: this.versionChangeAfterReboot && this.isInVersionChangeDetour(),
|
|
766
775
|
});
|
|
767
776
|
if (otaStatusChanged && otaStatus?.status === "failed")
|
|
768
777
|
this.reportFailure("device_failed");
|
|
@@ -864,14 +873,18 @@ class OtaInstallCoordinator {
|
|
|
864
873
|
(otaStatus.error === "downgrade_not_owned" ||
|
|
865
874
|
otaStatus.error === "downgrade_handoff_refused" ||
|
|
866
875
|
otaStatus.error === "downgrade_handoff_failed" ||
|
|
867
|
-
otaStatus.error === "downgrade_transaction_stalled"
|
|
876
|
+
otaStatus.error === "downgrade_transaction_stalled" ||
|
|
877
|
+
// Before the post-reboot handoff any failure (a firmware step's included) means no
|
|
878
|
+
// transaction owns the detour; only the unknown status keeps waiting.
|
|
879
|
+
(this.versionChangeAfterReboot && otaStatus.error !== "downgrade_status_unknown"))) {
|
|
868
880
|
console.log(`[OTA_PROGRESS] version-change: no transaction owns the detour (${otaStatus.error}) — releasing latch`);
|
|
869
881
|
this.versionChangeInstallStarted = false;
|
|
870
882
|
this.emitInternalChange();
|
|
871
883
|
}
|
|
872
|
-
// Version-change convergence: the reconnected glasses report
|
|
873
|
-
//
|
|
874
|
-
//
|
|
884
|
+
// Version-change convergence: the reconnected glasses report the pinned target. This is
|
|
885
|
+
// the ONLY completion signal for a downgrade (lower build, no increase, wiped session).
|
|
886
|
+
// A build above the pin but below the one the session started from also converges: an
|
|
887
|
+
// older service app can update itself over Wi-Fi seconds after the pin starts.
|
|
875
888
|
if (this.versionChangeSession &&
|
|
876
889
|
this.versionChangeInstallStarted &&
|
|
877
890
|
!this.versionChangeConverged &&
|
|
@@ -879,7 +892,10 @@ class OtaInstallCoordinator {
|
|
|
879
892
|
buildNumberChanged &&
|
|
880
893
|
buildNumber) {
|
|
881
894
|
const currentBuild = Number.parseInt(buildNumber, 10);
|
|
882
|
-
|
|
895
|
+
const startBuild = Number.parseInt(this.initialBuildNumber ?? "", 10);
|
|
896
|
+
const reached = currentBuild === this.versionChangeTarget ||
|
|
897
|
+
(currentBuild > this.versionChangeTarget && Number.isFinite(startBuild) && currentBuild < startBuild);
|
|
898
|
+
if (Number.isFinite(currentBuild) && reached) {
|
|
883
899
|
console.log(`[OTA_PROGRESS] version-change converged: glasses report target ${currentBuild}, completing`);
|
|
884
900
|
this.clearPerStepTimers();
|
|
885
901
|
this.clearGlobalTimeout();
|
|
@@ -955,8 +971,9 @@ class OtaInstallCoordinator {
|
|
|
955
971
|
}, pingIntervalMs);
|
|
956
972
|
}
|
|
957
973
|
}
|
|
958
|
-
// Any glasses activity proves the logical ota_start was accepted.
|
|
959
|
-
|
|
974
|
+
// Any glasses activity proves the logical ota_start was accepted. An idle reply does not:
|
|
975
|
+
// a hotspot start still joining has sent the glasses nothing yet.
|
|
976
|
+
if ((otaStatusChanged || otaProgressChanged) && hasRecoveringOtaReply(otaStatus, otaProgress)) {
|
|
960
977
|
this.onFirstActivity();
|
|
961
978
|
}
|
|
962
979
|
// The stuck-at-zero watchdog clears only on real byte or percent progress.
|
|
@@ -1217,6 +1234,33 @@ class OtaInstallCoordinator {
|
|
|
1217
1234
|
(otaProgress.status === "STARTED" || otaProgress.status === "PROGRESS")));
|
|
1218
1235
|
return statusReadyToRestart || progressReadyToRestart || legacyInstallInProgress;
|
|
1219
1236
|
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Firmware pass of a downgrade whose glasses hand the pin off after the firmware reboot: note
|
|
1239
|
+
* the staging, then treat the firmware's completion as the handoff point. From there the detour
|
|
1240
|
+
* wait owns the reboot and reconnects, and completion is exact-version convergence.
|
|
1241
|
+
*/
|
|
1242
|
+
runVersionChangeAfterRebootPass(otaStatus) {
|
|
1243
|
+
if (!this.versionChangeSession || this.versionChangeInstallStarted)
|
|
1244
|
+
return;
|
|
1245
|
+
if (this.otaStartOwnership?.outcome !== "acknowledged" || !otaStatus)
|
|
1246
|
+
return;
|
|
1247
|
+
if (otaStatus.stepType === "apk" && otaStatus.phase === "download" && otaStatus.totalSteps > 1) {
|
|
1248
|
+
if (!this.versionChangeAfterReboot) {
|
|
1249
|
+
console.log("[OTA_PROGRESS] version-change: glasses stage the pin for after their firmware reboot");
|
|
1250
|
+
this.versionChangeAfterReboot = true;
|
|
1251
|
+
}
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
const firmwareDone = otaStatus.phase === "install" &&
|
|
1255
|
+
((otaStatus.stepType === "bes" && (otaStatus.status === "step_complete" || otaStatus.status === "complete")) ||
|
|
1256
|
+
(otaStatus.stepType === "mtk" && otaStatus.status === "complete"));
|
|
1257
|
+
if (!this.versionChangeAfterReboot || !firmwareDone)
|
|
1258
|
+
return;
|
|
1259
|
+
console.log("[OTA_PROGRESS] version-change: firmware done — entering detour wait across its reboot");
|
|
1260
|
+
this.versionChangeInstallStarted = true;
|
|
1261
|
+
this.otaStartOwnership.versionChangeTarget = this.versionChangeTarget ?? undefined;
|
|
1262
|
+
this.emitInternalChange();
|
|
1263
|
+
}
|
|
1220
1264
|
/** Complete only after a protocol-authorized BES restart traverses disconnect -> reconnect. */
|
|
1221
1265
|
completeBesRestartRecovery() {
|
|
1222
1266
|
if (!this.besRestartDisconnectObserved || this.besRestartRecovery !== "awaiting")
|
|
@@ -1293,6 +1337,7 @@ class OtaInstallCoordinator {
|
|
|
1293
1337
|
besRestartRecovery: this.besRestartRecovery,
|
|
1294
1338
|
versionChangeConverged: this.versionChangeConverged,
|
|
1295
1339
|
versionChangeSession: this.versionChangeSession,
|
|
1340
|
+
versionChangeAfterReboot: this.versionChangeAfterReboot && this.isInVersionChangeDetour(),
|
|
1296
1341
|
});
|
|
1297
1342
|
}
|
|
1298
1343
|
/**
|
|
@@ -1519,7 +1564,14 @@ class OtaInstallCoordinator {
|
|
|
1519
1564
|
ownership.outcome = "rejected";
|
|
1520
1565
|
this.clearStuckTimeout();
|
|
1521
1566
|
this.reportFailure("hotspot_preflight_failed", err instanceof OtaArtifactError ? err.failure : undefined);
|
|
1522
|
-
|
|
1567
|
+
// Unconfirmed cleanup stays with the transport, which retries it on the next attempt;
|
|
1568
|
+
// it must not leave the screen on "starting" without the error.
|
|
1569
|
+
try {
|
|
1570
|
+
await this.teardownHotspotTransport();
|
|
1571
|
+
}
|
|
1572
|
+
catch (cleanupError) {
|
|
1573
|
+
console.warn("[OTA_PROGRESS] hotspot cleanup failed", cleanupError);
|
|
1574
|
+
}
|
|
1523
1575
|
if (!isCurrentAttempt())
|
|
1524
1576
|
return;
|
|
1525
1577
|
if (this.attached) {
|