@mentra/engine 3.2.0-dev.180 → 3.2.0-dev.187

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +13 -0
  2. package/build/engine.d.ts +8 -0
  3. package/build/engine.d.ts.map +1 -1
  4. package/build/facades/pairing.d.ts +3 -1
  5. package/build/facades/pairing.d.ts.map +1 -1
  6. package/build/facades/pairing.js +9 -0
  7. package/build/facades/pairing.js.map +1 -1
  8. package/build/facades/phoneNotifications.d.ts +9 -0
  9. package/build/facades/phoneNotifications.d.ts.map +1 -1
  10. package/build/facades/phoneNotifications.js +15 -0
  11. package/build/facades/phoneNotifications.js.map +1 -1
  12. package/build/generated/releaseMetadata.js +5 -5
  13. package/build/generated/releaseMetadata.js.map +1 -1
  14. package/build/services/NativeNotificationPolicy.d.ts +13 -0
  15. package/build/services/NativeNotificationPolicy.d.ts.map +1 -0
  16. package/build/services/NativeNotificationPolicy.js +12 -0
  17. package/build/services/NativeNotificationPolicy.js.map +1 -0
  18. package/build/services/PhoneNotificationsSync.d.ts +13 -0
  19. package/build/services/PhoneNotificationsSync.d.ts.map +1 -1
  20. package/build/services/PhoneNotificationsSync.js +102 -26
  21. package/build/services/PhoneNotificationsSync.js.map +1 -1
  22. package/build/stores/settings.d.ts.map +1 -1
  23. package/build/stores/settings.js +30 -0
  24. package/build/stores/settings.js.map +1 -1
  25. package/build/types/capabilities/even-realities-g2.d.ts.map +1 -1
  26. package/build/types/capabilities/even-realities-g2.js +1 -0
  27. package/build/types/capabilities/even-realities-g2.js.map +1 -1
  28. package/build/types/hardware.d.ts +2 -0
  29. package/build/types/hardware.d.ts.map +1 -1
  30. package/build/types/hardware.js.map +1 -1
  31. package/package.json +7 -7
  32. package/src/facades/pairing.ts +16 -1
  33. package/src/facades/phoneNotifications.ts +21 -0
  34. package/src/generated/releaseMetadata.ts +5 -5
  35. package/src/services/NativeNotificationPolicy.ts +24 -0
  36. package/src/services/PhoneNotificationsSync.ts +115 -31
  37. package/src/stores/settings.ts +34 -7
  38. package/src/types/capabilities/even-realities-g2.ts +1 -0
  39. package/src/types/hardware.ts +2 -0
package/README.md CHANGED
@@ -132,3 +132,16 @@ combined run. Per-file processes give every suite an isolated registry.
132
132
  The same rule applies when writing tests: it is fine to `mock.module` any
133
133
  specifier your suite needs, but never rely on a mock installed by a
134
134
  _different_ test file — each file must set up everything it imports.
