@mentra/engine 0.1.0-beta.0 → 0.1.0-dev.1
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 +42 -1
- package/build/engine.d.ts +11 -3
- package/build/engine.d.ts.map +1 -1
- package/build/engine.js +7 -2
- package/build/engine.js.map +1 -1
- package/build/facades/dev.d.ts.map +1 -1
- package/build/facades/dev.js +9 -5
- package/build/facades/dev.js.map +1 -1
- package/build/facades/gallery.js +1 -1
- package/build/facades/gallery.js.map +1 -1
- package/build/facades/glasses.d.ts +1 -0
- package/build/facades/glasses.d.ts.map +1 -1
- package/build/facades/glasses.js +19 -4
- package/build/facades/glasses.js.map +1 -1
- package/build/facades/glassesSettings.d.ts.map +1 -1
- package/build/facades/glassesSettings.js +1 -0
- package/build/facades/glassesSettings.js.map +1 -1
- package/build/facades/miniapps.d.ts +4 -0
- package/build/facades/miniapps.d.ts.map +1 -1
- package/build/facades/miniapps.js +5 -0
- package/build/facades/miniapps.js.map +1 -1
- package/build/facades/ota.d.ts +11 -2
- package/build/facades/ota.d.ts.map +1 -1
- package/build/facades/ota.js +19 -4
- 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 +10 -8
- package/build/facades/pairing.js.map +1 -1
- package/build/facades/phoneNotifications.d.ts +0 -4
- package/build/facades/phoneNotifications.d.ts.map +1 -1
- package/build/facades/phoneNotifications.js +4 -14
- package/build/facades/phoneNotifications.js.map +1 -1
- package/build/index.d.ts +6 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/internal.d.ts +2 -2
- package/build/internal.d.ts.map +1 -1
- package/build/internal.js +1 -1
- package/build/internal.js.map +1 -1
- package/build/react/MentraLiveOtaFlow.d.ts +38 -0
- package/build/react/MentraLiveOtaFlow.d.ts.map +1 -0
- package/build/react/MentraLiveOtaFlow.js +528 -0
- package/build/react/MentraLiveOtaFlow.js.map +1 -0
- package/build/react/index.d.ts +2 -0
- package/build/react/index.d.ts.map +1 -0
- package/build/react/index.js +2 -0
- package/build/react/index.js.map +1 -0
- package/build/react/useEngineSnapshot.d.ts +2 -0
- package/build/react/useEngineSnapshot.d.ts.map +1 -0
- package/build/react/useEngineSnapshot.js +14 -0
- package/build/react/useEngineSnapshot.js.map +1 -0
- package/build/runtime/bootstrap.d.ts +24 -1
- package/build/runtime/bootstrap.d.ts.map +1 -1
- package/build/runtime/bootstrap.js +17 -0
- package/build/runtime/bootstrap.js.map +1 -1
- package/build/runtime/scanQrSeam.d.ts +7 -0
- package/build/runtime/scanQrSeam.d.ts.map +1 -0
- package/build/runtime/scanQrSeam.js +16 -0
- package/build/runtime/scanQrSeam.js.map +1 -0
- package/build/services/AppRegistry.d.ts +18 -8
- package/build/services/AppRegistry.d.ts.map +1 -1
- package/build/services/AppRegistry.js +44 -45
- package/build/services/AppRegistry.js.map +1 -1
- package/build/services/AudioCloudUplink.d.ts +9 -3
- package/build/services/AudioCloudUplink.d.ts.map +1 -1
- package/build/services/AudioCloudUplink.js +9 -3
- package/build/services/AudioCloudUplink.js.map +1 -1
- package/build/services/AudioPlaybackService.d.ts +9 -1
- package/build/services/AudioPlaybackService.d.ts.map +1 -1
- package/build/services/AudioPlaybackService.js +77 -32
- package/build/services/AudioPlaybackService.js.map +1 -1
- package/build/services/BlobStore.d.ts +2 -1
- package/build/services/BlobStore.d.ts.map +1 -1
- package/build/services/BlobStore.js +17 -9
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/CloudAudioSubscriptionSync.d.ts.map +1 -1
- package/build/services/CloudAudioSubscriptionSync.js +13 -1
- package/build/services/CloudAudioSubscriptionSync.js.map +1 -1
- package/build/services/CloudClientService.d.ts +15 -0
- package/build/services/CloudClientService.d.ts.map +1 -1
- package/build/services/CloudClientService.js +75 -0
- package/build/services/CloudClientService.js.map +1 -1
- package/build/services/ForegroundLocationPermission.d.ts +13 -0
- package/build/services/ForegroundLocationPermission.d.ts.map +1 -0
- package/build/services/ForegroundLocationPermission.js +12 -0
- package/build/services/ForegroundLocationPermission.js.map +1 -0
- package/build/services/GlassesSettingsSync.d.ts.map +1 -1
- package/build/services/GlassesSettingsSync.js +9 -3
- package/build/services/GlassesSettingsSync.js.map +1 -1
- package/build/services/GlassesStatusProjection.d.ts +2 -1
- package/build/services/GlassesStatusProjection.d.ts.map +1 -1
- package/build/services/GlassesStatusProjection.js +15 -8
- package/build/services/GlassesStatusProjection.js.map +1 -1
- package/build/services/HotspotOtaTransport.d.ts +29 -0
- package/build/services/HotspotOtaTransport.d.ts.map +1 -0
- package/build/services/HotspotOtaTransport.js +146 -0
- package/build/services/HotspotOtaTransport.js.map +1 -0
- package/build/services/HotspotShutdown.d.ts +17 -0
- package/build/services/HotspotShutdown.d.ts.map +1 -0
- package/build/services/HotspotShutdown.js +29 -0
- package/build/services/HotspotShutdown.js.map +1 -0
- package/build/services/LocalDisplayManager.d.ts +15 -0
- package/build/services/LocalDisplayManager.d.ts.map +1 -1
- package/build/services/LocalDisplayManager.js +106 -20
- package/build/services/LocalDisplayManager.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +67 -1
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +486 -126
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/LocalMiniappStorage.d.ts +32 -0
- package/build/services/LocalMiniappStorage.d.ts.map +1 -0
- package/build/services/LocalMiniappStorage.js +66 -0
- package/build/services/LocalMiniappStorage.js.map +1 -0
- package/build/services/LocalMiniappUserIdentity.d.ts +20 -0
- package/build/services/LocalMiniappUserIdentity.d.ts.map +1 -0
- package/build/services/LocalMiniappUserIdentity.js +43 -0
- package/build/services/LocalMiniappUserIdentity.js.map +1 -0
- package/build/services/MicStateCoordinator.d.ts +42 -1
- package/build/services/MicStateCoordinator.d.ts.map +1 -1
- package/build/services/MicStateCoordinator.js +141 -3
- package/build/services/MicStateCoordinator.js.map +1 -1
- package/build/services/MiniappLauncher.d.ts.map +1 -1
- package/build/services/MiniappLauncher.js +23 -3
- package/build/services/MiniappLauncher.js.map +1 -1
- package/build/services/MiniappLiveness.d.ts +12 -0
- package/build/services/MiniappLiveness.d.ts.map +1 -0
- package/build/services/MiniappLiveness.js +16 -0
- package/build/services/MiniappLiveness.js.map +1 -0
- package/build/services/OtaArtifactDownloader.d.ts +65 -0
- package/build/services/OtaArtifactDownloader.d.ts.map +1 -0
- package/build/services/OtaArtifactDownloader.js +226 -0
- package/build/services/OtaArtifactDownloader.js.map +1 -0
- package/build/services/OtaAutoChain.d.ts +34 -0
- package/build/services/OtaAutoChain.d.ts.map +1 -0
- package/build/services/OtaAutoChain.js +83 -0
- package/build/services/OtaAutoChain.js.map +1 -0
- package/build/services/OtaErrorMapping.d.ts +18 -0
- package/build/services/OtaErrorMapping.d.ts.map +1 -0
- package/build/services/OtaErrorMapping.js +63 -0
- package/build/services/OtaErrorMapping.js.map +1 -0
- package/build/services/OtaInstallCoordinator.d.ts +94 -14
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +574 -130
- package/build/services/OtaInstallCoordinator.js.map +1 -1
- package/build/services/OtaService.d.ts.map +1 -1
- package/build/services/OtaService.js +8 -1
- package/build/services/OtaService.js.map +1 -1
- package/build/services/OtaUpdateCheckService.d.ts +38 -3
- package/build/services/OtaUpdateCheckService.d.ts.map +1 -1
- package/build/services/OtaUpdateCheckService.js +142 -22
- package/build/services/OtaUpdateCheckService.js.map +1 -1
- package/build/services/PhoneCalendarService.d.ts.map +1 -1
- package/build/services/PhoneCalendarService.js +22 -1
- package/build/services/PhoneCalendarService.js.map +1 -1
- package/build/services/PhoneCameraFovCoordinator.d.ts +2 -0
- package/build/services/PhoneCameraFovCoordinator.d.ts.map +1 -1
- package/build/services/PhoneCameraFovCoordinator.js +14 -0
- package/build/services/PhoneCameraFovCoordinator.js.map +1 -1
- package/build/services/PhoneNotificationsSync.d.ts.map +1 -1
- package/build/services/PhoneNotificationsSync.js +12 -10
- package/build/services/PhoneNotificationsSync.js.map +1 -1
- package/build/services/PhonePhotoCoordinator.d.ts +10 -3
- package/build/services/PhonePhotoCoordinator.d.ts.map +1 -1
- package/build/services/PhonePhotoCoordinator.js +21 -3
- package/build/services/PhonePhotoCoordinator.js.map +1 -1
- package/build/services/PhoneStreamCoordinator.d.ts +8 -1
- package/build/services/PhoneStreamCoordinator.d.ts.map +1 -1
- package/build/services/PhoneStreamCoordinator.js +125 -13
- package/build/services/PhoneStreamCoordinator.js.map +1 -1
- package/build/services/PhoneVideoCoordinator.d.ts +2 -0
- package/build/services/PhoneVideoCoordinator.d.ts.map +1 -1
- package/build/services/PhoneVideoCoordinator.js +10 -0
- package/build/services/PhoneVideoCoordinator.js.map +1 -1
- package/build/services/SceneRenderer.d.ts.map +1 -1
- package/build/services/SceneRenderer.js +15 -0
- package/build/services/SceneRenderer.js.map +1 -1
- package/build/services/SupportProfileSync.d.ts +22 -0
- package/build/services/SupportProfileSync.d.ts.map +1 -0
- package/build/services/SupportProfileSync.js +213 -0
- package/build/services/SupportProfileSync.js.map +1 -0
- package/build/services/TtsTextSanitizer.d.ts +5 -0
- package/build/services/TtsTextSanitizer.d.ts.map +1 -0
- package/build/services/TtsTextSanitizer.js +61 -0
- package/build/services/TtsTextSanitizer.js.map +1 -0
- package/build/services/WifiAdbRequest.d.ts +17 -0
- package/build/services/WifiAdbRequest.d.ts.map +1 -0
- package/build/services/WifiAdbRequest.js +35 -0
- package/build/services/WifiAdbRequest.js.map +1 -0
- package/build/services/asg/asgCameraApi.d.ts +3 -0
- package/build/services/asg/asgCameraApi.d.ts.map +1 -1
- package/build/services/asg/asgCameraApi.js +72 -2
- package/build/services/asg/asgCameraApi.js.map +1 -1
- package/build/services/asg/gallerySyncService.d.ts.map +1 -1
- package/build/services/asg/gallerySyncService.js +26 -14
- package/build/services/asg/gallerySyncService.js.map +1 -1
- package/build/services/asg/localNetworkTransport.d.ts +2 -2
- package/build/services/asg/localNetworkTransport.d.ts.map +1 -1
- package/build/services/asg/localNetworkTransport.js +6 -6
- package/build/services/asg/localNetworkTransport.js.map +1 -1
- package/build/services/audioPlaybackAssets.d.ts +8 -0
- package/build/services/audioPlaybackAssets.d.ts.map +1 -0
- package/build/services/audioPlaybackAssets.js +7 -0
- package/build/services/audioPlaybackAssets.js.map +1 -0
- package/build/services/glassesClockSync.js +2 -2
- package/build/services/glassesClockSync.js.map +1 -1
- package/build/services/manifestActions.d.ts +7 -0
- package/build/services/manifestActions.d.ts.map +1 -0
- package/build/services/manifestActions.js +25 -0
- package/build/services/manifestActions.js.map +1 -0
- package/build/services/otaDisplayState.d.ts +22 -11
- package/build/services/otaDisplayState.d.ts.map +1 -1
- package/build/services/otaDisplayState.js +36 -14
- package/build/services/otaDisplayState.js.map +1 -1
- package/build/services/otaInstallPolicy.d.ts +15 -3
- package/build/services/otaInstallPolicy.d.ts.map +1 -1
- package/build/services/otaInstallPolicy.js +24 -3
- package/build/services/otaInstallPolicy.js.map +1 -1
- package/build/services/otaManifestUrl.d.ts +2 -0
- package/build/services/otaManifestUrl.d.ts.map +1 -0
- package/build/services/{asgOtaVersionUrl.js → otaManifestUrl.js} +15 -5
- package/build/services/otaManifestUrl.js.map +1 -0
- package/build/services/slimStreamStatus.d.ts +11 -0
- package/build/services/slimStreamStatus.d.ts.map +1 -1
- package/build/services/slimStreamStatus.js +14 -4
- package/build/services/slimStreamStatus.js.map +1 -1
- package/build/stores/apps.d.ts.map +1 -1
- package/build/stores/apps.js +11 -0
- package/build/stores/apps.js.map +1 -1
- package/build/stores/bluetoothSettingKeys.d.ts.map +1 -1
- package/build/stores/bluetoothSettingKeys.js +2 -0
- package/build/stores/bluetoothSettingKeys.js.map +1 -1
- package/build/stores/gallerySync.d.ts +2 -0
- package/build/stores/gallerySync.d.ts.map +1 -1
- package/build/stores/gallerySync.js +2 -0
- package/build/stores/gallerySync.js.map +1 -1
- package/build/stores/glasses.d.ts.map +1 -1
- package/build/stores/glasses.js +3 -0
- package/build/stores/glasses.js.map +1 -1
- package/build/stores/settings.d.ts +17 -0
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +152 -19
- package/build/stores/settings.js.map +1 -1
- package/build/types/applet.d.ts +2 -0
- package/build/types/applet.d.ts.map +1 -1
- package/build/types/applet.js.map +1 -1
- package/build/types/enums.d.ts +1 -0
- package/build/types/enums.d.ts.map +1 -1
- package/build/types/enums.js +1 -0
- package/build/types/enums.js.map +1 -1
- package/build/types/hardware.d.ts +1 -0
- package/build/types/hardware.d.ts.map +1 -1
- package/build/types/hardware.js +14 -0
- package/build/types/hardware.js.map +1 -1
- package/build/utils/configuredDevHost.d.ts +6 -0
- package/build/utils/configuredDevHost.d.ts.map +1 -0
- package/build/utils/configuredDevHost.js +19 -0
- package/build/utils/configuredDevHost.js.map +1 -0
- package/build/utils/devMiniappLaunch.d.ts +19 -8
- package/build/utils/devMiniappLaunch.d.ts.map +1 -1
- package/build/utils/devMiniappLaunch.js +144 -21
- package/build/utils/devMiniappLaunch.js.map +1 -1
- package/build/utils/diagnosticContext.d.ts.map +1 -1
- package/build/utils/diagnosticContext.js +15 -17
- package/build/utils/diagnosticContext.js.map +1 -1
- package/build/utils/hardware/hardware.d.ts.map +1 -1
- package/build/utils/hardware/hardware.js +7 -3
- package/build/utils/hardware/hardware.js.map +1 -1
- package/build/utils/miniappDiagnostics.d.ts +64 -0
- package/build/utils/miniappDiagnostics.d.ts.map +1 -0
- package/build/utils/miniappDiagnostics.js +173 -0
- package/build/utils/miniappDiagnostics.js.map +1 -0
- package/build/utils/timers/timers.d.ts.map +1 -1
- package/build/utils/timers/timers.js +55 -18
- package/build/utils/timers/timers.js.map +1 -1
- package/package.json +27 -18
- package/src/assets/silence.wav +0 -0
- package/src/engine.ts +7 -2
- package/src/facades/dev.ts +9 -5
- package/src/facades/gallery.ts +1 -1
- package/src/facades/glasses.ts +17 -4
- package/src/facades/glassesSettings.ts +5 -0
- package/src/facades/miniapps.ts +7 -0
- package/src/facades/ota.ts +19 -4
- package/src/facades/pairing.ts +11 -7
- package/src/facades/phoneNotifications.ts +4 -13
- package/src/index.ts +26 -2
- package/src/internal.ts +2 -1
- package/src/react/MentraLiveOtaFlow.tsx +856 -0
- package/src/react/index.ts +7 -0
- package/src/react/useEngineSnapshot.ts +16 -0
- package/src/runtime/bootstrap.ts +33 -1
- package/src/runtime/scanQrSeam.ts +20 -0
- package/src/services/AppRegistry.ts +72 -48
- package/src/services/AudioCloudUplink.ts +9 -3
- package/src/services/AudioPlaybackService.ts +94 -34
- package/src/services/BlobStore.ts +22 -9
- package/src/services/CloudAudioSubscriptionSync.ts +13 -1
- package/src/services/CloudClientService.ts +74 -0
- package/src/services/ForegroundLocationPermission.ts +24 -0
- package/src/services/GlassesSettingsSync.ts +9 -3
- package/src/services/GlassesStatusProjection.ts +16 -8
- package/src/services/HotspotOtaTransport.ts +184 -0
- package/src/services/HotspotShutdown.ts +41 -0
- package/src/services/LocalDisplayManager.ts +112 -21
- package/src/services/LocalMiniappRuntime.ts +576 -130
- package/src/services/LocalMiniappStorage.ts +82 -0
- package/src/services/LocalMiniappUserIdentity.ts +46 -0
- package/src/services/MicStateCoordinator.ts +169 -4
- package/src/services/MiniappLauncher.ts +30 -3
- package/src/services/MiniappLiveness.ts +24 -0
- package/src/services/OtaArtifactDownloader.ts +312 -0
- package/src/services/OtaAutoChain.ts +106 -0
- package/src/services/OtaErrorMapping.ts +80 -0
- package/src/services/OtaInstallCoordinator.ts +645 -143
- package/src/services/OtaService.ts +11 -5
- package/src/services/OtaUpdateCheckService.ts +180 -20
- package/src/services/PhoneCalendarService.ts +27 -4
- package/src/services/PhoneCameraFovCoordinator.ts +15 -0
- package/src/services/PhoneNotificationsSync.ts +12 -10
- package/src/services/PhonePhotoCoordinator.ts +33 -7
- package/src/services/PhoneStreamCoordinator.ts +139 -25
- package/src/services/PhoneVideoCoordinator.ts +11 -0
- package/src/services/SceneRenderer.ts +16 -0
- package/src/services/SupportProfileSync.ts +218 -0
- package/src/services/TtsTextSanitizer.ts +66 -0
- package/src/services/WifiAdbRequest.ts +53 -0
- package/src/services/asg/asgCameraApi.ts +99 -8
- package/src/services/asg/gallerySyncService.ts +28 -19
- package/src/services/asg/localNetworkTransport.ts +7 -11
- package/src/services/audioPlaybackAssets.ts +8 -0
- package/src/services/glassesClockSync.ts +2 -2
- package/src/services/manifestActions.ts +30 -0
- package/src/services/otaDisplayState.ts +57 -16
- package/src/services/otaInstallPolicy.ts +29 -3
- package/src/services/{asgOtaVersionUrl.ts → otaManifestUrl.ts} +16 -4
- package/src/services/slimStreamStatus.ts +16 -5
- package/src/stores/apps.ts +12 -0
- package/src/stores/bluetoothSettingKeys.ts +2 -0
- package/src/stores/gallerySync.ts +4 -0
- package/src/stores/glasses.ts +3 -0
- package/src/stores/settings.ts +174 -21
- package/src/types/applet.ts +2 -0
- package/src/types/enums.ts +2 -1
- package/src/types/hardware.ts +17 -0
- package/src/utils/configuredDevHost.ts +17 -0
- package/src/utils/devMiniappLaunch.ts +151 -23
- package/src/utils/diagnosticContext.ts +17 -17
- package/src/utils/hardware/hardware.ts +7 -9
- package/src/utils/miniappDiagnostics.ts +226 -0
- package/src/utils/timers/timers.ts +57 -21
- package/build/services/asgOtaVersionUrl.d.ts +0 -2
- package/build/services/asgOtaVersionUrl.d.ts.map +0 -1
- package/build/services/asgOtaVersionUrl.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as RNFS from "@dr.pogodin/react-native-fs";
|
|
2
2
|
type DownloadOptions = Parameters<typeof RNFS.downloadFile>[0];
|
|
3
3
|
type DownloadHandle = ReturnType<typeof RNFS.downloadFile>;
|
|
4
|
-
export declare function shouldUseScopedLocalNetwork(os: string,
|
|
4
|
+
export declare function shouldUseScopedLocalNetwork(os: string, moduleAvailable: boolean): boolean;
|
|
5
5
|
export declare const localNetworkTransport: {
|
|
6
6
|
supportsScopedConnection: () => boolean;
|
|
7
7
|
isScopedConnectionActive: () => boolean;
|
|
8
|
-
connect(ssid: string, password: string): Promise<
|
|
8
|
+
connect(ssid: string, password: string): Promise<string | undefined>;
|
|
9
9
|
disconnect(): Promise<void>;
|
|
10
10
|
fetch(url: string | URL | Request, init?: RequestInit, timeoutMs?: number): Promise<Response>;
|
|
11
11
|
downloadFile(options: DownloadOptions): DownloadHandle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localNetworkTransport.d.ts","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AAMnD,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAA;AAO1D,wBAAgB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"localNetworkTransport.d.ts","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AAMnD,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,CAAA;AAO1D,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,OAAO,CAEzF;AAuBD,eAAO,MAAM,qBAAqB;oCACF,OAAO;oCACP,OAAO;kBAEjB,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;kBAYtD,OAAO,CAAC,IAAI,CAAC;eAQhB,MAAM,GAAG,GAAG,GAAG,OAAO,SAAS,WAAW,uBAAuB,OAAO,CAAC,QAAQ,CAAC;0BA8B7E,eAAe,GAAG,cAAc;wBA6DlC,MAAM,GAAG,IAAI;CASlC,CAAA"}
|
|
@@ -7,12 +7,11 @@ let scopedConnectionActive = false;
|
|
|
7
7
|
let nextJobId = 1_000_000;
|
|
8
8
|
const nativeJobs = new Map();
|
|
9
9
|
const cancelledNativeJobs = new Set();
|
|
10
|
-
export function shouldUseScopedLocalNetwork(os,
|
|
11
|
-
|
|
12
|
-
return os === "android" && level >= 29 && moduleAvailable;
|
|
10
|
+
export function shouldUseScopedLocalNetwork(os, moduleAvailable) {
|
|
11
|
+
return os === "android" && moduleAvailable;
|
|
13
12
|
}
|
|
14
13
|
function supportsScopedConnection() {
|
|
15
|
-
return shouldUseScopedLocalNetwork(Platform.OS,
|
|
14
|
+
return shouldUseScopedLocalNetwork(Platform.OS, MentraLocalNetwork != null);
|
|
16
15
|
}
|
|
17
16
|
function normalizeHeaders(headers) {
|
|
18
17
|
if (!headers)
|
|
@@ -39,10 +38,11 @@ export const localNetworkTransport = {
|
|
|
39
38
|
nativeJobs.clear();
|
|
40
39
|
if (!supportsScopedConnection()) {
|
|
41
40
|
await WifiManager.connectToProtectedSSID(ssid, password, false, false);
|
|
42
|
-
return;
|
|
41
|
+
return undefined;
|
|
43
42
|
}
|
|
44
|
-
await MentraLocalNetwork.connect(ssid, password);
|
|
43
|
+
const result = await MentraLocalNetwork.connect(ssid, password);
|
|
45
44
|
scopedConnectionActive = true;
|
|
45
|
+
return result.localAddress;
|
|
46
46
|
},
|
|
47
47
|
async disconnect() {
|
|
48
48
|
if (supportsScopedConnection()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localNetworkTransport.js","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AACnD,OAAO,EAAC,kBAAkB,EAAoC,MAAM,gCAAgC,CAAA;AACpG,OAAO,EAAC,MAAM,EAAC,MAAM,Q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AAC,UAAU;gBAC7B,YAAY,EAAE,MAAM,CAAC,YAAY;aAClC,CAAA;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,IAAI,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;YACrE,MAAM,KAAK,CAAA;QACb,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACxB,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACjC,YAAY,CAAC,MAAM,EAAE,CAAA;QACvB,CAAC,CAAC,CAAA;QAEJ,OAAO,EAAC,KAAK,EAAE,OAAO,EAAmB,CAAA;IAC3C,CAAC;IAED,YAAY,CAAC,KAAa;QACxB,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACtC,IAAI,QAAQ,IAAI,kBAAkB,EAAE,CAAC;YACnC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YAC9B,KAAK,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACxC,OAAM;QACR,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;CACF,CAAA;AAED,kBAAkB,EAAE,WAAW,CAAC,aAAa,EAAE,GAAG,EAAE;IAClD,sBAAsB,GAAG,KAAK,CAAA;IAC9B,UAAU,CAAC,KAAK,EAAE,CAAA;AACpB,CAAC,CAAC,CAAA","sourcesContent":["import * as RNFS from \"@dr.pogodin/react-native-fs\"\nimport {MentraLocalNetwork, type LocalNetworkDownloadProgress} from \"@mentra/bluetooth-sdk/internal\"\nimport {Buffer} from \"buffer\"\nimport {Platform} from \"react-native\"\nimport WifiManager from \"react-native-wifi-reborn\"\n\ntype DownloadOptions = Parameters<typeof RNFS.downloadFile>[0]\ntype DownloadHandle = ReturnType<typeof RNFS.downloadFile>\n\nlet scopedConnectionActive = false\nlet nextJobId = 1_000_000\nconst nativeJobs = new Map<number, string>()\nconst cancelledNativeJobs = new Set<number>()\n\nexport function shouldUseScopedLocalNetwork(\n os: string,\n platformVersion: number | string,\n moduleAvailable: boolean,\n): boolean {\n const level = typeof platformVersion === \"number\" ? platformVersion : Number.parseInt(platformVersion, 10)\n return os === \"android\" && level >= 29 && moduleAvailable\n}\n\nfunction supportsScopedConnection(): boolean {\n return shouldUseScopedLocalNetwork(Platform.OS, Platform.Version, MentraLocalNetwork != null)\n}\n\nfunction normalizeHeaders(headers?: HeadersInit): Record<string, string> {\n if (!headers) return {}\n if (headers instanceof Headers) {\n const result: Record<string, string> = {}\n headers.forEach((value, key) => {\n result[key] = value\n })\n return result\n }\n if (Array.isArray(headers)) return Object.fromEntries(headers)\n return {...headers}\n}\n\nfunction requestId(prefix: string): string {\n return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2)}`\n}\n\nexport const localNetworkTransport = {\n supportsScopedConnection: (): boolean => supportsScopedConnection(),\n isScopedConnectionActive: (): boolean => scopedConnectionActive,\n\n async connect(ssid: string, password: string): Promise<void> {\n scopedConnectionActive = false\n nativeJobs.clear()\n if (!supportsScopedConnection()) {\n await WifiManager.connectToProtectedSSID(ssid, password, false, false)\n return\n }\n await MentraLocalNetwork!.connect(ssid, password)\n scopedConnectionActive = true\n },\n\n async disconnect(): Promise<void> {\n if (supportsScopedConnection()) {\n await MentraLocalNetwork!.disconnect().catch(() => {})\n }\n scopedConnectionActive = false\n nativeJobs.clear()\n },\n\n async fetch(url: string | URL | Request, init?: RequestInit, timeoutMs = 30_000): Promise<Response> {\n if (!scopedConnectionActive || !MentraLocalNetwork || typeof url !== \"string\") {\n return globalThis.fetch(url, init)\n }\n\n const nativeModule = MentraLocalNetwork\n const id = requestId(\"request\")\n const signal = init?.signal\n const cancel = () => void nativeModule.cancel(id)\n if (signal?.aborted) throw new Error(\"Request aborted\")\n signal?.addEventListener(\"abort\", cancel, {once: true})\n try {\n const result = await nativeModule.request(\n id,\n url,\n init?.method || \"GET\",\n normalizeHeaders(init?.headers),\n typeof init?.body === \"string\" ? init.body : null,\n timeoutMs,\n )\n const bytes = Buffer.from(result.bodyBase64, \"base64\")\n return new Response(bytes as unknown as BodyInit, {\n status: result.status,\n headers: result.headers,\n })\n } finally {\n signal?.removeEventListener(\"abort\", cancel)\n }\n },\n\n downloadFile(options: DownloadOptions): DownloadHandle {\n if (!scopedConnectionActive || !MentraLocalNetwork) return RNFS.downloadFile(options)\n\n const jobId = nextJobId++\n const id = requestId(\"download\")\n let began = false\n nativeJobs.set(jobId, id)\n const subscription = MentraLocalNetwork.addListener(\"downloadProgress\", (event: LocalNetworkDownloadProgress) => {\n if (event.requestId !== id) return\n if (!began) {\n began = true\n options.begin?.({\n jobId,\n statusCode: event.statusCode || 200,\n contentLength: event.contentLength,\n headers: event.headers || {},\n })\n }\n options.progress?.({\n jobId,\n contentLength: event.contentLength,\n bytesWritten: event.bytesWritten,\n })\n })\n\n const promise = MentraLocalNetwork.download(\n id,\n options.fromUrl,\n options.toFile,\n options.headers || {},\n options.connectionTimeout || 30_000,\n options.readTimeout || 30_000,\n )\n .then((result) => {\n if (!began) {\n options.begin?.({\n jobId,\n statusCode: result.statusCode,\n contentLength: result.bytesWritten,\n headers: result.headers,\n })\n }\n return {\n jobId,\n statusCode: result.statusCode,\n bytesWritten: result.bytesWritten,\n }\n })\n .catch((error) => {\n if (cancelledNativeJobs.has(jobId)) throw new Error(\"Sync cancelled\")\n throw error\n })\n .finally(() => {\n nativeJobs.delete(jobId)\n cancelledNativeJobs.delete(jobId)\n subscription.remove()\n })\n\n return {jobId, promise} as DownloadHandle\n },\n\n stopDownload(jobId: number): void {\n const nativeId = nativeJobs.get(jobId)\n if (nativeId && MentraLocalNetwork) {\n cancelledNativeJobs.add(jobId)\n void MentraLocalNetwork.cancel(nativeId)\n return\n }\n RNFS.stopDownload(jobId)\n },\n}\n\nMentraLocalNetwork?.addListener(\"networkLost\", () => {\n scopedConnectionActive = false\n nativeJobs.clear()\n})\n"]}
|
|
1
|
+
{"version":3,"file":"localNetworkTransport.js","sourceRoot":"","sources":["../../../src/services/asg/localNetworkTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,6BAA6B,CAAA;AACnD,OAAO,EAAC,kBAAkB,EAAoC,MAAM,gCAAgC,CAAA;AACpG,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AACrC,OAAO,WAAW,MAAM,0BAA0B,CAAA;AAKlD,IAAI,sBAAsB,GAAG,KAAK,CAAA;AAClC,IAAI,SAAS,GAAG,SAAS,CAAA;AACzB,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAA;AAC5C,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAA;AAE7C,MAAM,UAAU,2BAA2B,CAAC,EAAU,EAAE,eAAwB;IAC9E,OAAO,EAAE,KAAK,SAAS,IAAI,eAAe,CAAA;AAC5C,CAAC;AAED,SAAS,wBAAwB;IAC/B,OAAO,2BAA2B,CAAC,QAAQ,CAAC,EAAE,EAAE,kBAAkB,IAAI,IAAI,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAqB;IAC7C,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAA;IACvB,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;QAC/B,MAAM,MAAM,GAA2B,EAAE,CAAA;QACzC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACrB,CAAC,CAAC,CAAA;QACF,OAAO,MAAM,CAAA;IACf,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,MAAM,CAAC,WAAW,CA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alNetworkDownloadProgress} from \"@mentra/bluetooth-sdk/internal\"\nimport {Buffer} from \"buffer\"\nimport {Platform} from \"react-native\"\nimport WifiManager from \"react-native-wifi-reborn\"\n\ntype DownloadOptions = Parameters<typeof RNFS.downloadFile>[0]\ntype DownloadHandle = ReturnType<typeof RNFS.downloadFile>\n\nlet scopedConnectionActive = false\nlet nextJobId = 1_000_000\nconst nativeJobs = new Map<number, string>()\nconst cancelledNativeJobs = new Set<number>()\n\nexport function shouldUseScopedLocalNetwork(os: string, moduleAvailable: boolean): boolean {\n return os === \"android\" && moduleAvailable\n}\n\nfunction supportsScopedConnection(): boolean {\n return shouldUseScopedLocalNetwork(Platform.OS, MentraLocalNetwork != null)\n}\n\nfunction normalizeHeaders(headers?: HeadersInit): Record<string, string> {\n if (!headers) return {}\n if (headers instanceof Headers) {\n const result: Record<string, string> = {}\n headers.forEach((value, key) => {\n result[key] = value\n })\n return result\n }\n if (Array.isArray(headers)) return Object.fromEntries(headers)\n return {...headers}\n}\n\nfunction requestId(prefix: string): string {\n return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2)}`\n}\n\nexport const localNetworkTransport = {\n supportsScopedConnection: (): boolean => supportsScopedConnection(),\n isScopedConnectionActive: (): boolean => scopedConnectionActive,\n\n async connect(ssid: string, password: string): Promise<string | undefined> {\n scopedConnectionActive = false\n nativeJobs.clear()\n if (!supportsScopedConnection()) {\n await WifiManager.connectToProtectedSSID(ssid, password, false, false)\n return undefined\n }\n const result = await MentraLocalNetwork!.connect(ssid, password)\n scopedConnectionActive = true\n return result.localAddress\n },\n\n async disconnect(): Promise<void> {\n if (supportsScopedConnection()) {\n await MentraLocalNetwork!.disconnect().catch(() => {})\n }\n scopedConnectionActive = false\n nativeJobs.clear()\n },\n\n async fetch(url: string | URL | Request, init?: RequestInit, timeoutMs = 30_000): Promise<Response> {\n if (!scopedConnectionActive || !MentraLocalNetwork || typeof url !== \"string\") {\n return globalThis.fetch(url, init)\n }\n\n const nativeModule = MentraLocalNetwork\n const id = requestId(\"request\")\n const signal = init?.signal\n const cancel = () => void nativeModule.cancel(id)\n if (signal?.aborted) throw new Error(\"Request aborted\")\n signal?.addEventListener(\"abort\", cancel, {once: true})\n try {\n const result = await nativeModule.request(\n id,\n url,\n init?.method || \"GET\",\n normalizeHeaders(init?.headers),\n typeof init?.body === \"string\" ? init.body : null,\n timeoutMs,\n )\n const bytes = Buffer.from(result.bodyBase64, \"base64\")\n return new Response(bytes as unknown as BodyInit, {\n status: result.status,\n headers: result.headers,\n })\n } finally {\n signal?.removeEventListener(\"abort\", cancel)\n }\n },\n\n downloadFile(options: DownloadOptions): DownloadHandle {\n if (!scopedConnectionActive || !MentraLocalNetwork) return RNFS.downloadFile(options)\n\n const jobId = nextJobId++\n const id = requestId(\"download\")\n let began = false\n nativeJobs.set(jobId, id)\n const subscription = MentraLocalNetwork.addListener(\"downloadProgress\", (event: LocalNetworkDownloadProgress) => {\n if (event.requestId !== id) return\n if (!began) {\n began = true\n options.begin?.({\n jobId,\n statusCode: event.statusCode || 200,\n contentLength: event.contentLength,\n headers: event.headers || {},\n })\n }\n options.progress?.({\n jobId,\n contentLength: event.contentLength,\n bytesWritten: event.bytesWritten,\n })\n })\n\n const promise = MentraLocalNetwork.download(\n id,\n options.fromUrl,\n options.toFile,\n options.headers || {},\n options.connectionTimeout || 30_000,\n options.readTimeout || 30_000,\n )\n .then((result) => {\n if (!began) {\n options.begin?.({\n jobId,\n statusCode: result.statusCode,\n contentLength: result.bytesWritten,\n headers: result.headers,\n })\n }\n return {\n jobId,\n statusCode: result.statusCode,\n bytesWritten: result.bytesWritten,\n }\n })\n .catch((error) => {\n if (cancelledNativeJobs.has(jobId)) throw new Error(\"Sync cancelled\")\n throw error\n })\n .finally(() => {\n nativeJobs.delete(jobId)\n cancelledNativeJobs.delete(jobId)\n subscription.remove()\n })\n\n return {jobId, promise} as DownloadHandle\n },\n\n stopDownload(jobId: number): void {\n const nativeId = nativeJobs.get(jobId)\n if (nativeId && MentraLocalNetwork) {\n cancelledNativeJobs.add(jobId)\n void MentraLocalNetwork.cancel(nativeId)\n return\n }\n RNFS.stopDownload(jobId)\n },\n}\n\nMentraLocalNetwork?.addListener(\"networkLost\", () => {\n scopedConnectionActive = false\n nativeJobs.clear()\n})\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AudioSource } from "expo-audio";
|
|
2
|
+
/**
|
|
3
|
+
* A tiny bundled source used to detach completed or interrupted audio without
|
|
4
|
+
* destroying the reusable native player. If a media control later sends Play,
|
|
5
|
+
* only this silence can be resumed instead of the previous miniapp audio.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SILENT_AUDIO_SOURCE: AudioSource;
|
|
8
|
+
//# sourceMappingURL=audioPlaybackAssets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioPlaybackAssets.d.ts","sourceRoot":"","sources":["../../src/services/audioPlaybackAssets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAE3C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAA8C,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tiny bundled source used to detach completed or interrupted audio without
|
|
3
|
+
* destroying the reusable native player. If a media control later sends Play,
|
|
4
|
+
* only this silence can be resumed instead of the previous miniapp audio.
|
|
5
|
+
*/
|
|
6
|
+
export const SILENT_AUDIO_SOURCE = require("../assets/silence.wav");
|
|
7
|
+
//# sourceMappingURL=audioPlaybackAssets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioPlaybackAssets.js","sourceRoot":"","sources":["../../src/services/audioPlaybackAssets.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAgB,OAAO,CAAC,uBAAuB,CAAC,CAAA","sourcesContent":["import type {AudioSource} from \"expo-audio\"\n\n/**\n * A tiny bundled source used to detach completed or interrupted audio without\n * destroying the reusable native player. If a media control later sends Play,\n * only this silence can be resumed instead of the previous miniapp audio.\n */\nexport const SILENT_AUDIO_SOURCE: AudioSource = require(\"../assets/silence.wav\")\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import BluetoothSdk from "@mentra/bluetooth-sdk/internal";
|
|
5
5
|
import { BgTimer } from "../utils/timers";
|
|
6
6
|
import { useGlassesStore } from "../stores/glasses";
|
|
7
|
-
import {
|
|
7
|
+
import { resolveOtaManifestUrl } from "./otaManifestUrl";
|
|
8
8
|
import { detectClockSkew } from "./gallerySyncClock";
|
|
9
9
|
export const CLOCK_SETTLE_MS = 500;
|
|
10
10
|
const OTA_CLOCK_FIX_COOLDOWN_MS = 30_000;
|
|
@@ -70,7 +70,7 @@ export async function handleOtaClockSkewFromGlasses(errorCode, glassesTimeMs) {
|
|
|
70
70
|
}
|
|
71
71
|
lastOtaClockFixAt = Date.now();
|
|
72
72
|
const { buildNumber, otaVersionUrl } = useGlassesStore.getState();
|
|
73
|
-
const manifestUrl =
|
|
73
|
+
const manifestUrl = resolveOtaManifestUrl(otaVersionUrl, buildNumber);
|
|
74
74
|
console.log("[GlassesClockSync] ⏰ Restarting OTA with ota_start after clock fix");
|
|
75
75
|
await BluetoothSdk.startOtaUpdate(manifestUrl);
|
|
76
76
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glassesClockSync.js","sourceRoot":"","sources":["../../src/services/glassesClockSync.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,YAAY,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"glassesClockSync.js","sourceRoot":"","sources":["../../src/services/glassesClockSync.ts"],"names":[],"mappings":"AAAA;;GAEG;A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M,EAAC,WAAW,EAAE,aAAa,EAAC,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;YAC/D,MAAM,WAAW,GAAG,qBAAqB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA;YACrE,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAA;YACjF,MAAM,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;YAC9C,OAAO,IAAI,CAAA;QACb,CAAC;gBAAS,CAAC;YACT,mBAAmB,GAAG,IAAI,CAAA;QAC5B,CAAC;IACH,CAAC,CAAC,EAAE,CAAA;IAEJ,OAAO,mBAAmB,CAAA;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,YAAgC;IACxF,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA;IAC5D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * Push phone time to glasses only when clock skew is detected (gallery sync, OTA, etc.).\n */\n\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport {BgTimer} from \"../utils/timers\"\nimport {useGlassesStore} from \"../stores/glasses\"\n\nimport {resolveOtaManifestUrl} from \"./otaManifestUrl\"\nimport {detectClockSkew} from \"./gallerySyncClock\"\n\nexport const CLOCK_SETTLE_MS = 500\n\nconst OTA_CLOCK_FIX_COOLDOWN_MS = 30_000\nlet lastOtaClockFixAt = 0\n// Coalesce concurrent OTA clock-fix attempts. Glasses can emit two clock_skew events\n// back-to-back during BLE handshake; without this guard both would await the BLE fix\n// + retry pair before either updated `lastOtaClockFixAt`.\nlet inflightOtaClockFix: Promise<boolean> | null = null\n\n/** @internal test-only */\nexport function resetOtaClockFixCooldownForTests(): void {\n lastOtaClockFixAt = 0\n inflightOtaClockFix = null\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => BgTimer.setTimeout(resolve, ms))\n}\n\n/**\n * Set glasses system clock from phone when skew is detected.\n */\nexport async function fixGlassesClockIfSkewed(glassesServerTime: number, lastSyncTime = 0): Promise<boolean> {\n const {skewed, reason} = detectClockSkew(Date.now(), glassesServerTime, lastSyncTime)\n if (!skewed) {\n return false\n }\n console.log(`[GlassesClockSync] ⏰ Clock skew detected (${reason}) — setting glasses time from phone`)\n await BluetoothSdk.setSystemTime(Date.now())\n await delay(CLOCK_SETTLE_MS)\n return true\n}\n\n/**\n * After glasses report OTA failure due to clock skew, fix time and restart\n * through the normal phone-driven ota_start path.\n */\nexport async function handleOtaClockSkewFromGlasses(\n errorCode: string | undefined,\n glassesTimeMs?: number,\n): Promise<boolean> {\n if (Date.now() - lastOtaClockFixAt < OTA_CLOCK_FIX_COOLDOWN_MS) {\n return false\n }\n\n const hasGlassesTime = typeof glassesTimeMs === \"number\" && Number.isFinite(glassesTimeMs) && glassesTimeMs > 0\n\n if (errorCode === \"ssl_error\") {\n if (!hasGlassesTime) {\n return false\n }\n const {skewed} = detectClockSkew(Date.now(), glassesTimeMs, 0)\n if (!skewed) {\n return false\n }\n console.log(\"[GlassesClockSync] ⏰ OTA ssl_error with wall-clock drift — treating as clock skew\")\n } else if (errorCode !== \"clock_skew\") {\n return false\n }\n\n // Coalesce concurrent attempts: if a fix is already in flight, await its result instead\n // of racing it through the cooldown guard.\n if (inflightOtaClockFix) {\n return inflightOtaClockFix\n }\n\n const glassesTime = hasGlassesTime ? glassesTimeMs : Date.now() - 86_400_000\n\n inflightOtaClockFix = (async () => {\n try {\n const fixed = await fixGlassesClockIfSkewed(glassesTime, 0)\n if (!fixed) {\n return false\n }\n\n lastOtaClockFixAt = Date.now()\n const {buildNumber, otaVersionUrl} = useGlassesStore.getState()\n const manifestUrl = resolveOtaManifestUrl(otaVersionUrl, buildNumber)\n console.log(\"[GlassesClockSync] ⏰ Restarting OTA with ota_start after clock fix\")\n await BluetoothSdk.startOtaUpdate(manifestUrl)\n return true\n } finally {\n inflightOtaClockFix = null\n }\n })()\n\n return inflightOtaClockFix\n}\n\n/**\n * Proactive fix when version_info includes glasses system_time_ms before OTA manifest checks.\n */\nexport async function maybeFixGlassesClockFromVersionInfo(systemTimeMs: number | undefined): Promise<boolean> {\n if (typeof systemTimeMs !== \"number\" || systemTimeMs <= 0) {\n return false\n }\n\n const fixed = await fixGlassesClockIfSkewed(systemTimeMs, 0)\n if (!fixed) {\n return false\n }\n\n return true\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeclaredAction } from "../types/applet";
|
|
2
|
+
/**
|
|
3
|
+
* Normalize manifest actions defensively for installed and dev-sideloaded
|
|
4
|
+
* bundles. Input and output schemas are passed through as opaque JSON Schema.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeManifestActions(raw: unknown): DeclaredAction[];
|
|
7
|
+
//# sourceMappingURL=manifestActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifestActions.d.ts","sourceRoot":"","sources":["../../src/services/manifestActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAA;AAEnD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,EAAE,CAuBvE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize manifest actions defensively for installed and dev-sideloaded
|
|
3
|
+
* bundles. Input and output schemas are passed through as opaque JSON Schema.
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeManifestActions(raw) {
|
|
6
|
+
if (!Array.isArray(raw))
|
|
7
|
+
return [];
|
|
8
|
+
const out = [];
|
|
9
|
+
for (const a of raw) {
|
|
10
|
+
if (a && typeof a.id === "string" && typeof a.description === "string") {
|
|
11
|
+
out.push({
|
|
12
|
+
id: a.id,
|
|
13
|
+
description: a.description,
|
|
14
|
+
...(a.parameters && typeof a.parameters === "object" && !Array.isArray(a.parameters)
|
|
15
|
+
? { parameters: a.parameters }
|
|
16
|
+
: {}),
|
|
17
|
+
...(a.outputSchema && typeof a.outputSchema === "object" && !Array.isArray(a.outputSchema)
|
|
18
|
+
? { outputSchema: a.outputSchema }
|
|
19
|
+
: {}),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=manifestActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifestActions.js","sourceRoot":"","sources":["../../src/services/manifestActions.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAA;IAClC,MAAM,GAAG,GAAqB,EAAE,CAAA;IAChC,KAAK,MAAM,CAAC,IAAI,GAKd,EAAE,CAAC;QACH,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YACvE,GAAG,CAAC,IAAI,CAAC;gBACP,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;oBAClF,CAAC,CAAC,EAAC,UAAU,EAAE,CAAC,CAAC,UAAqC,EAAC;oBACvD,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,OAAO,CAAC,CAAC,YAAY,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC;oBACxF,CAAC,CAAC,EAAC,YAAY,EAAE,CAAC,CAAC,YAAuC,EAAC;oBAC3D,CAAC,CAAC,EAAE,CAAC;aACR,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import type {DeclaredAction} from \"../types/applet\"\n\n/**\n * Normalize manifest actions defensively for installed and dev-sideloaded\n * bundles. Input and output schemas are passed through as opaque JSON Schema.\n */\nexport function normalizeManifestActions(raw: unknown): DeclaredAction[] {\n if (!Array.isArray(raw)) return []\n const out: DeclaredAction[] = []\n for (const a of raw as Array<{\n id?: unknown\n description?: unknown\n parameters?: unknown\n outputSchema?: unknown\n }>) {\n if (a && typeof a.id === \"string\" && typeof a.description === \"string\") {\n out.push({\n id: a.id,\n description: a.description,\n ...(a.parameters && typeof a.parameters === \"object\" && !Array.isArray(a.parameters)\n ? {parameters: a.parameters as Record<string, unknown>}\n : {}),\n ...(a.outputSchema && typeof a.outputSchema === \"object\" && !Array.isArray(a.outputSchema)\n ? {outputSchema: a.outputSchema as Record<string, unknown>}\n : {}),\n })\n }\n }\n return out\n}\n"]}
|
|
@@ -14,29 +14,40 @@ export type DisplayState = "starting" | "updating" | "complete" | "failed" | "di
|
|
|
14
14
|
*
|
|
15
15
|
* Priority-ordered rules (first match wins):
|
|
16
16
|
* 1. errorMsg !== "" -> "failed"
|
|
17
|
-
* 2. BES
|
|
18
|
-
* 3. BES
|
|
17
|
+
* 2. BES reboot recovery complete -> "complete"
|
|
18
|
+
* 3. BES reboot recovery awaiting reconnect -> "restarting"
|
|
19
|
+
* 4. BES terminal (any connection state) -> "restarting"
|
|
19
20
|
* (legacy-shaped BES "complete" counts only in install phase)
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* 6. apkCompletedViaBuildIncrease (legacy build-number port) -> "complete"
|
|
22
|
+
* 7. otaStatus.status === "failed" -> "failed"
|
|
23
|
+
* 8. otaStatus.status === "complete" (non-BES) -> "complete"
|
|
23
24
|
* (unless legacy-shaped download-complete or held apk settle -> in flight)
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
25
|
+
* 9. !connected + legacy in-flight complete (held apk) -> "updating"
|
|
26
|
+
* 10. !connected + APK step_complete with totalSteps > 1 -> "starting" (expected reboot)
|
|
27
|
+
* 11. !connected + BES in flight -> "restarting" (defensive)
|
|
28
|
+
* 12. !connected -> "disconnected"
|
|
29
|
+
* 13. connected + in_progress | step_complete | legacy in-flight complete -> "updating"
|
|
30
|
+
* 14. fallback -> "starting"
|
|
30
31
|
*/
|
|
31
32
|
export declare function deriveDisplayState(args: {
|
|
32
33
|
otaStatus: OtaStatus | null;
|
|
33
34
|
otaProgress: OtaProgress | null;
|
|
34
35
|
connected: boolean;
|
|
35
36
|
errorMsg: string;
|
|
37
|
+
/**
|
|
38
|
+
* Retained for host API compatibility. A session-wide reconnect edge is not
|
|
39
|
+
* sufficient for BES completion because it may belong to an earlier APK step.
|
|
40
|
+
*/
|
|
36
41
|
sawReconnectEdge: boolean;
|
|
37
42
|
/** Coordinator is holding a legacy apk install "complete" for the settle window (WP 8C). */
|
|
38
43
|
legacyApkSettleHold?: boolean;
|
|
39
44
|
/** Legacy APK completion detected by build-number increase (WP 8C). */
|
|
40
45
|
apkCompletedViaBuildIncrease?: boolean;
|
|
46
|
+
/** Phone-observed BES disconnect/reconnect recovery, independent of stale OTA progress. */
|
|
47
|
+
besRestartRecovery?: "awaiting" | "complete" | null;
|
|
48
|
+
/** Downgrade detour: the reconnected glasses reported exactly the pinned target version. */
|
|
49
|
+
versionChangeConverged?: boolean;
|
|
50
|
+
/** True for the whole downgrade (version-change) session. */
|
|
51
|
+
versionChangeSession?: boolean;
|
|
41
52
|
}): DisplayState;
|
|
42
53
|
//# sourceMappingURL=otaDisplayState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaDisplayState.d.ts","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,gCAAgC,CAAA;AAI1E,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAA;AAE1G
|
|
1
|
+
{"version":3,"file":"otaDisplayState.d.ts","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,gCAAgC,CAAA;AAI1E,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAA;AAE1G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;IAC3B,WAAW,EAAE,WAAW,GAAG,IAAI,CAAA;IAC/B,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAA;IACzB,4FAA4F;IAC5F,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,uEAAuE;IACvE,4BAA4B,CAAC,EAAE,OAAO,CAAA;IACtC,2FAA2F;IAC3F,kBAAkB,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAA;IACnD,4FAA4F;IAC5F,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,GAAG,YAAY,CAqFf"}
|
|
@@ -13,27 +13,49 @@ import { isLegacyShapedOtaStatus } from "./otaInstallPolicy";
|
|
|
13
13
|
*
|
|
14
14
|
* Priority-ordered rules (first match wins):
|
|
15
15
|
* 1. errorMsg !== "" -> "failed"
|
|
16
|
-
* 2. BES
|
|
17
|
-
* 3. BES
|
|
16
|
+
* 2. BES reboot recovery complete -> "complete"
|
|
17
|
+
* 3. BES reboot recovery awaiting reconnect -> "restarting"
|
|
18
|
+
* 4. BES terminal (any connection state) -> "restarting"
|
|
18
19
|
* (legacy-shaped BES "complete" counts only in install phase)
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* 6. apkCompletedViaBuildIncrease (legacy build-number port) -> "complete"
|
|
21
|
+
* 7. otaStatus.status === "failed" -> "failed"
|
|
22
|
+
* 8. otaStatus.status === "complete" (non-BES) -> "complete"
|
|
22
23
|
* (unless legacy-shaped download-complete or held apk settle -> in flight)
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* 9. !connected + legacy in-flight complete (held apk) -> "updating"
|
|
25
|
+
* 10. !connected + APK step_complete with totalSteps > 1 -> "starting" (expected reboot)
|
|
26
|
+
* 11. !connected + BES in flight -> "restarting" (defensive)
|
|
27
|
+
* 12. !connected -> "disconnected"
|
|
28
|
+
* 13. connected + in_progress | step_complete | legacy in-flight complete -> "updating"
|
|
29
|
+
* 14. fallback -> "starting"
|
|
29
30
|
*/
|
|
30
31
|
export function deriveDisplayState(args) {
|
|
31
|
-
const { otaStatus, otaProgress, connected, errorMsg,
|
|
32
|
+
const { otaStatus, otaProgress, connected, errorMsg, legacyApkSettleHold, apkCompletedViaBuildIncrease, besRestartRecovery, versionChangeConverged, versionChangeSession, } = args;
|
|
32
33
|
if (errorMsg)
|
|
33
34
|
return "failed";
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
// Downgrade detour completion: exact-version convergence after reconnect is the
|
|
36
|
+
// only completion signal (the wipe destroys ASG's ota_session, and the target is
|
|
37
|
+
// a LOWER build so no build-number increase fires). Outranks the stale install
|
|
38
|
+
// status still sitting in the store from before the handoff.
|
|
39
|
+
if (versionChangeConverged)
|
|
40
|
+
return "complete";
|
|
41
|
+
// A BES reboot destroys or strands the glasses-side OTA session on older
|
|
42
|
+
// clients. Once the phone observed that reboot, stale pre-reboot progress must
|
|
43
|
+
// not move the UI from restarting back to updating.
|
|
44
|
+
if (besRestartRecovery === "complete")
|
|
36
45
|
return "complete";
|
|
46
|
+
if (besRestartRecovery === "awaiting")
|
|
47
|
+
return "restarting";
|
|
48
|
+
// In a version-change session, convergence (above) is the ONLY completion for the ASG
|
|
49
|
+
// downgrade. A bare non-firmware "complete" before convergence — the glasses refusing
|
|
50
|
+
// the downgrade (floor/gate) with no install, or a stale pre-handoff status — must never
|
|
51
|
+
// present as success. Firmware-step completions (mtk/bes) DO pass through: a combined
|
|
52
|
+
// downgrade+firmware manifest applies firmware first on its own pass, which must finish
|
|
53
|
+
// so the phone re-checks and re-offers the now-firmware-free downgrade.
|
|
54
|
+
const isFirmwareComplete = otaStatus?.stepType === "mtk" || otaStatus?.stepType === "bes";
|
|
55
|
+
if (versionChangeSession && otaStatus?.status === "complete" && !isFirmwareComplete) {
|
|
56
|
+
return connected ? "updating" : "disconnected";
|
|
57
|
+
}
|
|
58
|
+
const besTerminal = isBesTerminal(otaStatus, otaProgress);
|
|
37
59
|
if (besTerminal)
|
|
38
60
|
return "restarting";
|
|
39
61
|
// Legacy build-number APK completion: the coordinator clears errorMsg when it fires,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaDisplayState.js","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAUlC;IACC,MAAM,EAAC,SAAS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Status} from \"./otaInstallPolicy\"\n\nexport type DisplayState = \"starting\" | \"updating\" | \"complete\" | \"failed\" | \"disconnected\" | \"restarting\"\n\n/**\n * Pure derivation of the OTA progress UI state from the glasses data in the\n * Zustand store plus a couple of genuinely-local inputs. See\n * OtaInstallCoordinator.ts for the state machine that consumes this (the host\n * progress screen renders its snapshot).\n *\n * Legacy shape (WP 8C): old (< 37) ASG builds send `ota_progress`, which the SDK\n * maps to ota_status with sessionId \"\" and FINISHED→\"complete\" at ANY phase. For\n * those statuses a download-phase \"complete\" only means the download finished\n * (the install is still ahead), and an apk install \"complete\" may be held by the\n * coordinator's settle window — both stay \"updating\" instead of terminal.\n *\n * Priority-ordered rules (first match wins):\n * 1. errorMsg !== \"\" -> \"failed\"\n * 2. BES terminal + connected + sawReconnectEdge -> \"complete\"\n * 3. BES terminal (any connection state) -> \"restarting\"\n * (legacy-shaped BES \"complete\" counts only in install phase)\n * 4. apkCompletedViaBuildIncrease (legacy build-number port) -> \"complete\"\n * 5. otaStatus.status === \"failed\" -> \"failed\"\n * 6. otaStatus.status === \"complete\" (non-BES) -> \"complete\"\n * (unless legacy-shaped download-complete or held apk settle -> in flight)\n * 7. !connected + legacy in-flight complete (held apk) -> \"updating\"\n * 8. !connected + APK step_complete with totalSteps > 1 -> \"starting\" (expected reboot)\n * 9. !connected + BES in flight -> \"restarting\" (defensive)\n * 10. !connected -> \"disconnected\"\n * 11. connected + in_progress | step_complete | legacy in-flight complete -> \"updating\"\n * 12. fallback -> \"starting\"\n */\nexport function deriveDisplayState(args: {\n otaStatus: OtaStatus | null\n otaProgress: OtaProgress | null\n connected: boolean\n errorMsg: string\n sawReconnectEdge: boolean\n /** Coordinator is holding a legacy apk install \"complete\" for the settle window (WP 8C). */\n legacyApkSettleHold?: boolean\n /** Legacy APK completion detected by build-number increase (WP 8C). */\n apkCompletedViaBuildIncrease?: boolean\n}): DisplayState {\n const {otaStatus, otaProgress, connected, errorMsg, sawReconnectEdge, legacyApkSettleHold, apkCompletedViaBuildIncrease} =\n args\n\n if (errorMsg) return \"failed\"\n\n const besTerminal = isBesTerminal(otaStatus, otaProgress)\n if (besTerminal && connected && sawReconnectEdge) return \"complete\"\n if (besTerminal) return \"restarting\"\n\n // Legacy build-number APK completion: the coordinator clears errorMsg when it fires,\n // and the flag outranks whatever stale legacy status is still in the store (the old\n // screen's last-write-wins completion from starting/failed/installing).\n if (apkCompletedViaBuildIncrease) return \"complete\"\n\n if (otaStatus?.status === \"failed\") return \"failed\"\n\n // Legacy-shaped \"complete\" that is still in flight: a download-phase FINISHED (the\n // install is still ahead), or an apk install FINISHED held by the settle window.\n const legacyInFlightComplete =\n isLegacyShapedOtaStatus(otaStatus) &&\n otaStatus?.status === \"complete\" &&\n (otaStatus.phase === \"download\" ||\n (!!legacyApkSettleHold && otaStatus.stepType === \"apk\" && otaStatus.phase === \"install\"))\n\n if (otaStatus?.status === \"complete\" && !legacyInFlightComplete) return \"complete\"\n\n if (!connected) {\n // The held apk install complete means the glasses are restarting into the new\n // build — the legacy screen kept showing \"installing\" through that restart.\n if (legacyInFlightComplete && otaStatus?.phase === \"install\") return \"updating\"\n\n // By here, the failed/complete rules already returned for terminal statuses.\n // For APK multi-step, \"step_complete\" means the current step ended and the\n // glasses are rebooting to start the next one.\n const apkRebootExpected =\n otaStatus?.stepType === \"apk\" && (otaStatus?.totalSteps ?? 0) > 1 && otaStatus.status === \"step_complete\"\n if (apkRebootExpected) return \"starting\"\n\n // Legacy-shaped BES download events do not mean a reboot is coming (the flash\n // has not started); the legacy screen treated that drop as a plain disconnect.\n const besStatusInFlight =\n otaStatus?.stepType === \"bes\" && !(isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase === \"download\")\n const besInFlight =\n besStatusInFlight || (otaProgress?.currentUpdate === \"bes\" && otaProgress?.stage === \"install\")\n if (besInFlight) return \"restarting\"\n\n return \"disconnected\"\n }\n\n if (otaStatus?.status === \"in_progress\" || otaStatus?.status === \"step_complete\" || legacyInFlightComplete) {\n return \"updating\"\n }\n\n return \"starting\"\n}\n\nfunction isBesTerminal(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null): boolean {\n if (otaStatus?.stepType === \"bes\" && (otaStatus.status === \"step_complete\" || otaStatus.status === \"complete\")) {\n // Legacy-shaped statuses map download FINISHED to \"complete\" too; only an\n // install-phase terminal means the BES flash actually ran (WP 8C).\n if (isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase !== \"install\") {\n return false\n }\n return true\n }\n if (otaProgress?.currentUpdate === \"bes\" && otaProgress.stage === \"install\" && otaProgress.status === \"FINISHED\") {\n return true\n }\n return false\n}\n"]}
|
|
1
|
+
{"version":3,"file":"otaDisplayState.js","sourceRoot":"","sources":["../../src/services/otaDisplayState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAoBlC;IACC,MAAM,EACJ,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EACR,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,GACrB,GAAG,IAAI,CAAA;IAER,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAE7B,gFAAgF;IAChF,iFAAiF;IACjF,+EAA+E;IAC/E,6DAA6D;IAC7D,IAAI,sBAAsB;QAAE,OAAO,UAAU,CAAA;IAE7C,yEAAyE;IACzE,+EAA+E;IAC/E,oDAAoD;IACpD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,UAAU,CAAA;IACxD,IAAI,kBAAkB,KAAK,UAAU;QAAE,OAAO,YAAY,CAAA;IAE1D,sFAAsF;IACtF,sFAAsF;IACtF,yFAAyF;IACzF,sFAAsF;IACtF,wFAAwF;IACxF,wEAAwE;IACxE,MAAM,kBAAkB,GAAG,SAAS,EAAE,QAAQ,KAAK,KAAK,IAAI,SAAS,EA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icy\"\n\nexport type DisplayState = \"starting\" | \"updating\" | \"complete\" | \"failed\" | \"disconnected\" | \"restarting\"\n\n/**\n * Pure derivation of the OTA progress UI state from the glasses data in the\n * Zustand store plus a couple of genuinely-local inputs. See\n * OtaInstallCoordinator.ts for the state machine that consumes this (the host\n * progress screen renders its snapshot).\n *\n * Legacy shape (WP 8C): old (< 37) ASG builds send `ota_progress`, which the SDK\n * maps to ota_status with sessionId \"\" and FINISHED→\"complete\" at ANY phase. For\n * those statuses a download-phase \"complete\" only means the download finished\n * (the install is still ahead), and an apk install \"complete\" may be held by the\n * coordinator's settle window — both stay \"updating\" instead of terminal.\n *\n * Priority-ordered rules (first match wins):\n * 1. errorMsg !== \"\" -> \"failed\"\n * 2. BES reboot recovery complete -> \"complete\"\n * 3. BES reboot recovery awaiting reconnect -> \"restarting\"\n * 4. BES terminal (any connection state) -> \"restarting\"\n * (legacy-shaped BES \"complete\" counts only in install phase)\n * 6. apkCompletedViaBuildIncrease (legacy build-number port) -> \"complete\"\n * 7. otaStatus.status === \"failed\" -> \"failed\"\n * 8. otaStatus.status === \"complete\" (non-BES) -> \"complete\"\n * (unless legacy-shaped download-complete or held apk settle -> in flight)\n * 9. !connected + legacy in-flight complete (held apk) -> \"updating\"\n * 10. !connected + APK step_complete with totalSteps > 1 -> \"starting\" (expected reboot)\n * 11. !connected + BES in flight -> \"restarting\" (defensive)\n * 12. !connected -> \"disconnected\"\n * 13. connected + in_progress | step_complete | legacy in-flight complete -> \"updating\"\n * 14. fallback -> \"starting\"\n */\nexport function deriveDisplayState(args: {\n otaStatus: OtaStatus | null\n otaProgress: OtaProgress | null\n connected: boolean\n errorMsg: string\n /**\n * Retained for host API compatibility. A session-wide reconnect edge is not\n * sufficient for BES completion because it may belong to an earlier APK step.\n */\n sawReconnectEdge: boolean\n /** Coordinator is holding a legacy apk install \"complete\" for the settle window (WP 8C). */\n legacyApkSettleHold?: boolean\n /** Legacy APK completion detected by build-number increase (WP 8C). */\n apkCompletedViaBuildIncrease?: boolean\n /** Phone-observed BES disconnect/reconnect recovery, independent of stale OTA progress. */\n besRestartRecovery?: \"awaiting\" | \"complete\" | null\n /** Downgrade detour: the reconnected glasses reported exactly the pinned target version. */\n versionChangeConverged?: boolean\n /** True for the whole downgrade (version-change) session. */\n versionChangeSession?: boolean\n}): DisplayState {\n const {\n otaStatus,\n otaProgress,\n connected,\n errorMsg,\n legacyApkSettleHold,\n apkCompletedViaBuildIncrease,\n besRestartRecovery,\n versionChangeConverged,\n versionChangeSession,\n } = args\n\n if (errorMsg) return \"failed\"\n\n // Downgrade detour completion: exact-version convergence after reconnect is the\n // only completion signal (the wipe destroys ASG's ota_session, and the target is\n // a LOWER build so no build-number increase fires). Outranks the stale install\n // status still sitting in the store from before the handoff.\n if (versionChangeConverged) return \"complete\"\n\n // A BES reboot destroys or strands the glasses-side OTA session on older\n // clients. Once the phone observed that reboot, stale pre-reboot progress must\n // not move the UI from restarting back to updating.\n if (besRestartRecovery === \"complete\") return \"complete\"\n if (besRestartRecovery === \"awaiting\") return \"restarting\"\n\n // In a version-change session, convergence (above) is the ONLY completion for the ASG\n // downgrade. A bare non-firmware \"complete\" before convergence — the glasses refusing\n // the downgrade (floor/gate) with no install, or a stale pre-handoff status — must never\n // present as success. Firmware-step completions (mtk/bes) DO pass through: a combined\n // downgrade+firmware manifest applies firmware first on its own pass, which must finish\n // so the phone re-checks and re-offers the now-firmware-free downgrade.\n const isFirmwareComplete = otaStatus?.stepType === \"mtk\" || otaStatus?.stepType === \"bes\"\n if (versionChangeSession && otaStatus?.status === \"complete\" && !isFirmwareComplete) {\n return connected ? \"updating\" : \"disconnected\"\n }\n\n const besTerminal = isBesTerminal(otaStatus, otaProgress)\n if (besTerminal) return \"restarting\"\n\n // Legacy build-number APK completion: the coordinator clears errorMsg when it fires,\n // and the flag outranks whatever stale legacy status is still in the store (the old\n // screen's last-write-wins completion from starting/failed/installing).\n if (apkCompletedViaBuildIncrease) return \"complete\"\n\n if (otaStatus?.status === \"failed\") return \"failed\"\n\n // Legacy-shaped \"complete\" that is still in flight: a download-phase FINISHED (the\n // install is still ahead), or an apk install FINISHED held by the settle window.\n const legacyInFlightComplete =\n isLegacyShapedOtaStatus(otaStatus) &&\n otaStatus?.status === \"complete\" &&\n (otaStatus.phase === \"download\" ||\n (!!legacyApkSettleHold && otaStatus.stepType === \"apk\" && otaStatus.phase === \"install\"))\n\n if (otaStatus?.status === \"complete\" && !legacyInFlightComplete) return \"complete\"\n\n if (!connected) {\n // The held apk install complete means the glasses are restarting into the new\n // build — the legacy screen kept showing \"installing\" through that restart.\n if (legacyInFlightComplete && otaStatus?.phase === \"install\") return \"updating\"\n\n // By here, the failed/complete rules already returned for terminal statuses.\n // For APK multi-step, \"step_complete\" means the current step ended and the\n // glasses are rebooting to start the next one.\n const apkRebootExpected =\n otaStatus?.stepType === \"apk\" && (otaStatus?.totalSteps ?? 0) > 1 && otaStatus.status === \"step_complete\"\n if (apkRebootExpected) return \"starting\"\n\n // Legacy-shaped BES download events do not mean a reboot is coming (the flash\n // has not started); the legacy screen treated that drop as a plain disconnect.\n const besStatusInFlight =\n otaStatus?.stepType === \"bes\" && !(isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase === \"download\")\n const besInFlight = besStatusInFlight || (otaProgress?.currentUpdate === \"bes\" && otaProgress?.stage === \"install\")\n if (besInFlight) return \"restarting\"\n\n return \"disconnected\"\n }\n\n if (otaStatus?.status === \"in_progress\" || otaStatus?.status === \"step_complete\" || legacyInFlightComplete) {\n return \"updating\"\n }\n\n return \"starting\"\n}\n\nfunction isBesTerminal(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null): boolean {\n if (otaStatus?.stepType === \"bes\" && (otaStatus.status === \"step_complete\" || otaStatus.status === \"complete\")) {\n // Legacy-shaped statuses map download FINISHED to \"complete\" too; only an\n // install-phase terminal means the BES flash actually ran (WP 8C).\n if (isLegacyShapedOtaStatus(otaStatus) && otaStatus.phase !== \"install\") {\n return false\n }\n return true\n }\n if (otaProgress?.currentUpdate === \"bes\" && otaProgress.stage === \"install\" && otaProgress.status === \"FINISHED\") {\n return true\n }\n return false\n}\n"]}
|
|
@@ -8,6 +8,7 @@ import type { OtaProgress, OtaStatus } from "@mentra/bluetooth-sdk/internal";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const MINIMUM_OTA_STATUS_BUILD = 37;
|
|
10
10
|
export declare const MAX_RETRIES = 3;
|
|
11
|
+
/** Wait between ended native ota_start requests; never overlaps a pending request. */
|
|
11
12
|
export declare const RETRY_INTERVAL_MS = 5000;
|
|
12
13
|
/** APK/BES and general install when progress events are expected */
|
|
13
14
|
export declare const PROGRESS_TIMEOUT_MS = 120000;
|
|
@@ -17,8 +18,6 @@ export declare const DOWNLOAD_STUCK_TIMEOUT_MS = 70000;
|
|
|
17
18
|
export declare const MTK_INSTALL_TIMEOUT_MS = 300000;
|
|
18
19
|
/** Whole multi-step session cap */
|
|
19
20
|
export declare const GLOBAL_OTA_TIMEOUT_MS: number;
|
|
20
|
-
/** After APK reboot, ASG OTA service needs time before next ota_start */
|
|
21
|
-
export declare const POST_APK_OTA_START_DELAY_MS = 6000;
|
|
22
21
|
/** BLE keepalive during OTA */
|
|
23
22
|
export declare const PING_INTERVAL_MS = 10000;
|
|
24
23
|
/**
|
|
@@ -58,6 +57,7 @@ export declare const LEGACY_MTK_STALL_ZONE_MIN_PERCENT = 45;
|
|
|
58
57
|
export declare const LEGACY_MTK_STALL_ZONE_MAX_PERCENT = 55;
|
|
59
58
|
export declare const LEGACY_MTK_SIM_FLOOR_PERCENT = 51;
|
|
60
59
|
export declare const LEGACY_MTK_SIM_CAP_PERCENT = 60;
|
|
60
|
+
export type OtaProtocolProfile = "legacy" | "unified";
|
|
61
61
|
/**
|
|
62
62
|
* Legacy-shaped ota_status: old (< 37) ASG builds send `ota_progress`, which the SDK
|
|
63
63
|
* (Android MentraLive.kt / iOS MentraLive.swift) maps to a unified ota_status with
|
|
@@ -72,10 +72,22 @@ export declare function isLegacyShapedOtaStatus(otaStatus: OtaStatus | null): bo
|
|
|
72
72
|
* before any event arrives only the glasses build number can tell.
|
|
73
73
|
*/
|
|
74
74
|
export declare function isLegacyShapedOtaSession(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null, buildNumber: string | null | undefined): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Select the compatibility profile once at install-screen attach. The old split
|
|
77
|
+
* routes made this decision from the pre-update build and kept it for the whole
|
|
78
|
+
* mounted flow, even when an APK step restarted into a newer ASG build. Returning
|
|
79
|
+
* null leaves the coordinator undecided until the first meaningful OTA event.
|
|
80
|
+
*/
|
|
81
|
+
export declare function selectOtaProtocolProfile(otaStatus: OtaStatus | null, otaProgress: OtaProgress | null, buildNumber: string | null | undefined): OtaProtocolProfile | null;
|
|
75
82
|
export declare const OtaProgressMessages: {
|
|
76
|
-
readonly noAckResponse: "Unable to start update. Glasses did not respond.";
|
|
77
83
|
readonly stalledOrStuck: "Update may have failed. Ensure glasses have internet access and try again.";
|
|
78
84
|
readonly globalTimeout: "Update took too long. Please try again.";
|
|
79
85
|
readonly sendOtaStartFailed: "Failed to communicate with glasses.";
|
|
86
|
+
readonly hotspotArtifactDownloadFailed: "Could not download the update to your phone. Check phone internet and try again.";
|
|
87
|
+
readonly hotspotArtifactVerifyFailed: "The update package could not be verified. Please try again later.";
|
|
88
|
+
readonly hotspotWifiPermissionDenied: "Allow nearby devices access so the phone can connect to the glasses hotspot.";
|
|
89
|
+
readonly hotspotStartFailed: "Could not start the glasses hotspot. Please try again.";
|
|
90
|
+
readonly hotspotJoinFailed: "Could not connect the phone to the glasses hotspot. Please try again.";
|
|
91
|
+
readonly hotspotServerFailed: "Could not make the update available to the glasses. Please try again.";
|
|
80
92
|
};
|
|
81
93
|
//# sourceMappingURL=otaInstallPolicy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaInstallPolicy.d.ts","sourceRoot":"","sources":["../../src/services/otaInstallPolicy.ts"],"names":[],"mappings":"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|
export const MAX_RETRIES = 3;
|
|
9
|
+
/** Wait between ended native ota_start requests; never overlaps a pending request. */
|
|
9
10
|
export const RETRY_INTERVAL_MS = 5000;
|
|
10
11
|
/** APK/BES and general install when progress events are expected */
|
|
11
12
|
export const PROGRESS_TIMEOUT_MS = 120_000;
|
|
@@ -15,8 +16,6 @@ export const DOWNLOAD_STUCK_TIMEOUT_MS = 70_000;
|
|
|
15
16
|
export const MTK_INSTALL_TIMEOUT_MS = 300_000;
|
|
16
17
|
/** Whole multi-step session cap */
|
|
17
18
|
export const GLOBAL_OTA_TIMEOUT_MS = 20 * 60 * 1000;
|
|
18
|
-
/** After APK reboot, ASG OTA service needs time before next ota_start */
|
|
19
|
-
export const POST_APK_OTA_START_DELAY_MS = 6000;
|
|
20
19
|
/** BLE keepalive during OTA */
|
|
21
20
|
export const PING_INTERVAL_MS = 10_000;
|
|
22
21
|
/**
|
|
@@ -87,10 +86,32 @@ export function isLegacyShapedOtaSession(otaStatus, otaProgress, buildNumber) {
|
|
|
87
86
|
const build = Number.parseInt(buildNumber ?? "", 10);
|
|
88
87
|
return Number.isFinite(build) && build > 0 && build < MINIMUM_OTA_STATUS_BUILD;
|
|
89
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Select the compatibility profile once at install-screen attach. The old split
|
|
91
|
+
* routes made this decision from the pre-update build and kept it for the whole
|
|
92
|
+
* mounted flow, even when an APK step restarted into a newer ASG build. Returning
|
|
93
|
+
* null leaves the coordinator undecided until the first meaningful OTA event.
|
|
94
|
+
*/
|
|
95
|
+
export function selectOtaProtocolProfile(otaStatus, otaProgress, buildNumber) {
|
|
96
|
+
const build = Number.parseInt(buildNumber ?? "", 10);
|
|
97
|
+
if (Number.isFinite(build) && build > 0) {
|
|
98
|
+
return build < MINIMUM_OTA_STATUS_BUILD ? "legacy" : "unified";
|
|
99
|
+
}
|
|
100
|
+
if (otaStatus)
|
|
101
|
+
return isLegacyShapedOtaStatus(otaStatus) ? "legacy" : "unified";
|
|
102
|
+
if (otaProgress)
|
|
103
|
+
return "legacy";
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
90
106
|
export const OtaProgressMessages = {
|
|
91
|
-
noAckResponse: "Unable to start update. Glasses did not respond.",
|
|
92
107
|
stalledOrStuck: "Update may have failed. Ensure glasses have internet access and try again.",
|
|
93
108
|
globalTimeout: "Update took too long. Please try again.",
|
|
94
109
|
sendOtaStartFailed: "Failed to communicate with glasses.",
|
|
110
|
+
hotspotArtifactDownloadFailed: "Could not download the update to your phone. Check phone internet and try again.",
|
|
111
|
+
hotspotArtifactVerifyFailed: "The update package could not be verified. Please try again later.",
|
|
112
|
+
hotspotWifiPermissionDenied: "Allow nearby devices access so the phone can connect to the glasses hotspot.",
|
|
113
|
+
hotspotStartFailed: "Could not start the glasses hotspot. Please try again.",
|
|
114
|
+
hotspotJoinFailed: "Could not connect the phone to the glasses hotspot. Please try again.",
|
|
115
|
+
hotspotServerFailed: "Could not make the update available to the glasses. Please try again.",
|
|
95
116
|
};
|
|
96
117
|
//# sourceMappingURL=otaInstallPolicy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otaInstallPolicy.js","sourceRoot":"","sources":["../../src/services/otaInstallPolicy.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAC5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACrC,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAA;AAC1C,kDAAkD;AAClD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAC/C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAA;AAC7C,mCAAmC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;A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GAAG,EAAE,CAAA;AACnD,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAA;AAC9C,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAA2B;IACjE,OAAO,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,KAAK,EAAE,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,CAAA;AACjF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAA2B,EAC3B,WAA+B,EAC/B,WAAsC;IAEtC,IAAI,SAAS;QAAE,OAAO,uBAAuB,CAAC,SAAS,CAAC,CAAA;IACxD,IAAI,WAAW;QAAE,OAAO,IAAI,CAAA;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,wBAAwB,CAAA;AAChF,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,kDAAkD;IACjE,cAAc,EAAE,4EAA4E;IAC5F,aAAa,EAAE,yCAAyC;IACxD,kBAAkB,EAAE,qCAAqC;CACjD,CAAA","sourcesContent":["/** Shared OTA progress watchdog timings (see progress-legacy.tsx / progress.tsx). */\nimport type {OtaProgress, OtaStatus} from \"@mentra/bluetooth-sdk/internal\"\n\n/**\n * First glasses `build_number` (ASG `versionCode`) that uses `progress.tsx` with unified\n * `ota_status` session UI. Strictly lower builds use `/ota/progress-legacy` (routed from\n * `check-for-updates.tsx` before navigation), and get the LEGACY_* padded policy below\n * in the unified OtaInstallCoordinator (WP 8C). Change only here.\n */\nexport const MINIMUM_OTA_STATUS_BUILD = 37\n\nexport const MAX_RETRIES = 3\nexport const RETRY_INTERVAL_MS = 5000\n/** APK/BES and general install when progress events are expected */\nexport const PROGRESS_TIMEOUT_MS = 120_000\n/** Fail if still at 0% in starting/downloading */\nexport const DOWNLOAD_STUCK_TIMEOUT_MS = 70_000\n/** MTK system install often goes quiet for long periods */\nexport const MTK_INSTALL_TIMEOUT_MS = 300_000\n/** Whole multi-step session cap */\nexport const GLOBAL_OTA_TIMEOUT_MS = 20 * 60 * 1000\n/** After APK reboot, ASG OTA service needs time before next ota_start */\nexport const POST_APK_OTA_START_DELAY_MS = 6000\n/** BLE keepalive during OTA */\nexport const PING_INTERVAL_MS = 10_000\n/**\n * If we sent ota_query_status (e.g. on reconnect) and the glasses haven't\n * replied with an ota_status by then, fall back to ota_start. This recovers\n * from the case where the glasses process restarted between mount and\n * reconnect — the session is gone, ota_query_status returns nothing, and\n * the user would otherwise sit on the spinner forever.\n */\nexport const QUERY_REPLY_TIMEOUT_MS = 6000\n/** 15s lockout on the Continue button after a BES restart, to prevent an accidental tap. */\nexport const BES_CONTINUE_LOCKOUT_MS = 15_000\n\n// --- Legacy old-build (< MINIMUM_OTA_STATUS_BUILD) OTA policy (WP 8C) ---\n//\n// Ported verbatim from mobile/src/app/ota/progress-legacy.tsx, which padded EVERY\n// watchdog/timer by +20s for old ASG builds (\"Legacy OTA: +20s on every watchdog /\n// timer duration\"). Old builds respond slower on every path, so where the legacy\n// screen used a longer duration the coordinator applies the longer value whenever\n// the session is legacy-shaped (see isLegacyShapedOtaStatus / the coordinator's\n// session-shape check). Builds >= 37 keep the unpadded values above.\n\n/** The uniform pad progress-legacy.tsx added to every duration for old builds. */\nexport const LEGACY_EXTRA_TIMEOUT_MS = 20_000\nexport const LEGACY_RETRY_INTERVAL_MS = RETRY_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PROGRESS_TIMEOUT_MS = PROGRESS_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_DOWNLOAD_STUCK_TIMEOUT_MS = DOWNLOAD_STUCK_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_INSTALL_TIMEOUT_MS = MTK_INSTALL_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_GLOBAL_OTA_TIMEOUT_MS = GLOBAL_OTA_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PING_INTERVAL_MS = PING_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_BES_CONTINUE_LOCKOUT_MS = BES_CONTINUE_LOCKOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * After a legacy apk `install FINISHED` observed in-flight, the legacy screen held the\n * completed state for 12s (+20s pad) so the ASG process restart settles (and fresh\n * version_info lands) before the user can continue.\n */\nexport const LEGACY_APK_COMPLETION_SETTLE_MS = 12_000 + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * Legacy MTK install stall simulation (display-only): the MTK system install typically\n * stalls around 49-50%. After LEGACY_MTK_STALL_DETECT_MS without a new event in the\n * [45, 55) zone, the legacy screen simulated +1% every LEGACY_MTK_SIM_TICK_MS starting\n * at max(stall+1, 51) and capped at 60%, purely to keep the user informed.\n */\nexport const LEGACY_MTK_STALL_DETECT_MS = 20_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_SIM_TICK_MS = 15_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_STALL_ZONE_MIN_PERCENT = 45\nexport const LEGACY_MTK_STALL_ZONE_MAX_PERCENT = 55\nexport const LEGACY_MTK_SIM_FLOOR_PERCENT = 51\nexport const LEGACY_MTK_SIM_CAP_PERCENT = 60\n\n/**\n * Legacy-shaped ota_status: old (< 37) ASG builds send `ota_progress`, which the SDK\n * (Android MentraLive.kt / iOS MentraLive.swift) maps to a unified ota_status with\n * sessionId \"\" and totalSteps 1, and FINISHED→\"complete\" regardless of phase. A real\n * (>= 37) session always carries a sessionId; an \"idle\" reply also has sessionId \"\" but\n * proves the glasses speak the unified protocol, so it is NOT legacy-shaped.\n */\nexport function isLegacyShapedOtaStatus(otaStatus: OtaStatus | null): boolean {\n return !!otaStatus && otaStatus.sessionId === \"\" && otaStatus.status !== \"idle\"\n}\n\n/**\n * Is the current install session legacy-shaped? Event shape wins when events exist\n * (per the WP 8C rule: key off legacy-shaped inputs, not a build flag, where possible);\n * before any event arrives only the glasses build number can tell.\n */\nexport function isLegacyShapedOtaSession(\n otaStatus: OtaStatus | null,\n otaProgress: OtaProgress | null,\n buildNumber: string | null | undefined,\n): boolean {\n if (otaStatus) return isLegacyShapedOtaStatus(otaStatus)\n if (otaProgress) return true\n const build = Number.parseInt(buildNumber ?? \"\", 10)\n return Number.isFinite(build) && build > 0 && build < MINIMUM_OTA_STATUS_BUILD\n}\n\nexport const OtaProgressMessages = {\n noAckResponse: \"Unable to start update. Glasses did not respond.\",\n stalledOrStuck: \"Update may have failed. Ensure glasses have internet access and try again.\",\n globalTimeout: \"Update took too long. Please try again.\",\n sendOtaStartFailed: \"Failed to communicate with glasses.\",\n} as const\n"]}
|
|
1
|
+
{"version":3,"file":"otaInstallPolicy.js","sourceRoot":"","sources":["../../src/services/otaInstallPolicy.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAC5B,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACrC,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAA;AAC1C,kDAAkD;AAClD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAC/C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAA;AAC7C,mCAAmC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AACn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E,4EAA4E;IAC5F,aAAa,EAAE,yCAAyC;IACxD,kBAAkB,EAAE,qCAAqC;IACzD,6BAA6B,EAAE,kFAAkF;IACjH,2BAA2B,EAAE,mEAAmE;IAChG,2BAA2B,EAAE,8EAA8E;IAC3G,kBAAkB,EAAE,wDAAwD;IAC5E,iBAAiB,EAAE,uEAAuE;IAC1F,mBAAmB,EAAE,uEAAuE;CACpF,CAAA","sourcesContent":["/** Shared OTA progress watchdog timings (see progress-legacy.tsx / progress.tsx). */\nimport type {OtaProgress, OtaStatus} from \"@mentra/bluetooth-sdk/internal\"\n\n/**\n * First glasses `build_number` (ASG `versionCode`) that uses `progress.tsx` with unified\n * `ota_status` session UI. Strictly lower builds use `/ota/progress-legacy` (routed from\n * `check-for-updates.tsx` before navigation), and get the LEGACY_* padded policy below\n * in the unified OtaInstallCoordinator (WP 8C). Change only here.\n */\nexport const MINIMUM_OTA_STATUS_BUILD = 37\n\nexport const MAX_RETRIES = 3\n/** Wait between ended native ota_start requests; never overlaps a pending request. */\nexport const RETRY_INTERVAL_MS = 5000\n/** APK/BES and general install when progress events are expected */\nexport const PROGRESS_TIMEOUT_MS = 120_000\n/** Fail if still at 0% in starting/downloading */\nexport const DOWNLOAD_STUCK_TIMEOUT_MS = 70_000\n/** MTK system install often goes quiet for long periods */\nexport const MTK_INSTALL_TIMEOUT_MS = 300_000\n/** Whole multi-step session cap */\nexport const GLOBAL_OTA_TIMEOUT_MS = 20 * 60 * 1000\n/** BLE keepalive during OTA */\nexport const PING_INTERVAL_MS = 10_000\n/**\n * If we sent ota_query_status (e.g. on reconnect) and the glasses haven't\n * replied with an ota_status by then, fall back to ota_start. This recovers\n * from the case where the glasses process restarted between mount and\n * reconnect — the session is gone, ota_query_status returns nothing, and\n * the user would otherwise sit on the spinner forever.\n */\nexport const QUERY_REPLY_TIMEOUT_MS = 6000\n/** 15s lockout on the Continue button after a BES restart, to prevent an accidental tap. */\nexport const BES_CONTINUE_LOCKOUT_MS = 15_000\n\n// --- Legacy old-build (< MINIMUM_OTA_STATUS_BUILD) OTA policy (WP 8C) ---\n//\n// Ported verbatim from mobile/src/app/ota/progress-legacy.tsx, which padded EVERY\n// watchdog/timer by +20s for old ASG builds (\"Legacy OTA: +20s on every watchdog /\n// timer duration\"). Old builds respond slower on every path, so where the legacy\n// screen used a longer duration the coordinator applies the longer value whenever\n// the session is legacy-shaped (see isLegacyShapedOtaStatus / the coordinator's\n// session-shape check). Builds >= 37 keep the unpadded values above.\n\n/** The uniform pad progress-legacy.tsx added to every duration for old builds. */\nexport const LEGACY_EXTRA_TIMEOUT_MS = 20_000\nexport const LEGACY_RETRY_INTERVAL_MS = RETRY_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PROGRESS_TIMEOUT_MS = PROGRESS_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_DOWNLOAD_STUCK_TIMEOUT_MS = DOWNLOAD_STUCK_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_INSTALL_TIMEOUT_MS = MTK_INSTALL_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_GLOBAL_OTA_TIMEOUT_MS = GLOBAL_OTA_TIMEOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_PING_INTERVAL_MS = PING_INTERVAL_MS + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_BES_CONTINUE_LOCKOUT_MS = BES_CONTINUE_LOCKOUT_MS + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * After a legacy apk `install FINISHED` observed in-flight, the legacy screen held the\n * completed state for 12s (+20s pad) so the ASG process restart settles (and fresh\n * version_info lands) before the user can continue.\n */\nexport const LEGACY_APK_COMPLETION_SETTLE_MS = 12_000 + LEGACY_EXTRA_TIMEOUT_MS\n/**\n * Legacy MTK install stall simulation (display-only): the MTK system install typically\n * stalls around 49-50%. After LEGACY_MTK_STALL_DETECT_MS without a new event in the\n * [45, 55) zone, the legacy screen simulated +1% every LEGACY_MTK_SIM_TICK_MS starting\n * at max(stall+1, 51) and capped at 60%, purely to keep the user informed.\n */\nexport const LEGACY_MTK_STALL_DETECT_MS = 20_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_SIM_TICK_MS = 15_000 + LEGACY_EXTRA_TIMEOUT_MS\nexport const LEGACY_MTK_STALL_ZONE_MIN_PERCENT = 45\nexport const LEGACY_MTK_STALL_ZONE_MAX_PERCENT = 55\nexport const LEGACY_MTK_SIM_FLOOR_PERCENT = 51\nexport const LEGACY_MTK_SIM_CAP_PERCENT = 60\n\nexport type OtaProtocolProfile = \"legacy\" | \"unified\"\n\n/**\n * Legacy-shaped ota_status: old (< 37) ASG builds send `ota_progress`, which the SDK\n * (Android MentraLive.kt / iOS MentraLive.swift) maps to a unified ota_status with\n * sessionId \"\" and totalSteps 1, and FINISHED→\"complete\" regardless of phase. A real\n * (>= 37) session always carries a sessionId; an \"idle\" reply also has sessionId \"\" but\n * proves the glasses speak the unified protocol, so it is NOT legacy-shaped.\n */\nexport function isLegacyShapedOtaStatus(otaStatus: OtaStatus | null): boolean {\n return !!otaStatus && otaStatus.sessionId === \"\" && otaStatus.status !== \"idle\"\n}\n\n/**\n * Is the current install session legacy-shaped? Event shape wins when events exist\n * (per the WP 8C rule: key off legacy-shaped inputs, not a build flag, where possible);\n * before any event arrives only the glasses build number can tell.\n */\nexport function isLegacyShapedOtaSession(\n otaStatus: OtaStatus | null,\n otaProgress: OtaProgress | null,\n buildNumber: string | null | undefined,\n): boolean {\n if (otaStatus) return isLegacyShapedOtaStatus(otaStatus)\n if (otaProgress) return true\n const build = Number.parseInt(buildNumber ?? \"\", 10)\n return Number.isFinite(build) && build > 0 && build < MINIMUM_OTA_STATUS_BUILD\n}\n\n/**\n * Select the compatibility profile once at install-screen attach. The old split\n * routes made this decision from the pre-update build and kept it for the whole\n * mounted flow, even when an APK step restarted into a newer ASG build. Returning\n * null leaves the coordinator undecided until the first meaningful OTA event.\n */\nexport function selectOtaProtocolProfile(\n otaStatus: OtaStatus | null,\n otaProgress: OtaProgress | null,\n buildNumber: string | null | undefined,\n): OtaProtocolProfile | null {\n const build = Number.parseInt(buildNumber ?? \"\", 10)\n if (Number.isFinite(build) && build > 0) {\n return build < MINIMUM_OTA_STATUS_BUILD ? \"legacy\" : \"unified\"\n }\n if (otaStatus) return isLegacyShapedOtaStatus(otaStatus) ? \"legacy\" : \"unified\"\n if (otaProgress) return \"legacy\"\n return null\n}\n\nexport const OtaProgressMessages = {\n stalledOrStuck: \"Update may have failed. Ensure glasses have internet access and try again.\",\n globalTimeout: \"Update took too long. Please try again.\",\n sendOtaStartFailed: \"Failed to communicate with glasses.\",\n hotspotArtifactDownloadFailed: \"Could not download the update to your phone. Check phone internet and try again.\",\n hotspotArtifactVerifyFailed: \"The update package could not be verified. Please try again later.\",\n hotspotWifiPermissionDenied: \"Allow nearby devices access so the phone can connect to the glasses hotspot.\",\n hotspotStartFailed: \"Could not start the glasses hotspot. Please try again.\",\n hotspotJoinFailed: \"Could not connect the phone to the glasses hotspot. Please try again.\",\n hotspotServerFailed: \"Could not make the update available to the glasses. Please try again.\",\n} as const\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otaManifestUrl.d.ts","sourceRoot":"","sources":["../../src/services/otaManifestUrl.ts"],"names":[],"mappings":"AA6BA,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAuB5G"}
|