135
+
136
+ ## Phone notification presentation
137
+
138
+ `engine.phoneNotifications` owns native-notification configuration alongside the existing Android listener kill switch and per-app blocklist. Capture remains independent of presentation. A host starts/stops its presentation owner with `setPresentationActive(boolean)`; the Mentra App uses Notify's running state on both platforms.
139
+
140
+ - `nativeCapabilities()` distinguishes native presentation, phone content access, app filtering, and removal support.
141
+ - `nativeStatus()` / `onNativeStatus(listener)` expose native availability, authorization, desired controls, and failures.
142
+ - `usesNativePresentation()` selects firmware presentation. A host forwards its captured event through `presentNative(event)` and skips its local card for that event. This does not replace permission-gated miniapp forwarding.
143
+ - `onNativeDelivery(listener)` exposes Android transfer outcomes without message content.
144
+
145
+ Settings are `native_notifications_enabled`, `native_notifications_auto_display`, `native_notifications_duration`, and `native_notifications_do_not_disturb`. Native presentation defaults off. The Android `notifications_blocklist` is also passed to native configuration so pending work is invalidated when filtering changes. Disconnected events are not retained for replay.
146
+
147
+ On iOS, G2 receives ANCS directly; the host does not upload the app-identity relay back to the glasses. Full title/body access, editing the firmware app filter, and phone-dismissal synchronization remain unsupported. The existing G2 app-identity event is not evidence of full content access.
package/build/engine.d.ts CHANGED
@@ -208,6 +208,7 @@ export declare const engine: {
208
208
  onIdentity: (cb: (identity: import(".").IdentitySnapshot) => void) => (() => void);
209
209
  markPendingSelection: (model: string) => import("typesafe-ts").AsyncResult<void, Error>;
210
210
  scan: (model: import("@mentra/bluetooth-sdk").DeviceModel) => Promise<void>;
211
+ diagnoseEmptyScan: (model: import("@mentra/bluetooth-sdk").DeviceModel) => Promise<import("@mentra/bluetooth-sdk").ScanDiagnostic | null>;
211
212
  scanning: () => boolean;
212
213
  onScanning: (cb: (scanning: boolean) => void) => (() => void);
213
214
  scanningController: () => boolean;
@@ -237,6 +238,13 @@ export declare const engine: {
237
238
  };
238
239
  /** Phone→glasses notification forwarding (Android). */
239
240
  phoneNotifications: {
241
+ nativeCapabilities: typeof import("./services/PhoneNotificationsSync").nativeNotificationCapabilities;
242
+ setPresentationActive: typeof import("./services/PhoneNotificationsSync").setPhoneNotificationPresentationActive;
243
+ usesNativePresentation: typeof import("./services/PhoneNotificationsSync").usesNativeNotificationPresentation;
244
+ presentNative: typeof import("./services/PhoneNotificationsSync").presentNativePhoneNotification;
245
+ nativeStatus: () => Promise<import("@mentra/bluetooth-sdk").NativeNotificationStatus>;
246
+ onNativeStatus: (listener: (status: import("@mentra/bluetooth-sdk").NativeNotificationStatus) => void) => () => void;
247
+ onNativeDelivery: (listener: (event: import("@mentra/bluetooth-sdk").NativeNotificationDelivery) => void) => () => void;
240
248
  installedApps: () => Promise<Array<{
241
249
  packageName: string;
242
250
  appName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,SAAS,EAIT,aAAa,EACd,MAAM,qBAAqB,CAAA;AAuC5B,eAAO,MAAM,MAAM;IACjB,2EAA2E;;IAE3E,8EAA8E;;IAE9E;iDAC6C;;IAkF7C;;yCAEqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BrC,mFAAmF;;;;;;;;IAEnF,sEAAsE;;;;;;;;;;;;IAEtE,qFAAqF;;;gBApGjF,CAAL;mBAAiB,CAAC;;;gBAKX,CAAC;mBAAiB,CAAC;;;;;;;;;;;;;;;;IAiGzB,qEAAqE;;;;IAErE,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEtF,6EAA6E;;;;;;;;;;;;IAE7E,iFAAiF;;;;;;;;;;;;;;;;;;;IAEjF,8CAA8C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAE9C,uDAAuD;;;;;;;;;;;;IAEvD,8EAA8E;;;;;;;IAE9E,qFAAqF;;;;;;;;;;;;;;CAGtF,CAAA"}
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,SAAS,EAIT,aAAa,EACd,MAAM,qBAAqB,CAAA;AAuC5B,eAAO,MAAM,MAAM;IACjB,2EAA2E;;IAE3E,8EAA8E;;IAE9E;iDAC6C;;IAkF7C;;yCAEqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BrC,mFAAmF;;;;;;;;IAEnF,sEAAsE;;;;;;;;;;;;IAEtE,qFAAqF;;;gBApGjF,CAAL;mBAAiB,CAAC;;;gBAKX,CAAC;mBAAiB,CAAC;;;;;;;;;;;;;;;;IAiGzB,qEAAqE;;;;IAErE,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEtF,6EAA6E;;;;;;;;;;;;IAE7E,iFAAiF;;;;;;;;;;;;;;;;;;;IAEjF,8CAA8C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAE9C,uDAAuD;;;;;;;;;;;;;;;;;;;IAEvD,8EAA8E;;;;;;;IAE9E,qFAAqF;;;;;;;;;;;;;;CAGtF,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { ConnectOptions, Device, DeviceModel, PairFailureEvent, GlassesNotReadyEvent } from "@mentra/bluetooth-sdk";
1
+ import type { ConnectOptions, Device, DeviceModel, PairFailureEvent, GlassesNotReadyEvent, ScanDiagnostic } from "@mentra/bluetooth-sdk";
2
2
  import { type IdentitySnapshot } from "../services/PairingIdentity";
3
3
  import { type AutomaticReportSubmissionStatus } from "../services/AutomaticReportResult";
4
4
  export type { IdentitySnapshot } from "../services/PairingIdentity";
@@ -43,6 +43,8 @@ export declare const pairing: {
43
43
  markPendingSelection: (model: string) => import("typesafe-ts").AsyncResult<void, Error>;
44
44
  /** Start scanning for nearby glasses. Results land on `searchResults()`/`onFound()`. */
45
45
  scan: (model: DeviceModel) => Promise<void>;
46
+ /** Best-effort advisory after a caller-managed scan completes empty. */
47
+ diagnoseEmptyScan: (model: DeviceModel) => Promise<ScanDiagnostic | null>;
46
48
  /** Whether a scan is currently in progress. */
47
49
  scanning: () => boolean;
48
50
  /** Subscribe to scan-in-progress changes; fires only when it changes. Returns an unsubscribe. */
@@ -1 +1 @@
1
- {"version":3,"file":"pairing.d.ts","sourceRoot":"","sources":["../../src/facades/pairing.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,uBAAuB,CAAA;AAKtH,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAGL,KAAK,+BAA+B,EACrC,MAAM,mCAAmC,CAAA;AAK1C,YAAY,EAAC,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAEjE,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAOD,iBAAS,gBAAgB;;;;;;EASxB;AA8ED,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE1E,wBAAsB,8BAA8B,CAAC,MAAM,EAAE;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kBA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+C;oBACjC,OAAO;IACrB,iGAAiG;qBAChF,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;IAC3D,0DAA0D;8BAClC,OAAO;IAC/B,4GAA4G;+BACjF,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;IAErE,sGAAsG;4BAChF,OAAO;IAC7B,iHAAiH;6BACxF,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;IAEpE,2CAA2C;;;;;;;;;;;;IAI3C,6FAA6F;kBAC/E,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;IAYxD;;;;;;OAMG;mBACkB,MAAM,YAAY,cAAc,KAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,6EAA6E;yBACxD,MAAM,GAAG,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC;IAClD;;;;;;;;OAQG;wCACiC,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;IAE1D;;;;;;;;;;;;;;;;;;OAkBG;0BACuB,OAAO,CAAC,IAAI,CAAC;IAmCvC,6DAA6D;wBACzC,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;IAIpE,oFAAoF;4BAC5D,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;IAI5E,sFAAsF;;IAEtF,uEAAuE;;CAExE,CAAA"}
@@ -228,6 +228,15 @@ export const pairing = {
228
228
  markPendingSelection: (model) => markPendingSelection(model),
229
229
  /** Start scanning for nearby glasses. Results land on `searchResults()`/`onFound()`. */
230
230
  scan: (model) => BluetoothSdk.startScan(model),
231
+ /** Best-effort advisory after a caller-managed scan completes empty. */
232
+ diagnoseEmptyScan: async (model) => {
233
+ try {
234
+ return (await BluetoothSdk.getScanDiagnostic?.(model)) ?? null;
235
+ }
236
+ catch {
237
+ return null;
238
+ }
239
+ },
231
240
  /** Whether a scan is currently in progress. */
232
241
  scanning: () => useCoreStore.getState().searching,
233
242
  /** Subscribe to scan-in-progress changes; fires only when it changes. Returns an unsubscribe. */
@@ -1 +1 @@
1
- {"version":3,"file":"pairing.js","sourceRoot":"","sources":["../../src/facades/pairing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,0EAA0E;AAC1E,4EAA4E;AAC5E,wCAAwC;AACxC,OAAO,YAAY,MAAM,gCAAgC,CAAA;AAEzD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAA;AACjE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GAEzB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAA;AACvG,OAAO,EACL,kCAAkC,EAClC,iCAAiC,GAElC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAC,wBAAwB,EAAC,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AACxC,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAA;AAY/C,MAAM,+BAA+B,GAAG,MAAM,CAAA;AAC9C,MAAM,6BAA6B,GAAG,KAAK,CAAA;AAC3C,MAAM,qBAAqB,GAAG,kBAAkB,CAAA;AAChD,MAAM,OAAO,GAAG,sBAAsB,CAAA;AAEtC,SAAS,gBAAgB;IACvB,MAAM,CAAC,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAA;IACpC,OAAO;QACL,KAAK,EAAE,CAAC,CAAC,UAAU,C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AAA;QAC7D,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;IAC3B,CAAC;IACD,sFAAsF;IACtF,YAAY,EAAE,yBAAyB;IACvC,uEAAuE;IACvE,uBAAuB;CACxB,CAAA","sourcesContent":["/**\n * pairing facade — `engine.pairing`: scan for nearby glasses + pair. Scan state\n * (searching + results) comes from the engine core store; scan/connect go over the\n * bluetooth-sdk; pair-failure / not-ready are the bluetooth-sdk events.\n *\n * (Connect-the-already-paired-default is `engine.glasses.connectDefault()`; this\n * facade is the first-time discovery + pair flow.)\n */\n// Internal btsdk surface — updateBluetoothSettings (the Bluetooth Classic\n// target hint) lives on the full surface, not the public entry (same reason\n// the glasses facade imports internal).\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport type {ConnectOptions, Device, DeviceModel, PairFailureEvent, GlassesNotReadyEvent} from \"@mentra/bluetooth-sdk\"\nimport {useCoreStore} from \"../stores/core\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {hasDefaultDevice} from \"../services/DeviceStoreHydration\"\nimport {\n markPendingSelection,\n projectPairingIdentity,\n subscribePairingIdentity,\n type IdentitySnapshot,\n} from \"../services/PairingIdentity\"\nimport {isGlassesConnected, isGlassesLinkLayerBusy, isGlassesReady} from \"../services/GlassesReadiness\"\nimport {\n logAutomaticReportSubmissionStatus,\n toAutomaticReportSubmissionStatus,\n type AutomaticReportSubmissionStatus,\n} from \"../services/AutomaticReportResult\"\nimport {pushAllBluetoothSettings} from \"../services/GlassesSettingsSync\"\nimport {ControllerTypes} from \"../types\"\nimport {submitAutomaticReport} from \"./reports\"\n\nexport type {IdentitySnapshot} from \"../services/PairingIdentity\"\n\nexport interface PairingReadyWaitOptions {\n deviceModel?: string\n deviceName?: string\n timeoutMs?: number\n route?: string\n signal?: AbortSignal\n}\n\nconst DEFAULT_PAIRING_BOOT_TIMEOUT_MS = 35_000\nconst DEFAULT_BT_CLASSIC_TIMEOUT_MS = 1_000\nconst DEFAULT_PAIRING_ROUTE = \"/pairing/loading\"\nconst LOG_TAG = \"PairingTimeoutReport\"\n\nfunction projectReadiness() {\n const s = useGlassesStore.getState()\n return {\n state: s.connection.state,\n connected: s.connection.state === \"connected\",\n fullyBooted: isGlassesReady(s.connection),\n bluetoothClassicConnected: s.bluetoothClassicConnected,\n nativeLinkBusy: isGlassesLinkLayerBusy(s.connection),\n }\n}\n\nfunction projectTargetReady(options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">): boolean {\n const {deviceModel, deviceName} = options\n const glasses = useGlassesStore.getState()\n\n if (deviceModel === ControllerTypes.R1) {\n if (!glasses.controllerConnected || !glasses.controllerFullyBooted) return false\n const settings = useSettingsStore.getState()\n const pairedModel = settings.getSetting(SETTINGS.default_controller.key)\n const pairedName = settings.getSetting(SETTINGS.controller_device_name.key)\n return (!deviceModel || pairedModel === deviceModel) && (!deviceName || pairedName === deviceName)\n }\n\n if (!isGlassesReady(glasses.connection)) return false\n const identity = projectPairingIdentity()\n if (!deviceModel && !deviceName) return true\n return (\n identity.kind === \"paired\" &&\n (!deviceModel || identity.model === deviceModel) &&\n (!deviceName || identity.name === deviceName)\n )\n}\n\nfunction subscribeTargetReady(\n options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">,\n cb: (ready: boolean) => void,\n): () => void {\n let last = projectTargetReady(options)\n const notify = () => {\n const ready = projectTargetReady(options)\n if (ready === last) return\n last = ready\n cb(ready)\n }\n const unsubscribeGlasses = useGlassesStore.subscribe(notify)\n const unsubscribeSettings = useSettingsStore.subscribe(notify)\n return () => {\n unsubscribeGlasses()\n unsubscribeSettings()\n }\n}\n\nasync function waitForTargetReady(options: PairingReadyWaitOptions, timeoutMs: number): Promise<boolean> {\n return new Promise((resolve) => {\n if (options.signal?.aborted) {\n resolve(false)\n return\n }\n if (projectTargetReady(options)) {\n resolve(true)\n return\n }\n\n let settled = false\n let timeout: ReturnType<typeof setTimeout> | null = null\n let unsubscribe: (() => void) | null = null\n let onAbort: (() => void) | null = null\n const finish = (ready: boolean) => {\n if (settled) return\n settled = true\n if (timeout) clearTimeout(timeout)\n if (unsubscribe) unsubscribe()\n if (onAbort && options.signal) options.signal.removeEventListener(\"abort\", onAbort)\n resolve(ready)\n }\n\n unsubscribe = subscribeTargetReady(options, (ready) => {\n if (ready) finish(true)\n })\n if (options.signal) {\n onAbort = () => finish(false)\n options.signal.addEventListener(\"abort\", onAbort)\n }\n timeout = setTimeout(() => finish(projectTargetReady(options)), timeoutMs)\n })\n}\n\nexport type PairingReadinessSnapshot = ReturnType<typeof projectReadiness>\n\nexport async function submitPairingBootTimeoutReport(params: {\n deviceModel?: string\n deviceName?: string\n showGlassesBooting: boolean\n elapsedMs: number\n route?: string\n}): Promise<AutomaticReportSubmissionStatus> {\n const {deviceModel, deviceName, showGlassesBooting, elapsedMs, route = DEFAULT_PAIRING_ROUTE} = params\n const result = await submitAutomaticReport({\n kind: \"automatic\",\n trigger: {\n type: \"automatic\",\n source: \"pairing_loading\",\n reason: \"glasses_connect_timeout\",\n },\n report: {\n expectedBehavior: `Glasses should connect successfully within ${Math.round(elapsedMs / 1000)} seconds.`,\n actualBehavior: JSON.stringify(\n {\n deviceModel,\n deviceName,\n showGlassesBooting,\n elapsedMs,\n route,\n },\n null,\n 2,\n ),\n systemPriority: \"medium\",\n },\n throttleKey: `pairing_timeout|${deviceModel || \"unknown\"}|${deviceName || \"unknown\"}`,\n })\n\n const status = toAutomaticReportSubmissionStatus(result)\n logAutomaticReportSubmissionStatus(LOG_TAG, status, deviceModel, deviceName)\n return status\n}\n\nasync function waitForReadyDuringPairing(options: PairingReadyWaitOptions = {}): Promise<boolean> {\n const timeoutMs = options.timeoutMs ?? DEFAULT_PAIRING_BOOT_TIMEOUT_MS\n let showGlassesBooting = false\n const notReadySub = BluetoothSdk.addListener(\"glasses_not_ready\", () => {\n showGlassesBooting = true\n })\n\n try {\n const ready = await waitForTargetReady(options, timeoutMs)\n\n if (!ready && !options.signal?.aborted) {\n void submitPairingBootTimeoutReport({\n deviceModel: options.deviceModel,\n deviceName: options.deviceName,\n showGlassesBooting,\n elapsedMs: timeoutMs,\n route: options.route,\n }).catch((error) => {\n console.error(`[${LOG_TAG}] Unexpected error:`, error)\n })\n }\n\n return ready\n } finally {\n notReadySub.remove()\n }\n}\n\nasync function waitForBluetoothClassic(\n options: Pick<PairingReadyWaitOptions, \"timeoutMs\" | \"signal\"> = {},\n): Promise<boolean> {\n const timeoutMs = options.timeoutMs ?? DEFAULT_BT_CLASSIC_TIMEOUT_MS\n return new Promise((resolve) => {\n if (options.signal?.aborted) {\n resolve(false)\n return\n }\n\n const initial = useGlassesStore.getState().bluetoothClassicConnected\n if (initial) {\n resolve(true)\n return\n }\n\n let settled = false\n let timeout: ReturnType<typeof setTimeout> | null = null\n let unsubscribe: (() => void) | null = null\n let onAbort: (() => void) | null = null\n\n const finish = (value: boolean) => {\n if (settled) return\n settled = true\n if (timeout) clearTimeout(timeout)\n if (unsubscribe) unsubscribe()\n if (onAbort && options.signal) options.signal.removeEventListener(\"abort\", onAbort)\n resolve(value)\n }\n\n if (options.signal) {\n onAbort = () => finish(false)\n options.signal.addEventListener(\"abort\", onAbort)\n }\n\n unsubscribe = useGlassesStore.subscribe(\n (s) => s.bluetoothClassicConnected,\n (connected) => {\n if (connected) finish(true)\n },\n )\n\n timeout = setTimeout(() => {\n finish(useGlassesStore.getState().bluetoothClassicConnected)\n }, timeoutMs)\n })\n}\n\nexport const pairing = {\n readiness: (): PairingReadinessSnapshot => projectReadiness(),\n onReadiness: (cb: (readiness: PairingReadinessSnapshot) => void): (() => void) => {\n let last = JSON.stringify(projectReadiness())\n return useGlassesStore.subscribe(() => {\n const snap = projectReadiness()\n const key = JSON.stringify(snap)\n if (key === last) return\n last = key\n cb(snap)\n })\n },\n /** Whether the exact wearable or controller selected on the scan screen is ready. */\n targetReady: (options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">): boolean =>\n projectTargetReady(options),\n /** Subscribe to readiness for the exact selected target, excluding stale devices. */\n onTargetReady: (\n options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">,\n cb: (ready: boolean) => void,\n ): (() => void) => subscribeTargetReady(options, cb),\n\n // --- pairing-identity lifecycle (the PairingIdentity read-model + the JS-owned\n // identity writes; promotion to `paired` only ever happens natively) ---\n /** The identity lifecycle snapshot: none | pending (chosen, never paired) | paired. */\n identity: (): IdentitySnapshot => projectPairingIdentity(),\n /** Subscribe to identity changes; fires only when the projected snapshot changes.\n * Returns an unsubscribe. */\n onIdentity: (cb: (identity: IdentitySnapshot) => void): (() => void) => subscribePairingIdentity(cb),\n /** Mark the chosen model as the pending selection (the scan-entry write); the\n * host renders it as a finish-pairing affordance until pairing succeeds. */\n markPendingSelection: (model: string) => markPendingSelection(model),\n\n /** Start scanning for nearby glasses. Results land on `searchResults()`/`onFound()`. */\n scan: (model: DeviceModel): Promise<void> => BluetoothSdk.startScan(model),\n /** Whether a scan is currently in progress. */\n scanning: (): boolean => useCoreStore.getState().searching,\n /** Subscribe to scan-in-progress changes; fires only when it changes. Returns an unsubscribe. */\n onScanning: (cb: (scanning: boolean) => void): (() => void) => useCoreStore.subscribe((s) => s.searching, cb),\n /** Whether a controller scan is currently in progress. */\n scanningController: (): boolean => useCoreStore.getState().searchingController,\n /** Subscribe to controller-scan-in-progress changes; fires only when it changes. Returns an unsubscribe. */\n onScanningController: (cb: (scanning: boolean) => void): (() => void) =>\n useCoreStore.subscribe((s) => s.searchingController, cb),\n /** Whether the phone has another Bluetooth (audio) device connected — the BT Classic pairing hint. */\n otherBtConnected: (): boolean => useCoreStore.getState().otherBtConnected,\n /** Subscribe to other-Bluetooth-device-connected changes; fires only when it changes. Returns an unsubscribe. */\n onOtherBtConnected: (cb: (connected: boolean) => void): (() => void) =>\n useCoreStore.subscribe((s) => s.otherBtConnected, cb),\n /** The current scan results (snapshot). */\n // Copy the array AND each entry: neither the list nor the Device objects may\n // leak as mutable references into the store.\n searchResults: () => useCoreStore.getState().searchResults.map((result) => ({...result})),\n /** Subscribe to scan-result changes; fires only when they change. Returns an unsubscribe. */\n onFound: (cb: (results: Device[]) => void): (() => void) => {\n let last = JSON.stringify(useCoreStore.getState().searchResults)\n return useCoreStore.subscribe(() => {\n const results = useCoreStore.getState().searchResults\n const key = JSON.stringify(results)\n if (key === last) return\n last = key\n // Copy like searchResults(): listeners must not mutate shared scan state.\n cb(results.map((result) => ({...result})))\n })\n },\n\n /**\n * Pair with (connect to) a discovered device. Two-phase identity: the connect\n * attempt only marks the device as pending (`saveAsDefault: false` — no eager\n * default-device write); the native layer promotes it to the default wearable\n * when pairing actually succeeds (handleDeviceReady), so an abandoned or\n * failed attempt can't leave a default identity with no paired device behind.\n */\n pair: async (device: Device, options?: ConnectOptions): Promise<void> => {\n await pushAllBluetoothSettings()\n return BluetoothSdk.connect(device, {...options, saveAsDefault: false})\n },\n /** Set a device as the default for subsequent `glasses.connectDefault()`. */\n setDefault: (device: Device | null): Promise<void> => BluetoothSdk.setDefaultDevice(device),\n /**\n * Prime the native Bluetooth Classic audio watcher with the picked device.\n * The iOS Mentra Live flow pairs Classic audio BEFORE any BLE connect\n * exists, and native detects the pairing by matching the connected audio\n * route against its device_name — which two-phase identity no longer sets\n * at selection time. This is native-only routing state (device_name has no\n * native→JS echo): the phone's persisted identity is untouched, and\n * promotion still happens only at pairing success.\n */\n setBluetoothClassicTarget: (device: Device): Promise<void> =>\n BluetoothSdk.updateBluetoothSettings({device_name: device.name}),\n /**\n * Abandon an in-flight pairing attempt (back-out, failure retry, conflict\n * retry) without destroying an existing pairing. The decision comes from the\n * LIVE hydrated default-device read — never from flow-entry state, because a\n * pairing can PROMOTE while the flow is open (the glasses finish pairing\n * even as the user backs out of the UI), and an entry snapshot would forget\n * that brand-new pairing:\n * - Default device exists and glasses are connected (nothing in flight — an\n * attempt drops the link first): stop the scan, touch nothing else.\n * - Default device exists with an attempt in flight: cancel it, then re-seed\n * the native identity from the phone's persisted settings — the attempt's\n * connect-by-name overwrote the native device_name, so a later\n * connectDefault() would otherwise target the abandoned device.\n * - No default device (genuinely unpaired attempt): also forget, clearing\n * the partial native pairing state.\n * The read fails OPEN to \"preserve\" — a transient failure must never wipe a\n * real pairing. The `pending_wearable` marker is deliberately left alone —\n * the host renders it as a finish-pairing affordance.\n */\n abandonAttempt: async (): Promise<void> => {\n const nativeHasDefault = await hasDefaultDevice().catch(() => true)\n if (nativeHasDefault && isGlassesConnected(useGlassesStore.getState().connection)) {\n // Still connected means no connect attempt is in flight (an attempt drops\n // the existing link first): the user browsed the scan and backed out.\n // Stop the scan and leave the live pairing untouched.\n console.log(\"PairingIdentity: abandonAttempt — pairing intact and connected; stopping scan only\")\n await BluetoothSdk.stopScan()\n return\n }\n if (projectPairingIdentity().kind === \"paired\") {\n // The persisted settings describe a COMPLETE pairing: restore it to\n // native (the attempt's connect-by-name overwrote the native\n // device_name; and if native somehow lost its default entirely, this\n // repairs the divergence instead of forgetting a real pairing).\n console.log(\"PairingIdentity: abandonAttempt — preserving pairing; attempt cancelled, native identity re-seeded\")\n await BluetoothSdk.disconnect()\n await pushAllBluetoothSettings()\n return\n }\n if (nativeHasDefault) {\n // Mid-relay: native promoted and its echoes are still landing — the\n // incomplete JS snapshot must not be pushed over the fresher native\n // identity (the on-connect replay's race). Native holds the truth.\n console.log(\"PairingIdentity: abandonAttempt — preserving pairing; JS identity mid-relay, native kept as-is\")\n await BluetoothSdk.disconnect()\n return\n }\n // Partial attempt: forget owns teardown. Do NOT disconnect() first — that\n // nulls the MentraLive SGC and used to skip Classic removeBond, leaving\n // IBRT ACL up so glasses never re-advertise for the next scan.\n console.log(\"PairingIdentity: abandonAttempt — no pairing on either layer; forgetting the partial attempt\")\n await BluetoothSdk.forget()\n },\n\n /** Subscribe to pairing failures; returns an unsubscribe. */\n onPairFailure: (cb: (event: PairFailureEvent) => void): (() => void) => {\n const sub = BluetoothSdk.addListener(\"pair_failure\", cb)\n return () => sub.remove()\n },\n /** Subscribe to glasses-not-ready events during pairing; returns an unsubscribe. */\n onGlassesNotReady: (cb: (event: GlassesNotReadyEvent) => void): (() => void) => {\n const sub = BluetoothSdk.addListener(\"glasses_not_ready\", cb)\n return () => sub.remove()\n },\n /** Wait for paired glasses to finish booting; engine files the timeout diagnostic. */\n waitForReady: waitForReadyDuringPairing,\n /** Wait briefly for Bluetooth Classic to come up after BLE pairing. */\n waitForBluetoothClassic,\n}\n"]}
1
+ {"version":3,"file":"pairing.js","sourceRoot":"","sources":["../../src/facades/pairing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,0EAA0E;AAC1E,4EAA4E;AAC5E,wCAAwC;AACxC,OAAO,YAAY,MAAM,gCAAgC,CAAA;AASzD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAA;AACjE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GAEzB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAC,MAAM,8BAA8B,CAAA;AACvG,OAAO,EACL,kCAAkC,EAClC,iCAAiC,GAElC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAC,wBAAwB,EAAC,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AACxC,OAAO,EAAC,qBAAqB,EAAC,MAAM,WAAW,CAAA;AAY/C,MAAM,+BAA+B,GAAG,MAAM,CAAA;AAC9C,MAAM,6BAA6B,GAAG,KAAK,CAAA;AAC3C,MAAM,qBAAqB,GAAG,kBAAkB,CAAA;AAChD,MAAM,OAAO,GAAG,sBAAsB,CA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,MAAM,EAAE,CAAA;IAC7B,CAAC;IAED,6DAA6D;IAC7D,aAAa,EAAE,CAAC,EAAqC,EAAgB,EAAE;QACrE,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;QACxD,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;IAC3B,CAAC;IACD,oFAAoF;IACpF,iBAAiB,EAAE,CAAC,EAAyC,EAAgB,EAAE;QAC7E,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAA;QAC7D,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;IAC3B,CAAC;IACD,sFAAsF;IACtF,YAAY,EAAE,yBAAyB;IACvC,uEAAuE;IACvE,uBAAuB;CACxB,CAAA","sourcesContent":["/**\n * pairing facade — `engine.pairing`: scan for nearby glasses + pair. Scan state\n * (searching + results) comes from the engine core store; scan/connect go over the\n * bluetooth-sdk; pair-failure / not-ready are the bluetooth-sdk events.\n *\n * (Connect-the-already-paired-default is `engine.glasses.connectDefault()`; this\n * facade is the first-time discovery + pair flow.)\n */\n// Internal btsdk surface — updateBluetoothSettings (the Bluetooth Classic\n// target hint) lives on the full surface, not the public entry (same reason\n// the glasses facade imports internal).\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport type {\n ConnectOptions,\n Device,\n DeviceModel,\n PairFailureEvent,\n GlassesNotReadyEvent,\n ScanDiagnostic,\n} from \"@mentra/bluetooth-sdk\"\nimport {useCoreStore} from \"../stores/core\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {SETTINGS, useSettingsStore} from \"../stores/settings\"\nimport {hasDefaultDevice} from \"../services/DeviceStoreHydration\"\nimport {\n markPendingSelection,\n projectPairingIdentity,\n subscribePairingIdentity,\n type IdentitySnapshot,\n} from \"../services/PairingIdentity\"\nimport {isGlassesConnected, isGlassesLinkLayerBusy, isGlassesReady} from \"../services/GlassesReadiness\"\nimport {\n logAutomaticReportSubmissionStatus,\n toAutomaticReportSubmissionStatus,\n type AutomaticReportSubmissionStatus,\n} from \"../services/AutomaticReportResult\"\nimport {pushAllBluetoothSettings} from \"../services/GlassesSettingsSync\"\nimport {ControllerTypes} from \"../types\"\nimport {submitAutomaticReport} from \"./reports\"\n\nexport type {IdentitySnapshot} from \"../services/PairingIdentity\"\n\nexport interface PairingReadyWaitOptions {\n deviceModel?: string\n deviceName?: string\n timeoutMs?: number\n route?: string\n signal?: AbortSignal\n}\n\nconst DEFAULT_PAIRING_BOOT_TIMEOUT_MS = 35_000\nconst DEFAULT_BT_CLASSIC_TIMEOUT_MS = 1_000\nconst DEFAULT_PAIRING_ROUTE = \"/pairing/loading\"\nconst LOG_TAG = \"PairingTimeoutReport\"\n\nfunction projectReadiness() {\n const s = useGlassesStore.getState()\n return {\n state: s.connection.state,\n connected: s.connection.state === \"connected\",\n fullyBooted: isGlassesReady(s.connection),\n bluetoothClassicConnected: s.bluetoothClassicConnected,\n nativeLinkBusy: isGlassesLinkLayerBusy(s.connection),\n }\n}\n\nfunction projectTargetReady(options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">): boolean {\n const {deviceModel, deviceName} = options\n const glasses = useGlassesStore.getState()\n\n if (deviceModel === ControllerTypes.R1) {\n if (!glasses.controllerConnected || !glasses.controllerFullyBooted) return false\n const settings = useSettingsStore.getState()\n const pairedModel = settings.getSetting(SETTINGS.default_controller.key)\n const pairedName = settings.getSetting(SETTINGS.controller_device_name.key)\n return (!deviceModel || pairedModel === deviceModel) && (!deviceName || pairedName === deviceName)\n }\n\n if (!isGlassesReady(glasses.connection)) return false\n const identity = projectPairingIdentity()\n if (!deviceModel && !deviceName) return true\n return (\n identity.kind === \"paired\" &&\n (!deviceModel || identity.model === deviceModel) &&\n (!deviceName || identity.name === deviceName)\n )\n}\n\nfunction subscribeTargetReady(\n options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">,\n cb: (ready: boolean) => void,\n): () => void {\n let last = projectTargetReady(options)\n const notify = () => {\n const ready = projectTargetReady(options)\n if (ready === last) return\n last = ready\n cb(ready)\n }\n const unsubscribeGlasses = useGlassesStore.subscribe(notify)\n const unsubscribeSettings = useSettingsStore.subscribe(notify)\n return () => {\n unsubscribeGlasses()\n unsubscribeSettings()\n }\n}\n\nasync function waitForTargetReady(options: PairingReadyWaitOptions, timeoutMs: number): Promise<boolean> {\n return new Promise((resolve) => {\n if (options.signal?.aborted) {\n resolve(false)\n return\n }\n if (projectTargetReady(options)) {\n resolve(true)\n return\n }\n\n let settled = false\n let timeout: ReturnType<typeof setTimeout> | null = null\n let unsubscribe: (() => void) | null = null\n let onAbort: (() => void) | null = null\n const finish = (ready: boolean) => {\n if (settled) return\n settled = true\n if (timeout) clearTimeout(timeout)\n if (unsubscribe) unsubscribe()\n if (onAbort && options.signal) options.signal.removeEventListener(\"abort\", onAbort)\n resolve(ready)\n }\n\n unsubscribe = subscribeTargetReady(options, (ready) => {\n if (ready) finish(true)\n })\n if (options.signal) {\n onAbort = () => finish(false)\n options.signal.addEventListener(\"abort\", onAbort)\n }\n timeout = setTimeout(() => finish(projectTargetReady(options)), timeoutMs)\n })\n}\n\nexport type PairingReadinessSnapshot = ReturnType<typeof projectReadiness>\n\nexport async function submitPairingBootTimeoutReport(params: {\n deviceModel?: string\n deviceName?: string\n showGlassesBooting: boolean\n elapsedMs: number\n route?: string\n}): Promise<AutomaticReportSubmissionStatus> {\n const {deviceModel, deviceName, showGlassesBooting, elapsedMs, route = DEFAULT_PAIRING_ROUTE} = params\n const result = await submitAutomaticReport({\n kind: \"automatic\",\n trigger: {\n type: \"automatic\",\n source: \"pairing_loading\",\n reason: \"glasses_connect_timeout\",\n },\n report: {\n expectedBehavior: `Glasses should connect successfully within ${Math.round(elapsedMs / 1000)} seconds.`,\n actualBehavior: JSON.stringify(\n {\n deviceModel,\n deviceName,\n showGlassesBooting,\n elapsedMs,\n route,\n },\n null,\n 2,\n ),\n systemPriority: \"medium\",\n },\n throttleKey: `pairing_timeout|${deviceModel || \"unknown\"}|${deviceName || \"unknown\"}`,\n })\n\n const status = toAutomaticReportSubmissionStatus(result)\n logAutomaticReportSubmissionStatus(LOG_TAG, status, deviceModel, deviceName)\n return status\n}\n\nasync function waitForReadyDuringPairing(options: PairingReadyWaitOptions = {}): Promise<boolean> {\n const timeoutMs = options.timeoutMs ?? DEFAULT_PAIRING_BOOT_TIMEOUT_MS\n let showGlassesBooting = false\n const notReadySub = BluetoothSdk.addListener(\"glasses_not_ready\", () => {\n showGlassesBooting = true\n })\n\n try {\n const ready = await waitForTargetReady(options, timeoutMs)\n\n if (!ready && !options.signal?.aborted) {\n void submitPairingBootTimeoutReport({\n deviceModel: options.deviceModel,\n deviceName: options.deviceName,\n showGlassesBooting,\n elapsedMs: timeoutMs,\n route: options.route,\n }).catch((error) => {\n console.error(`[${LOG_TAG}] Unexpected error:`, error)\n })\n }\n\n return ready\n } finally {\n notReadySub.remove()\n }\n}\n\nasync function waitForBluetoothClassic(\n options: Pick<PairingReadyWaitOptions, \"timeoutMs\" | \"signal\"> = {},\n): Promise<boolean> {\n const timeoutMs = options.timeoutMs ?? DEFAULT_BT_CLASSIC_TIMEOUT_MS\n return new Promise((resolve) => {\n if (options.signal?.aborted) {\n resolve(false)\n return\n }\n\n const initial = useGlassesStore.getState().bluetoothClassicConnected\n if (initial) {\n resolve(true)\n return\n }\n\n let settled = false\n let timeout: ReturnType<typeof setTimeout> | null = null\n let unsubscribe: (() => void) | null = null\n let onAbort: (() => void) | null = null\n\n const finish = (value: boolean) => {\n if (settled) return\n settled = true\n if (timeout) clearTimeout(timeout)\n if (unsubscribe) unsubscribe()\n if (onAbort && options.signal) options.signal.removeEventListener(\"abort\", onAbort)\n resolve(value)\n }\n\n if (options.signal) {\n onAbort = () => finish(false)\n options.signal.addEventListener(\"abort\", onAbort)\n }\n\n unsubscribe = useGlassesStore.subscribe(\n (s) => s.bluetoothClassicConnected,\n (connected) => {\n if (connected) finish(true)\n },\n )\n\n timeout = setTimeout(() => {\n finish(useGlassesStore.getState().bluetoothClassicConnected)\n }, timeoutMs)\n })\n}\n\nexport const pairing = {\n readiness: (): PairingReadinessSnapshot => projectReadiness(),\n onReadiness: (cb: (readiness: PairingReadinessSnapshot) => void): (() => void) => {\n let last = JSON.stringify(projectReadiness())\n return useGlassesStore.subscribe(() => {\n const snap = projectReadiness()\n const key = JSON.stringify(snap)\n if (key === last) return\n last = key\n cb(snap)\n })\n },\n /** Whether the exact wearable or controller selected on the scan screen is ready. */\n targetReady: (options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">): boolean =>\n projectTargetReady(options),\n /** Subscribe to readiness for the exact selected target, excluding stale devices. */\n onTargetReady: (\n options: Pick<PairingReadyWaitOptions, \"deviceModel\" | \"deviceName\">,\n cb: (ready: boolean) => void,\n ): (() => void) => subscribeTargetReady(options, cb),\n\n // --- pairing-identity lifecycle (the PairingIdentity read-model + the JS-owned\n // identity writes; promotion to `paired` only ever happens natively) ---\n /** The identity lifecycle snapshot: none | pending (chosen, never paired) | paired. */\n identity: (): IdentitySnapshot => projectPairingIdentity(),\n /** Subscribe to identity changes; fires only when the projected snapshot changes.\n * Returns an unsubscribe. */\n onIdentity: (cb: (identity: IdentitySnapshot) => void): (() => void) => subscribePairingIdentity(cb),\n /** Mark the chosen model as the pending selection (the scan-entry write); the\n * host renders it as a finish-pairing affordance until pairing succeeds. */\n markPendingSelection: (model: string) => markPendingSelection(model),\n\n /** Start scanning for nearby glasses. Results land on `searchResults()`/`onFound()`. */\n scan: (model: DeviceModel): Promise<void> => BluetoothSdk.startScan(model),\n /** Best-effort advisory after a caller-managed scan completes empty. */\n diagnoseEmptyScan: async (model: DeviceModel): Promise<ScanDiagnostic | null> => {\n try {\n return (await BluetoothSdk.getScanDiagnostic?.(model)) ?? null\n } catch {\n return null\n }\n },\n /** Whether a scan is currently in progress. */\n scanning: (): boolean => useCoreStore.getState().searching,\n /** Subscribe to scan-in-progress changes; fires only when it changes. Returns an unsubscribe. */\n onScanning: (cb: (scanning: boolean) => void): (() => void) => useCoreStore.subscribe((s) => s.searching, cb),\n /** Whether a controller scan is currently in progress. */\n scanningController: (): boolean => useCoreStore.getState().searchingController,\n /** Subscribe to controller-scan-in-progress changes; fires only when it changes. Returns an unsubscribe. */\n onScanningController: (cb: (scanning: boolean) => void): (() => void) =>\n useCoreStore.subscribe((s) => s.searchingController, cb),\n /** Whether the phone has another Bluetooth (audio) device connected — the BT Classic pairing hint. */\n otherBtConnected: (): boolean => useCoreStore.getState().otherBtConnected,\n /** Subscribe to other-Bluetooth-device-connected changes; fires only when it changes. Returns an unsubscribe. */\n onOtherBtConnected: (cb: (connected: boolean) => void): (() => void) =>\n useCoreStore.subscribe((s) => s.otherBtConnected, cb),\n /** The current scan results (snapshot). */\n // Copy the array AND each entry: neither the list nor the Device objects may\n // leak as mutable references into the store.\n searchResults: () => useCoreStore.getState().searchResults.map((result) => ({...result})),\n /** Subscribe to scan-result changes; fires only when they change. Returns an unsubscribe. */\n onFound: (cb: (results: Device[]) => void): (() => void) => {\n let last = JSON.stringify(useCoreStore.getState().searchResults)\n return useCoreStore.subscribe(() => {\n const results = useCoreStore.getState().searchResults\n const key = JSON.stringify(results)\n if (key === last) return\n last = key\n // Copy like searchResults(): listeners must not mutate shared scan state.\n cb(results.map((result) => ({...result})))\n })\n },\n\n /**\n * Pair with (connect to) a discovered device. Two-phase identity: the connect\n * attempt only marks the device as pending (`saveAsDefault: false` — no eager\n * default-device write); the native layer promotes it to the default wearable\n * when pairing actually succeeds (handleDeviceReady), so an abandoned or\n * failed attempt can't leave a default identity with no paired device behind.\n */\n pair: async (device: Device, options?: ConnectOptions): Promise<void> => {\n await pushAllBluetoothSettings()\n return BluetoothSdk.connect(device, {...options, saveAsDefault: false})\n },\n /** Set a device as the default for subsequent `glasses.connectDefault()`. */\n setDefault: (device: Device | null): Promise<void> => BluetoothSdk.setDefaultDevice(device),\n /**\n * Prime the native Bluetooth Classic audio watcher with the picked device.\n * The iOS Mentra Live flow pairs Classic audio BEFORE any BLE connect\n * exists, and native detects the pairing by matching the connected audio\n * route against its device_name — which two-phase identity no longer sets\n * at selection time. This is native-only routing state (device_name has no\n * native→JS echo): the phone's persisted identity is untouched, and\n * promotion still happens only at pairing success.\n */\n setBluetoothClassicTarget: (device: Device): Promise<void> =>\n BluetoothSdk.updateBluetoothSettings({device_name: device.name}),\n /**\n * Abandon an in-flight pairing attempt (back-out, failure retry, conflict\n * retry) without destroying an existing pairing. The decision comes from the\n * LIVE hydrated default-device read — never from flow-entry state, because a\n * pairing can PROMOTE while the flow is open (the glasses finish pairing\n * even as the user backs out of the UI), and an entry snapshot would forget\n * that brand-new pairing:\n * - Default device exists and glasses are connected (nothing in flight — an\n * attempt drops the link first): stop the scan, touch nothing else.\n * - Default device exists with an attempt in flight: cancel it, then re-seed\n * the native identity from the phone's persisted settings — the attempt's\n * connect-by-name overwrote the native device_name, so a later\n * connectDefault() would otherwise target the abandoned device.\n * - No default device (genuinely unpaired attempt): also forget, clearing\n * the partial native pairing state.\n * The read fails OPEN to \"preserve\" — a transient failure must never wipe a\n * real pairing. The `pending_wearable` marker is deliberately left alone —\n * the host renders it as a finish-pairing affordance.\n */\n abandonAttempt: async (): Promise<void> => {\n const nativeHasDefault = await hasDefaultDevice().catch(() => true)\n if (nativeHasDefault && isGlassesConnected(useGlassesStore.getState().connection)) {\n // Still connected means no connect attempt is in flight (an attempt drops\n // the existing link first): the user browsed the scan and backed out.\n // Stop the scan and leave the live pairing untouched.\n console.log(\"PairingIdentity: abandonAttempt — pairing intact and connected; stopping scan only\")\n await BluetoothSdk.stopScan()\n return\n }\n if (projectPairingIdentity().kind === \"paired\") {\n // The persisted settings describe a COMPLETE pairing: restore it to\n // native (the attempt's connect-by-name overwrote the native\n // device_name; and if native somehow lost its default entirely, this\n // repairs the divergence instead of forgetting a real pairing).\n console.log(\"PairingIdentity: abandonAttempt — preserving pairing; attempt cancelled, native identity re-seeded\")\n await BluetoothSdk.disconnect()\n await pushAllBluetoothSettings()\n return\n }\n if (nativeHasDefault) {\n // Mid-relay: native promoted and its echoes are still landing — the\n // incomplete JS snapshot must not be pushed over the fresher native\n // identity (the on-connect replay's race). Native holds the truth.\n console.log(\"PairingIdentity: abandonAttempt — preserving pairing; JS identity mid-relay, native kept as-is\")\n await BluetoothSdk.disconnect()\n return\n }\n // Partial attempt: forget owns teardown. Do NOT disconnect() first — that\n // nulls the MentraLive SGC and used to skip Classic removeBond, leaving\n // IBRT ACL up so glasses never re-advertise for the next scan.\n console.log(\"PairingIdentity: abandonAttempt — no pairing on either layer; forgetting the partial attempt\")\n await BluetoothSdk.forget()\n },\n\n /** Subscribe to pairing failures; returns an unsubscribe. */\n onPairFailure: (cb: (event: PairFailureEvent) => void): (() => void) => {\n const sub = BluetoothSdk.addListener(\"pair_failure\", cb)\n return () => sub.remove()\n },\n /** Subscribe to glasses-not-ready events during pairing; returns an unsubscribe. */\n onGlassesNotReady: (cb: (event: GlassesNotReadyEvent) => void): (() => void) => {\n const sub = BluetoothSdk.addListener(\"glasses_not_ready\", cb)\n return () => sub.remove()\n },\n /** Wait for paired glasses to finish booting; engine files the timeout diagnostic. */\n waitForReady: waitForReadyDuringPairing,\n /** Wait briefly for Bluetooth Classic to come up after BLE pairing. */\n waitForBluetoothClassic,\n}\n"]}
@@ -1,4 +1,13 @@
1
+ import type { NativeNotificationStatus, NativeNotificationDelivery } from "@mentra/bluetooth-sdk";
2
+ import { nativeNotificationCapabilities, setPhoneNotificationPresentationActive, usesNativeNotificationPresentation, presentNativePhoneNotification } from "../services/PhoneNotificationsSync";
1
3
  export declare const phoneNotifications: {
4
+ nativeCapabilities: typeof nativeNotificationCapabilities;
5
+ setPresentationActive: typeof setPhoneNotificationPresentationActive;
6
+ usesNativePresentation: typeof usesNativeNotificationPresentation;
7
+ presentNative: typeof presentNativePhoneNotification;
8
+ nativeStatus: () => Promise<NativeNotificationStatus>;
9
+ onNativeStatus: (listener: (status: NativeNotificationStatus) => void) => () => void;
10
+ onNativeDelivery: (listener: (event: NativeNotificationDelivery) => void) => () => void;
2
11
  /** The phone's installed apps (package, name, icon). (empty on iOS) */
3
12
  installedApps: () => Promise<Array<{
4
13
  packageName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"phoneNotifications.d.ts","sourceRoot":"","sources":["../../src/facades/phoneNotifications.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB;IAC7B,uEAAuE;yBACpD,OAAO,CAAC,KAAK,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAC,CAAC,CAAC;IAK9F,mFAAmF;qBACpE,MAAM,EAAE;IAIvB,qCAAqC;iCACR,MAAM,EAAE;IAGrC,qFAAqF;iCAC1D,OAAO,CAAC,OAAO,CAAC;IAI3C,yFAAyF;;CAK1F,CAAA"}
1
+ {"version":3,"file":"phoneNotifications.d.ts","sourceRoot":"","sources":["../../src/facades/phoneNotifications.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAC,wBAAwB,EAAE,0BAA0B,EAAC,MAAM,uBAAuB,CAAA;AAC/F,OAAO,EACL,8BAA8B,EAC9B,sCAAsC,EACtC,kCAAkC,EAClC,8BAA8B,EAC/B,MAAM,oCAAoC,CAAA;AAG3C,eAAO,MAAM,kBAAkB;;;;;wBAKX,OAAO,CAAC,wBAAwB,CAAC;+BACxB,CAAC,MAAM,EAAE,wBAAwB,KAAK,IAAI;iCAIxC,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI;IAIxE,uEAAuE;yBACpD,OAAO,CAAC,KAAK,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAC,CAAC,CAAC;IAK9F,mFAAmF;qBACpE,MAAM,EAAE;IAIvB,qCAAqC;iCACR,MAAM,EAAE;IAGrC,qFAAqF;iCAC1D,OAAO,CAAC,OAAO,CAAC;IAI3C,yFAAyF;;CAK1F,CAAA"}
@@ -10,8 +10,23 @@
10
10
  */
11
11
  import { Platform } from "react-native";
12
12
  import CrustModule from "@mentra/crust";
13
+ import BluetoothSdk from "@mentra/bluetooth-sdk/internal";
14
+ import { nativeNotificationCapabilities, setPhoneNotificationPresentationActive, usesNativeNotificationPresentation, presentNativePhoneNotification, } from "../services/PhoneNotificationsSync";
13
15
  import { useSettingsStore, SETTINGS } from "../stores/settings";
14
16
  export const phoneNotifications = {
17
+ nativeCapabilities: nativeNotificationCapabilities,
18
+ setPresentationActive: setPhoneNotificationPresentationActive,
19
+ usesNativePresentation: usesNativeNotificationPresentation,
20
+ presentNative: presentNativePhoneNotification,
21
+ nativeStatus: () => BluetoothSdk.getNativeNotificationStatus(),
22
+ onNativeStatus: (listener) => {
23
+ const subscription = BluetoothSdk.addListener("native_notification_status", listener);
24
+ return () => subscription.remove();
25
+ },
26
+ onNativeDelivery: (listener) => {
27
+ const subscription = BluetoothSdk.addListener("native_notification_delivery", listener);
28
+ return () => subscription.remove();
29
+ },
15
30
  /** The phone's installed apps (package, name, icon). (empty on iOS) */
16
31
  installedApps: () => {
17
32
  if (Platform.OS !== "android")
@@ -1 +1 @@
1
- {"version":3,"file":"phoneNotifications.js","sourceRoot":"","sources":["../../src/facades/phoneNotifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AACrC,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAE7D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,uEAAuE;IACvE,aAAa,EAAE,GAAgF,EAAE;QAC/F,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACzD,OAAO,WAAW,CAAC,gBAAgB,EAAE,CAAA;IACvC,CAAC;IAED,mFAAmF;IACnF,SAAS,EAAE,GAAa,EAAE;QACxB,MAAM,CAAC,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;QACtF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAClC,CAAC;IACD,qCAAqC;IACrC,YAAY,EAAE,CAAC,YAAsB,EAAE,EAAE,CACvC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,EAAE,YAAY,CAAC;IAE5F,qFAAqF;IACrF,qBAAqB,EAAE,GAAqB,EAAE;QAC5C,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC5D,OAAO,WAAW,CAAC,iCAAiC,EAAE,CAAA;IACxD,CAAC;IACD,yFAAyF;IACzF,yBAAyB,EAAE,GAAG,EAAE;QAC9B,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS;YAAE,OAAM;QACrC,OAAO,WAAW,CAAC,gCAAgC,EAAE,CAAA;IACvD,CAAC;CACF,CAAA","sourcesContent":["/**\n * phoneNotifications facade — `engine.phoneNotifications`: forward phone\n * notifications to the glasses, with a per-app blocklist. Android-only (the\n * NotificationListenerService); the getters return sensible defaults on iOS.\n *\n * The per-app blocklist is an engine setting (auto-synced to the native\n * listener); the installed-apps list + listener permission are CrustModule.\n * Capture itself is controlled only by Android notification access and the\n * hidden operational kill switch.\n */\nimport {Platform} from \"react-native\"\nimport CrustModule from \"@mentra/crust\"\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\n\nexport const phoneNotifications = {\n /** The phone's installed apps (package, name, icon). (empty on iOS) */\n installedApps: (): Promise<Array<{packageName: string; appName: string; icon: string | null}>> => {\n if (Platform.OS !== \"android\") return Promise.resolve([])\n return CrustModule.getInstalledApps()\n },\n\n /** The per-app blocklist (package names whose notifications are NOT forwarded). */\n blocklist: (): string[] => {\n const b = useSettingsStore.getState().getSetting(SETTINGS.notifications_blocklist.key)\n return Array.isArray(b) ? b : []\n },\n /** Replace the per-app blocklist. */\n setBlocklist: (packageNames: string[]) =>\n useSettingsStore.getState().setSetting(SETTINGS.notifications_blocklist.key, packageNames),\n\n /** Does the app have the Android notification-listener permission? (false on iOS) */\n hasListenerPermission: (): Promise<boolean> => {\n if (Platform.OS !== \"android\") return Promise.resolve(false)\n return CrustModule.hasNotificationListenerPermission()\n },\n /** Open the OS settings to grant the notification-listener permission. (no-op on iOS) */\n requestListenerPermission: () => {\n if (Platform.OS !== \"android\") return\n return CrustModule.openNotificationListenerSettings()\n },\n}\n"]}
1
+ {"version":3,"file":"phoneNotifications.js","sourceRoot":"","sources":["../../src/facades/phoneNotifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AACrC,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,YAAY,MAAM,gCAAgC,CAAA;AAEzD,OAAO,EACL,8BAA8B,EAC9B,sCAAsC,EACtC,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAE7D,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,kBAAkB,EAAE,8BAA8B;IAClD,qBAAqB,EAAE,sCAAsC;IAC7D,sBAAsB,EAAE,kCAAkC;IAC1D,aAAa,EAAE,8BAA8B;IAC7C,YAAY,EAAE,GAAsC,EAAE,CAAC,YAAY,CAAC,2BAA2B,EAAE;IACjG,cAAc,EAAE,CAAC,Q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AAyB,EAAE,GAAG,EAAE;QAC9B,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS;YAAE,OAAM;QACrC,OAAO,WAAW,CAAC,gCAAgC,EAAE,CAAA;IACvD,CAAC;CACF,CAAA","sourcesContent":["/**\n * phoneNotifications facade — `engine.phoneNotifications`: forward phone\n * notifications to the glasses, with a per-app blocklist. Android-only (the\n * NotificationListenerService); the getters return sensible defaults on iOS.\n *\n * The per-app blocklist is an engine setting (auto-synced to the native\n * listener); the installed-apps list + listener permission are CrustModule.\n * Capture itself is controlled only by Android notification access and the\n * hidden operational kill switch.\n */\nimport {Platform} from \"react-native\"\nimport CrustModule from \"@mentra/crust\"\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport type {NativeNotificationStatus, NativeNotificationDelivery} from \"@mentra/bluetooth-sdk\"\nimport {\n nativeNotificationCapabilities,\n setPhoneNotificationPresentationActive,\n usesNativeNotificationPresentation,\n presentNativePhoneNotification,\n} from \"../services/PhoneNotificationsSync\"\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\n\nexport const phoneNotifications = {\n nativeCapabilities: nativeNotificationCapabilities,\n setPresentationActive: setPhoneNotificationPresentationActive,\n usesNativePresentation: usesNativeNotificationPresentation,\n presentNative: presentNativePhoneNotification,\n nativeStatus: (): Promise<NativeNotificationStatus> => BluetoothSdk.getNativeNotificationStatus(),\n onNativeStatus: (listener: (status: NativeNotificationStatus) => void) => {\n const subscription = BluetoothSdk.addListener(\"native_notification_status\", listener)\n return () => subscription.remove()\n },\n onNativeDelivery: (listener: (event: NativeNotificationDelivery) => void) => {\n const subscription = BluetoothSdk.addListener(\"native_notification_delivery\", listener)\n return () => subscription.remove()\n },\n /** The phone's installed apps (package, name, icon). (empty on iOS) */\n installedApps: (): Promise<Array<{packageName: string; appName: string; icon: string | null}>> => {\n if (Platform.OS !== \"android\") return Promise.resolve([])\n return CrustModule.getInstalledApps()\n },\n\n /** The per-app blocklist (package names whose notifications are NOT forwarded). */\n blocklist: (): string[] => {\n const b = useSettingsStore.getState().getSetting(SETTINGS.notifications_blocklist.key)\n return Array.isArray(b) ? b : []\n },\n /** Replace the per-app blocklist. */\n setBlocklist: (packageNames: string[]) =>\n useSettingsStore.getState().setSetting(SETTINGS.notifications_blocklist.key, packageNames),\n\n /** Does the app have the Android notification-listener permission? (false on iOS) */\n hasListenerPermission: (): Promise<boolean> => {\n if (Platform.OS !== \"android\") return Promise.resolve(false)\n return CrustModule.hasNotificationListenerPermission()\n },\n /** Open the OS settings to grant the notification-listener permission. (no-op on iOS) */\n requestListenerPermission: () => {\n if (Platform.OS !== \"android\") return\n return CrustModule.openNotificationListenerSettings()\n },\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  export const ENGINE_RELEASE_METADATA = Object.freeze({
2
2
  "schemaVersion": 1,
3
3
  "familyBaseVersion": "3.2.0",
4
- "releaseIdentity": "3.2.0-dev.180",
5
- "releaseSetId": "mentra-3.2.0-dev.180",
6
- "sourceCommit": "1f24e462561fef37b7082204847a541db4a87c41",
7
- "otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.180.json",
8
- "otaManifestSha256": "cbf2a1b81430bd34942e2a1764138f6d79197767b4434a2d8c44311768f8b873"
4
+ "releaseIdentity": "3.2.0-dev.187",
5
+ "releaseSetId": "mentra-3.2.0-dev.187",
6
+ "sourceCommit": "d8b34892f11593baa3c075b94380253b06eb874d",
7
+ "otaManifestUrl": "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.187.json",
8
+ "otaManifestSha256": "cf21f4ab6347acb12eefa38d2f0a3b433bc0e05428c527bcda57a8693d7a72f9"
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,eAAe;IAClC,cAAc,EAAE,sBAAsB;IACtC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,wHAAwH;IAC1I,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.2.0\",\n \"releaseIdentity\": \"3.2.0-dev.180\",\n \"releaseSetId\": \"mentra-3.2.0-dev.180\",\n \"sourceCommit\": \"1f24e462561fef37b7082204847a541db4a87c41\",\n \"otaManifestUrl\": \"https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.180.json\",\n \"otaManifestSha256\": \"cbf2a1b81430bd34942e2a1764138f6d79197767b4434a2d8c44311768f8b873\"\n})\n"]}
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,eAAe;IAClC,cAAc,EAAE,sBAAsB;IACtC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,wHAAwH;IAC1I,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.2.0\",\n \"releaseIdentity\": \"3.2.0-dev.187\",\n \"releaseSetId\": \"mentra-3.2.0-dev.187\",\n \"sourceCommit\": \"d8b34892f11593baa3c075b94380253b06eb874d\",\n \"otaManifestUrl\": \"https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.187.json\",\n \"otaManifestSha256\": \"cf21f4ab6347acb12eefa38d2f0a3b433bc0e05428c527bcda57a8693d7a72f9\"\n})\n"]}
@@ -0,0 +1,13 @@
1
+ import type { NativeNotificationConfig } from "@mentra/bluetooth-sdk";
2
+ export interface NotificationPolicyInput {
3
+ supported: boolean;
4
+ selected: boolean;
5
+ presentationActive: boolean;
6
+ sourceEnabled: boolean;
7
+ autoDisplay: boolean;
8
+ durationSeconds: number;
9
+ doNotDisturb: boolean;
10
+ blockedApps: string[];
11
+ }
12
+ export declare function nativeNotificationConfig(input: NotificationPolicyInput): NativeNotificationConfig;
13
+ //# sourceMappingURL=NativeNotificationPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeNotificationPolicy.d.ts","sourceRoot":"","sources":["../../src/services/NativeNotificationPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uBAAuB,CAAA;AAEnE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,OAAO,CAAA;IACtB,WAAW,EAAE,OAAO,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,uBAAuB,GAAG,wBAAwB,CAUjG"}
@@ -0,0 +1,12 @@
1
+ export function nativeNotificationConfig(input) {
2
+ return {
3
+ enabled: input.supported && input.selected && input.presentationActive && input.sourceEnabled,
4
+ autoDisplay: input.autoDisplay,
5
+ durationSeconds: Number.isFinite(input.durationSeconds)
6
+ ? Math.min(30, Math.max(1, Math.round(input.durationSeconds)))
7
+ : 5,
8
+ doNotDisturb: input.doNotDisturb,
9
+ blockedApps: input.blockedApps,
10
+ };
11
+ }
12
+ //# sourceMappingURL=NativeNotificationPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeNotificationPolicy.js","sourceRoot":"","sources":["../../src/services/NativeNotificationPolicy.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,wBAAwB,CAAC,KAA8B;IACrE,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,aAAa;QAC7F,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,eAAe,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC;YACrD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;QACL,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAA;AACH,CAAC","sourcesContent":["import type {NativeNotificationConfig} from \"@mentra/bluetooth-sdk\"\n\nexport interface NotificationPolicyInput {\n supported: boolean\n selected: boolean\n presentationActive: boolean\n sourceEnabled: boolean\n autoDisplay: boolean\n durationSeconds: number\n doNotDisturb: boolean\n blockedApps: string[]\n}\n\nexport function nativeNotificationConfig(input: NotificationPolicyInput): NativeNotificationConfig {\n return {\n enabled: input.supported && input.selected && input.presentationActive && input.sourceEnabled,\n autoDisplay: input.autoDisplay,\n durationSeconds: Number.isFinite(input.durationSeconds)\n ? Math.min(30, Math.max(1, Math.round(input.durationSeconds)))\n : 5,\n doNotDisturb: input.doNotDisturb,\n blockedApps: input.blockedApps,\n }\n}\n"]}
@@ -1,3 +1,16 @@
1
+ import type { PhoneNotificationEvent } from "@mentra/crust";
2
+ export declare function nativeNotificationCapabilities(): {
3
+ supported: boolean;
4
+ source: "phone" | "ancs";
5
+ contentAccess: "full" | "unsupported" | "app_identity";
6
+ perAppFiltering: boolean;
7
+ removal: boolean;
8
+ };
9
+ /** Hosts activate their presentation owner (Notify in the Mentra App) through this seam. */
10
+ export declare function setPhoneNotificationPresentationActive(active: boolean): void;
11
+ export declare function usesNativeNotificationPresentation(): boolean;
12
+ /** Return true when the selected firmware presentation owns this event, including quiet/history mode. */
13
+ export declare function presentNativePhoneNotification(event: PhoneNotificationEvent): Promise<boolean>;
1
14
  export declare function startPhoneNotificationsSync(): void;
2
15
  export declare function stopPhoneNotificationsSync(): void;
3
16
  //# sourceMappingURL=PhoneNotificationsSync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNotificationsSync.d.ts","sourceRoot":"","sources":["../../src/services/PhoneNotificationsSync.ts"],"names":[],"mappings":"AA6BA,wBAAgB,2BAA2B,IAAI,IAAI,CAWlD;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAGjD"}
1
+ {"version":3,"file":"PhoneNotificationsSync.d.ts","sourceRoot":"","sources":["../../src/services/PhoneNotificationsSync.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAA;AAWzD,wBAAgB,8BAA8B;;;;;;EAY7C;AA0BD,4FAA4F;AAC5F,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAI5E;AAED,wBAAgB,kCAAkC,IAAI,OAAO,CAM5D;AAED,yGAAyG;AACzG,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBpG;AAcD,wBAAgB,2BAA2B,IAAI,IAAI,CAqBlD;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD"}
@@ -1,37 +1,113 @@
1
- /**
2
- * Phone-notifications sync engine-owned. Pushes the notification-forwarding
3
- * operational kill switch + config (`android_notification_listener_enabled`
4
- * and `notifications_blocklist`) to the native
5
- * NotificationListener via `CrustModule.setNotificationConfig`, so
6
- * the blocklist reaches the listener for ANY host — not just the Mentra App,
7
- * where this used to live in MantleManager. The Android service is desired by
8
- * default now that its cold start is isolated from React Native. Native code
9
- * keeps the component discoverable in Android's notification-access Settings,
10
- * but only binds the service after access is granted. The debug setting remains
11
- * a hidden emergency kill switch; Notify's running state gates presentation,
12
- * not capture. Android-only; a no-op elsewhere. Started by `engine.start()`.
13
- */
1
+ /** One engine-owned notification policy: capture remains independent of presentation. */
2
+ import { Platform } from "react-native";
14
3
  import { shallow } from "zustand/shallow";
15
4
  import CrustModule from "@mentra/crust";
5
+ import BluetoothSdk from "@mentra/bluetooth-sdk/internal";
16
6
  import { useSettingsStore, SETTINGS } from "../stores/settings";
17
- let unsubscribe = null;
7
+ import { useGlassesStore, isGlassesReady } from "../stores/glasses";
8
+ import { getModelCapabilities } from "../types/hardware";
9
+ import { nativeNotificationConfig } from "./NativeNotificationPolicy";
10
+ let unsubscribers = [];
11
+ let presentationActive = false;
12
+ export function nativeNotificationCapabilities() {
13
+ const supported = Boolean(getModelCapabilities(useGlassesStore.getState().deviceModel)?.hasNativeNotifications);
14
+ return {
15
+ supported,
16
+ source: Platform.OS === "ios" ? "ancs" : "phone",
17
+ contentAccess: Platform.OS === "android" ? "full" : supported ? "app_identity" : "unsupported",
18
+ perAppFiltering: Platform.OS === "android",
19
+ removal: false, // The verified G2 protocol does not yet include a removal command.
20
+ };
21
+ }
22
+ function desiredConfig() {
23
+ const settings = useSettingsStore.getState();
24
+ return nativeNotificationConfig({
25
+ supported: nativeNotificationCapabilities().supported,
26
+ selected: Boolean(settings.getSetting(SETTINGS.native_notifications_enabled.key)),
27
+ presentationActive,
28
+ sourceEnabled: Platform.OS !== "android" || Boolean(settings.getSetting(SETTINGS.android_notification_listener_enabled.key)),
29
+ autoDisplay: Boolean(settings.getSetting(SETTINGS.native_notifications_auto_display.key)),
30
+ durationSeconds: Number(settings.getSetting(SETTINGS.native_notifications_duration.key)),
31
+ doNotDisturb: Boolean(settings.getSetting(SETTINGS.native_notifications_do_not_disturb.key)),
32
+ blockedApps: Platform.OS === "android" ? settings.getSetting(SETTINGS.notifications_blocklist.key) : [],
33
+ });
34
+ }
35
+ function pushNativeConfig() {
36
+ if (!nativeNotificationCapabilities().supported)
37
+ return;
38
+ void BluetoothSdk.configureNativeNotifications(desiredConfig()).catch((error) => {
39
+ if (isGlassesReady(useGlassesStore.getState().connection)) {
40
+ console.warn("PhoneNotificationsSync: native notification configuration failed", error);
41
+ }
42
+ });
43
+ }
44
+ /** Hosts activate their presentation owner (Notify in the Mentra App) through this seam. */
45
+ export function setPhoneNotificationPresentationActive(active) {
46
+ if (active === presentationActive)
47
+ return;
48
+ presentationActive = active;
49
+ pushNativeConfig();
50
+ }
51
+ export function usesNativeNotificationPresentation() {
52
+ return (nativeNotificationCapabilities().supported &&
53
+ presentationActive &&
54
+ Boolean(useSettingsStore.getState().getSetting(SETTINGS.native_notifications_enabled.key)));
55
+ }
56
+ /** Return true when the selected firmware presentation owns this event, including quiet/history mode. */
57
+ export async function presentNativePhoneNotification(event) {
58
+ if (!usesNativeNotificationPresentation())
59
+ return false;
60
+ if (!desiredConfig().enabled)
61
+ return true;
62
+ if (Platform.OS !== "android")
63
+ return true; // G2 receives ANCS directly; never upload metadata back.
64
+ const blocked = useSettingsStore.getState().getSetting(SETTINGS.notifications_blocklist.key);
65
+ if (Array.isArray(blocked) && blocked.includes(event.packageName))
66
+ return true;
67
+ if (!isGlassesReady(useGlassesStore.getState().connection))
68
+ return true;
69
+ await BluetoothSdk.sendPhoneNotification({
70
+ notificationId: String(event.notificationId ?? ""),
71
+ packageName: String(event.packageName ?? ""),
72
+ appName: String(event.app ?? ""),
73
+ title: String(event.title ?? ""),
74
+ subtitle: "",
75
+ body: String(event.content ?? ""),
76
+ timestampMs: Number(event.timestamp ?? Date.now()),
77
+ action: 0,
78
+ });
79
+ return true;
80
+ }
18
81
  function pushConfig() {
19
- const s = useSettingsStore.getState();
20
- const listenerEnabled = Boolean(s.getSetting(SETTINGS.android_notification_listener_enabled.key));
21
- const blocklist = s.getSetting(SETTINGS.notifications_blocklist.key);
22
- CrustModule.setNotificationConfig(listenerEnabled, Array.isArray(blocklist) ? blocklist : []).catch((err) => console.warn(`PhoneNotificationsSync: setNotificationConfig failed: ${err?.message ?? err}`));
82
+ const settings = useSettingsStore.getState();
83
+ if (Platform.OS === "android") {
84
+ const enabled = Boolean(settings.getSetting(SETTINGS.android_notification_listener_enabled.key));
85
+ const blocklist = settings.getSetting(SETTINGS.notifications_blocklist.key);
86
+ void CrustModule.setNotificationConfig(enabled, Array.isArray(blocklist) ? blocklist : []).catch((error) => console.warn("PhoneNotificationsSync: listener configuration failed", error));
87
+ }
88
+ pushNativeConfig();
23
89
  }
24
90
  export function startPhoneNotificationsSync() {
25
- if (unsubscribe)
91
+ if (unsubscribers.length)
26
92
  return;
27
- pushConfig(); // initial sync so the listener has the current config
28
- unsubscribe = useSettingsStore.subscribe((state) => ({
29
- listenerEnabled: state.getSetting(SETTINGS.android_notification_listener_enabled.key),
30
- blocklist: state.getSetting(SETTINGS.notifications_blocklist.key),
31
- }), () => pushConfig(), { equalityFn: shallow });
93
+ pushConfig();
94
+ unsubscribers = [
95
+ useSettingsStore.subscribe((state) => [
96
+ SETTINGS.android_notification_listener_enabled,
97
+ SETTINGS.notifications_blocklist,
98
+ SETTINGS.native_notifications_enabled,
99
+ SETTINGS.native_notifications_auto_display,
100
+ SETTINGS.native_notifications_duration,
101
+ SETTINGS.native_notifications_do_not_disturb,
102
+ ].map((setting) => state.getSetting(setting.key)), pushConfig, { equalityFn: shallow }),
103
+ useGlassesStore.subscribe((state) => ({ model: state.deviceModel, connection: state.connection }), pushNativeConfig, {
104
+ equalityFn: shallow,
105
+ }),
106
+ ];
32
107
  }
33
108
  export function stopPhoneNotificationsSync() {
34
- unsubscribe?.();
35
- unsubscribe = null;
109
+ setPhoneNotificationPresentationActive(false);
110
+ unsubscribers.forEach((unsubscribe) => unsubscribe());
111
+ unsubscribers = [];
36
112
  }
37
113
  //# sourceMappingURL=PhoneNotificationsSync.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNotificationsSync.js","sourceRoot":"","sources":["../../src/services/PhoneNotificationsSync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AACvC,OAAO,WAAW,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAE7D,IAAI,WAAW,GAAwB,IAAI,CAAA;AAE3C,SAAS,UAAU;IACjB,MAAM,CAAC,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAA;IACrC,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,qCAAqC,CAAC,GAAG,CAAC,CAAC,CAAA;IACjG,MAAM,SAAS,GAAG,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;IACpE,WAAW,CAAC,qBAAqB,CAAC,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE,CACnH,OAAO,CAAC,IAAI,CAAC,yDAA0D,GAAa,EAAE,OAAO,IAAI,GAAG,EAAE,CAAC,CACxG,CAAA;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,WAAW;QAAE,OAAM;IACvB,UAAU,EAAE,CAAA,CAAC,sDAAsD;IACnE,WAAW,GAAG,gBAAgB,CAAC,SAAS,CACtC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACV,eAAe,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,qCAAqC,CAAC,GAAG,CAAC;QACrF,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,CAAC;KAClE,CAAC,EACF,GAAG,EAAE,CAAC,UAAU,EAAE,EAClB,EAAC,UAAU,EAAE,OAAO,EAAC,CACtB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,WAAW,EAAE,EAAE,CAAA;IACf,WAAW,GAAG,IAAI,CAAA;AACpB,CAAC","sourcesContent":["/**\n * Phone-notifications sync — engine-owned. Pushes the notification-forwarding\n * operational kill switch + config (`android_notification_listener_enabled`\n * and `notifications_blocklist`) to the native\n * NotificationListener via `CrustModule.setNotificationConfig`, so\n * the blocklist reaches the listener for ANY host — not just the Mentra App,\n * where this used to live in MantleManager. The Android service is desired by\n * default now that its cold start is isolated from React Native. Native code\n * keeps the component discoverable in Android's notification-access Settings,\n * but only binds the service after access is granted. The debug setting remains\n * a hidden emergency kill switch; Notify's running state gates presentation,\n * not capture. Android-only; a no-op elsewhere. Started by `engine.start()`.\n */\nimport {shallow} from \"zustand/shallow\"\nimport CrustModule from \"@mentra/crust\"\n\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\n\nlet unsubscribe: (() => void) | null = null\n\nfunction pushConfig(): void {\n const s = useSettingsStore.getState()\n const listenerEnabled = Boolean(s.getSetting(SETTINGS.android_notification_listener_enabled.key))\n const blocklist = s.getSetting(SETTINGS.notifications_blocklist.key)\n CrustModule.setNotificationConfig(listenerEnabled, Array.isArray(blocklist) ? blocklist : []).catch((err: unknown) =>\n console.warn(`PhoneNotificationsSync: setNotificationConfig failed: ${(err as Error)?.message ?? err}`),\n )\n}\n\nexport function startPhoneNotificationsSync(): void {\n if (unsubscribe) return\n pushConfig() // initial sync so the listener has the current config\n unsubscribe = useSettingsStore.subscribe(\n (state) => ({\n listenerEnabled: state.getSetting(SETTINGS.android_notification_listener_enabled.key),\n blocklist: state.getSetting(SETTINGS.notifications_blocklist.key),\n }),\n () => pushConfig(),\n {equalityFn: shallow},\n )\n}\n\nexport function stopPhoneNotificationsSync(): void {\n unsubscribe?.()\n unsubscribe = null\n}\n"]}
1
+ {"version":3,"file":"PhoneNotificationsSync.js","sourceRoot":"","sources":["../../src/services/PhoneNotificationsSync.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AACrC,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AACvC,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,YAAY,MAAM,gCAAgC,CAAA;AAGzD,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,mBAAmB,CAAA;AAEjE,OAAO,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AAEnE,IAAI,aAAa,GAAsB,EAAE,CAAA;AACzC,IAAI,kBAAkB,GAAG,KAAK,CAAA;AAE9B,MAAM,UAAU,8BAA8B;IAC5C,MAAM,SAAS,GAAG,OAAO,CACvB,oBAAoB,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,WAA0B,CAAC,EAAE,sBAAsB,CACpG,CAAA;IACD,OAAO;QACL,SAAS;QACT,MAAM,EAAE,QAA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IAAI,CAAC,uDAAuD,EAAE,KAAK,CAAC,CAC7E,CAAA;IACH,CAAC;IACD,gBAAgB,EAAE,CAAA;AACpB,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,aAAa,CAAC,MAAM;QAAE,OAAM;IAChC,UAAU,EAAE,CAAA;IACZ,aAAa,GAAG;QACd,gBAAgB,CAAC,SAAS,CACxB,CAAC,KAAK,EAAE,EAAE,CACR;YACE,QAAQ,CAAC,qCAAqC;YAC9C,QAAQ,CAAC,uBAAuB;YAChC,QAAQ,CAAC,4BAA4B;YACrC,QAAQ,CAAC,iCAAiC;YAC1C,QAAQ,CAAC,6BAA6B;YACtC,QAAQ,CAAC,mCAAmC;SAC7C,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EACnD,UAAU,EACV,EAAC,UAAU,EAAE,OAAO,EAAC,CACtB;QACD,eAAe,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAC,CAAC,EAAE,gBAAgB,EAAE;YACjH,UAAU,EAAE,OAAO;SACpB,CAAC;KACH,CAAA;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,sCAAsC,CAAC,KAAK,CAAC,CAAA;IAC7C,aAAa,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;IACrD,aAAa,GAAG,EAAE,CAAA;AACpB,CAAC","sourcesContent":["/** One engine-owned notification policy: capture remains independent of presentation. */\nimport {Platform} from \"react-native\"\nimport {shallow} from \"zustand/shallow\"\nimport CrustModule from \"@mentra/crust\"\nimport BluetoothSdk from \"@mentra/bluetooth-sdk/internal\"\nimport type {PhoneNotificationEvent} from \"@mentra/crust\"\n\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\nimport {useGlassesStore, isGlassesReady} from \"../stores/glasses\"\nimport {DeviceTypes} from \"../types/enums\"\nimport {getModelCapabilities} from \"../types/hardware\"\nimport {nativeNotificationConfig} from \"./NativeNotificationPolicy\"\n\nlet unsubscribers: Array<() => void> = []\nlet presentationActive = false\n\nexport function nativeNotificationCapabilities() {\n const supported = Boolean(\n getModelCapabilities(useGlassesStore.getState().deviceModel as DeviceTypes)?.hasNativeNotifications,\n )\n return {\n supported,\n source: Platform.OS === \"ios\" ? (\"ancs\" as const) : (\"phone\" as const),\n contentAccess:\n Platform.OS === \"android\" ? (\"full\" as const) : supported ? (\"app_identity\" as const) : (\"unsupported\" as const),\n perAppFiltering: Platform.OS === \"android\",\n removal: false, // The verified G2 protocol does not yet include a removal command.\n }\n}\n\nfunction desiredConfig() {\n const settings = useSettingsStore.getState()\n return nativeNotificationConfig({\n supported: nativeNotificationCapabilities().supported,\n selected: Boolean(settings.getSetting(SETTINGS.native_notifications_enabled.key)),\n presentationActive,\n sourceEnabled:\n Platform.OS !== \"android\" || Boolean(settings.getSetting(SETTINGS.android_notification_listener_enabled.key)),\n autoDisplay: Boolean(settings.getSetting(SETTINGS.native_notifications_auto_display.key)),\n durationSeconds: Number(settings.getSetting(SETTINGS.native_notifications_duration.key)),\n doNotDisturb: Boolean(settings.getSetting(SETTINGS.native_notifications_do_not_disturb.key)),\n blockedApps: Platform.OS === \"android\" ? settings.getSetting(SETTINGS.notifications_blocklist.key) : [],\n })\n}\n\nfunction pushNativeConfig(): void {\n if (!nativeNotificationCapabilities().supported) return\n void BluetoothSdk.configureNativeNotifications(desiredConfig()).catch((error: unknown) => {\n if (isGlassesReady(useGlassesStore.getState().connection)) {\n console.warn(\"PhoneNotificationsSync: native notification configuration failed\", error)\n }\n })\n}\n\n/** Hosts activate their presentation owner (Notify in the Mentra App) through this seam. */\nexport function setPhoneNotificationPresentationActive(active: boolean): void {\n if (active === presentationActive) return\n presentationActive = active\n pushNativeConfig()\n}\n\nexport function usesNativeNotificationPresentation(): boolean {\n return (\n nativeNotificationCapabilities().supported &&\n presentationActive &&\n Boolean(useSettingsStore.getState().getSetting(SETTINGS.native_notifications_enabled.key))\n )\n}\n\n/** Return true when the selected firmware presentation owns this event, including quiet/history mode. */\nexport async function presentNativePhoneNotification(event: PhoneNotificationEvent): Promise<boolean> {\n if (!usesNativeNotificationPresentation()) return false\n if (!desiredConfig().enabled) return true\n if (Platform.OS !== \"android\") return true // G2 receives ANCS directly; never upload metadata back.\n const blocked = useSettingsStore.getState().getSetting(SETTINGS.notifications_blocklist.key)\n if (Array.isArray(blocked) && blocked.includes(event.packageName)) return true\n if (!isGlassesReady(useGlassesStore.getState().connection)) return true\n await BluetoothSdk.sendPhoneNotification({\n notificationId: String(event.notificationId ?? \"\"),\n packageName: String(event.packageName ?? \"\"),\n appName: String(event.app ?? \"\"),\n title: String(event.title ?? \"\"),\n subtitle: \"\",\n body: String(event.content ?? \"\"),\n timestampMs: Number(event.timestamp ?? Date.now()),\n action: 0,\n })\n return true\n}\n\nfunction pushConfig(): void {\n const settings = useSettingsStore.getState()\n if (Platform.OS === \"android\") {\n const enabled = Boolean(settings.getSetting(SETTINGS.android_notification_listener_enabled.key))\n const blocklist = settings.getSetting(SETTINGS.notifications_blocklist.key)\n void CrustModule.setNotificationConfig(enabled, Array.isArray(blocklist) ? blocklist : []).catch((error: unknown) =>\n console.warn(\"PhoneNotificationsSync: listener configuration failed\", error),\n )\n }\n pushNativeConfig()\n}\n\nexport function startPhoneNotificationsSync(): void {\n if (unsubscribers.length) return\n pushConfig()\n unsubscribers = [\n useSettingsStore.subscribe(\n (state) =>\n [\n SETTINGS.android_notification_listener_enabled,\n SETTINGS.notifications_blocklist,\n SETTINGS.native_notifications_enabled,\n SETTINGS.native_notifications_auto_display,\n SETTINGS.native_notifications_duration,\n SETTINGS.native_notifications_do_not_disturb,\n ].map((setting) => state.getSetting(setting.key)),\n pushConfig,\n {equalityFn: shallow},\n ),\n useGlassesStore.subscribe((state) => ({model: state.deviceModel, connection: state.connection}), pushNativeConfig, {\n equalityFn: shallow,\n }),\n ]\n}\n\nexport function stopPhoneNotificationsSync(): void {\n setPhoneNotificationPresentationActive(false)\n unsubscribers.forEach((unsubscribe) => unsubscribe())\n unsubscribers = []\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/stores/settings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAwB,MAAM,aAAa,CAAA;AAQ9D,OAAO,EAAC,wBAAwB,EAAE,gCAAgC,EAAC,MAAM,wBAAwB,CAAA;AAEjG,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,GAAG,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,EAAE,OAAO,CAAA;IAGrB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;IAEjC,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAA;IAEpB,OAAO,EAAE,OAAO,CAAA;IAQhB,mBAAmB,CAAC,EAAE,IAAI,CAAA;IAC1B;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB,CAAC,EAAE,IAAI,CAAA;CAC7B;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CA2oBnC,CAAA;AAEV,eAAO,MAAM,eAAe,EAAE,MAAM,EAAqD,CAAA;AAIzF,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAiD1C,CAAA;AAeD,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAEV,CAAA;AAIhC,MAAM,WAAW,aAAa;IAE5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE7B,aAAa,EAAE,OAAO,CAAA;IAEtB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,EA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