@mentra/bluetooth-sdk 3.4.0-dev.999 → 3.4.0
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/MIGRATION.md +16 -7
- package/README.md +40 -13
- package/android/build.gradle +60 -51
- package/android/gradle.properties +3 -0
- package/android/settings.gradle +47 -3
- package/android/src/main/assets/nimo/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +77 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +41 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +114 -122
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +2 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +31 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +57 -196
- package/android/src/main/java/com/mentra/bluetoothsdk/OtaManifest.kt +1 -16
- package/android/src/main/java/com/mentra/bluetoothsdk/debug/BleTraceLogger.kt +10 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/Ipv4Prefix.kt +51 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/NetworkFacts.kt +81 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkError.kt +108 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadiness.kt +103 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpec.kt +44 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkState.kt +117 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedSoftApNetwork.kt +598 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/SoftApTrace.kt +143 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt +0 -7
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTracker.kt +15 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +274 -56
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +210 -325
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +0 -35
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +2 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdater.kt +213 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocol.kt +112 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/streaming/StreamModels.kt +17 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueue.kt +92 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHost.kt +169 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +74 -115
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +348 -357
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetector.kt +211 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngine.kt +137 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SttTextFormatter.kt +52 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/WakeWordDetector.kt +235 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/AvifExifStripper.java +2 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +3 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +11 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/AudioRouteWatcher.kt +120 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +181 -16
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlayback.kt +177 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/BesCrashReportWaitersTest.kt +112 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/StreamRequestCaptureAudioTest.kt +23 -4
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/Ipv4PrefixTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/NetworkFactsTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedLocalNetworkPermissionTest.kt +35 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkErrorTest.kt +85 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkLifecycleTest.kt +164 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadinessTest.kt +141 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpecTest.kt +56 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/SoftApTraceTest.kt +97 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/UnavailableRetryTest.kt +47 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTrackerTest.kt +26 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveGlassesReadyBurstTest.kt +141 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +183 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +3 -3
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveRgbLedResponseTest.kt +76 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareTargetTest.kt +15 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdaterTest.kt +76 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocolTest.kt +77 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNamingTest.kt +23 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoReadinessDriverTest.kt +31 -1
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueueTest.kt +81 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHostTest.kt +216 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/STTToolsExtractionTest.kt +108 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetectorTest.kt +126 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngineTest.kt +245 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SttTextFormatterTest.kt +67 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlaybackTest.kt +76 -0
- package/build/BluetoothSdk.types.d.ts +103 -5
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +42 -8
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +1 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/_private/MentraLocalNetworkModule.d.ts +1 -1
- package/build/_private/MentraLocalNetworkModule.d.ts.map +1 -1
- package/build/_private/MentraLocalNetworkModule.js.map +1 -1
- package/build/generated/changelogCatalog.d.ts +2 -2
- package/build/generated/changelogCatalog.js +2 -2
- package/build/generated/changelogCatalog.js.map +1 -1
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/ota-server/MentraOtaServerModule.d.ts +0 -2
- package/build/ota-server/MentraOtaServerModule.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.js.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts +0 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.js +0 -3
- package/build/ota-server/MentraOtaServerModule.web.js.map +1 -1
- package/build/ota-transport/index.d.ts +3 -3
- package/build/ota-transport/index.d.ts.map +1 -1
- package/build/ota-transport/index.js +4 -4
- package/build/ota-transport/index.js.map +1 -1
- package/build/react/useGlassesConnection.d.ts +1 -1
- package/build/react/useGlassesConnection.d.ts.map +1 -1
- package/build/react/useGlassesConnection.js +3 -3
- package/build/react/useGlassesConnection.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +1 -1
- package/build/react/useMentraBluetooth.d.ts.map +1 -1
- package/build/react/useMentraBluetooth.js +1 -1
- package/build/react/useMentraBluetooth.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +73 -22
- package/ios/LocalIPv4.swift +0 -61
- package/ios/MentraBluetoothSDK.podspec +7 -1
- package/ios/MentraOtaServerModule.swift +0 -16
- package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
- package/ios/Resources/NimoFirmware/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
- package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
- package/ios/Source/BesCrashReportWaiters.swift +64 -0
- package/ios/Source/BluetoothSdkDefaults.swift +4 -4
- package/ios/Source/Bridge.swift +14 -0
- package/ios/Source/DeviceManager.swift +43 -22
- package/ios/Source/GeneratedChangelogCatalog.swift +2 -2
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/MentraBluetoothSDK.swift +35 -16
- package/ios/Source/OtaManifest.swift +1 -17
- package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
- package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
- package/ios/Source/audio/SpeechActivity.swift +277 -0
- package/ios/Source/events/BluetoothEvents.swift +41 -0
- package/ios/Source/internal/BleTraceLogger.swift +14 -1
- package/ios/Source/internal/BluetoothAvailability.swift +15 -5
- package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
- package/ios/Source/sgcs/MentraLive.swift +195 -66
- package/ios/Source/sgcs/Nimo.swift +249 -276
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
- package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
- package/ios/Source/sgcs/NimoFirmwareUpdater.swift +260 -0
- package/ios/Source/sgcs/NimoOtaProtocol.swift +159 -0
- package/ios/Source/sgcs/SGCManager.swift +6 -0
- package/ios/Source/streaming/StreamModels.swift +15 -6
- package/ios/Source/stt/STTTools.swift +13 -31
- package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
- package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
- package/ios/Source/stt/WakeWordDetector.swift +145 -0
- package/ios/Source/utils/BoundedWait.swift +44 -0
- package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
- package/ios/Source/utils/SttModelTraits.swift +62 -0
- package/ios/Tests/BesCrashReportTests.swift +142 -0
- package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
- package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
- package/ios/Tests/GlassesAudioSetupPolicyTests.swift +9 -3
- package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
- package/ios/Tests/MentraLiveAudioSetupTests.swift +6 -12
- package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
- package/ios/Tests/MentraLiveSessionReadinessTests.swift +179 -10
- package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
- package/ios/Tests/NimoOtaProtocolTests.swift +78 -0
- package/ios/Tests/PcmStreamTests.swift +299 -0
- package/ios/Tests/SpeechActivityTests.swift +238 -0
- package/ios/Tests/StreamRequestTests.swift +18 -0
- package/ios/Tests/SttModelTraitsTests.swift +62 -0
- package/package.json +2 -2
- package/plugin/build/withAndroid.js +9 -11
- package/plugin/build/withKotlinVersion.d.ts +2 -0
- package/plugin/build/withKotlinVersion.js +46 -0
- package/src/BluetoothSdk.types.ts +107 -5
- package/src/_private/BluetoothSdkModule.ts +45 -8
- package/src/_private/MentraLocalNetworkModule.ts +5 -1
- package/src/generated/changelogCatalog.ts +2 -2
- package/src/generated/releaseMetadata.ts +5 -5
- package/src/index.ts +13 -1
- package/src/ota-server/MentraOtaServerModule.ts +0 -2
- package/src/ota-server/MentraOtaServerModule.web.ts +0 -4
- package/src/ota-transport/index.ts +4 -5
- package/src/react/useGlassesConnection.ts +4 -4
- package/src/react/useMentraBluetooth.ts +2 -2
- package/android/silero/LICENSE.md +0 -17
- package/android/silero/build.gradle +0 -50
- package/android/silero/proguard-rules.pro +0 -24
- package/android/silero/src/androidTest/assets/hello.wav +0 -0
- package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
- package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
- package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
- package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
- package/android/src/main/java/com/mentra/bluetoothsdk/ScopedNetworkReadiness.kt +0 -17
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
- package/android/src/test/java/com/mentra/bluetoothsdk/ScopedNetworkReadinessTest.kt +0 -39
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
- package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
- package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
- package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
- package/ios/Tests/NimoResourceSessionTests.swift +0 -476
- /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
- /package/android/{silero/src/main/assets → src/main/assets/vad}/silero_vad.onnx +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.hotspot
|
|
2
|
+
|
|
3
|
+
import com.mentra.bluetoothsdk.hotspot.ScopedNetworkReadiness.Verdict
|
|
4
|
+
import org.assertj.core.api.Assertions.assertThat
|
|
5
|
+
import org.junit.Test
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The race these cases pin cost a misdiagnosis: ingest started on `onAvailable`, the hotspot address
|
|
9
|
+
* was not yet in the kernel table, and the resulting candidate-less answer was blamed on socket
|
|
10
|
+
* binding. Readiness now has to agree from three sources, and the missing one has to be named.
|
|
11
|
+
*/
|
|
12
|
+
class ScopedNetworkReadinessTest {
|
|
13
|
+
|
|
14
|
+
private val readiness = ScopedNetworkReadiness()
|
|
15
|
+
|
|
16
|
+
private fun joined() {
|
|
17
|
+
readiness.onAvailable()
|
|
18
|
+
readiness.onCapabilities()
|
|
19
|
+
readiness.onLinkProperties("wlan0", "192.168.43.79")
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Test
|
|
23
|
+
fun `a fresh gate waits for onAvailable`() {
|
|
24
|
+
assertThat(readiness.verdict()).isEqualTo(Verdict.Waiting("onAvailable"))
|
|
25
|
+
assertThat(readiness.callbacksSatisfied()).isFalse
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Android's guidance, and the reason `onAvailable` alone was not enough. */
|
|
29
|
+
@Test
|
|
30
|
+
fun `onAvailable alone is not ready`() {
|
|
31
|
+
readiness.onAvailable()
|
|
32
|
+
|
|
33
|
+
assertThat(readiness.verdict()).isEqualTo(Verdict.Waiting("onCapabilitiesChanged"))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Test
|
|
37
|
+
fun `capabilities without an address is not ready`() {
|
|
38
|
+
readiness.onAvailable()
|
|
39
|
+
readiness.onCapabilities()
|
|
40
|
+
|
|
41
|
+
assertThat(readiness.verdict()).isEqualTo(Verdict.Waiting("an IPv4 address from onLinkPropertiesChanged"))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The whole point: the callbacks can all agree while ICE still has nothing to gather. */
|
|
45
|
+
@Test
|
|
46
|
+
fun `every callback reporting is not ready until the kernel table has the address`() {
|
|
47
|
+
joined()
|
|
48
|
+
|
|
49
|
+
assertThat(readiness.callbacksSatisfied()).isTrue
|
|
50
|
+
assertThat(readiness.verdict())
|
|
51
|
+
.isEqualTo(Verdict.Waiting("the kernel interface table to carry 192.168.43.79"))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Test
|
|
55
|
+
fun `the address appearing in the table late completes readiness`() {
|
|
56
|
+
joined()
|
|
57
|
+
|
|
58
|
+
readiness.onInterfaceTable("wlan0")
|
|
59
|
+
|
|
60
|
+
assertThat(readiness.verdict()).isEqualTo(Verdict.Ready("192.168.43.79", "wlan0", "wlan0"))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A name disagreement is reported, not blocked on: ICE gathers per address, so the address being
|
|
65
|
+
* in the table is what matters. Blocking here would fail calls that actually work.
|
|
66
|
+
*/
|
|
67
|
+
@Test
|
|
68
|
+
fun `the kernel owning the address under another name is still ready`() {
|
|
69
|
+
joined()
|
|
70
|
+
|
|
71
|
+
readiness.onInterfaceTable("wlan1")
|
|
72
|
+
|
|
73
|
+
val verdict = readiness.verdict() as Verdict.Ready
|
|
74
|
+
assertThat(verdict.interfaceName).isEqualTo("wlan0")
|
|
75
|
+
assertThat(verdict.owner).isEqualTo("wlan1")
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A later poll that no longer finds the address must un-ready the gate, not latch. */
|
|
79
|
+
@Test
|
|
80
|
+
fun `the address leaving the table takes readiness away again`() {
|
|
81
|
+
joined()
|
|
82
|
+
readiness.onInterfaceTable("wlan0")
|
|
83
|
+
|
|
84
|
+
readiness.onInterfaceTable(null)
|
|
85
|
+
|
|
86
|
+
assertThat(readiness.verdict()).isInstanceOf(Verdict.Waiting::class.java)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** LinkProperties is a whole-state snapshot, so a later one without an address means gone. */
|
|
90
|
+
@Test
|
|
91
|
+
fun `a link properties update without an address clears the observation`() {
|
|
92
|
+
joined()
|
|
93
|
+
readiness.onInterfaceTable("wlan0")
|
|
94
|
+
|
|
95
|
+
readiness.onLinkProperties("wlan0", null)
|
|
96
|
+
|
|
97
|
+
assertThat(readiness.callbacksSatisfied()).isFalse
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The synchronous read inside `onAvailable` is a hint; it must not erase a real callback. */
|
|
101
|
+
@Test
|
|
102
|
+
fun `seeding with no address does not clear what a callback reported`() {
|
|
103
|
+
readiness.onLinkProperties("wlan0", "192.168.43.79")
|
|
104
|
+
|
|
105
|
+
readiness.seedLinkProperties(null, null)
|
|
106
|
+
|
|
107
|
+
assertThat(readiness.observations.linkAddress).isEqualTo("192.168.43.79")
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@Test
|
|
111
|
+
fun `seeding supplies the address when the callback has not arrived`() {
|
|
112
|
+
readiness.onAvailable()
|
|
113
|
+
readiness.seedLinkProperties("wlan0", "192.168.43.79")
|
|
114
|
+
readiness.onCapabilities()
|
|
115
|
+
|
|
116
|
+
assertThat(readiness.callbacksSatisfied()).isTrue
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Rejoin reuses the instance, so a stale Ready from the previous call would be fatal. */
|
|
120
|
+
@Test
|
|
121
|
+
fun `reset returns the gate to waiting for onAvailable`() {
|
|
122
|
+
joined()
|
|
123
|
+
readiness.onInterfaceTable("wlan0")
|
|
124
|
+
|
|
125
|
+
readiness.reset()
|
|
126
|
+
|
|
127
|
+
assertThat(readiness.verdict()).isEqualTo(Verdict.Waiting("onAvailable"))
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Test
|
|
131
|
+
fun `callbacks arriving out of order still resolve`() {
|
|
132
|
+
readiness.onCapabilities()
|
|
133
|
+
readiness.onLinkProperties("wlan0", "192.168.43.79")
|
|
134
|
+
readiness.onInterfaceTable("wlan0")
|
|
135
|
+
assertThat(readiness.verdict()).isEqualTo(Verdict.Waiting("onAvailable"))
|
|
136
|
+
|
|
137
|
+
readiness.onAvailable()
|
|
138
|
+
|
|
139
|
+
assertThat(readiness.verdict()).isInstanceOf(Verdict.Ready::class.java)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.hotspot
|
|
2
|
+
|
|
3
|
+
import android.net.NetworkCapabilities
|
|
4
|
+
import org.assertj.core.api.Assertions.assertThat
|
|
5
|
+
import org.junit.Test
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Guards the one property the whole dual-homing design rests on: the SoftAP request must not ask
|
|
9
|
+
* for `NET_CAPABILITY_INTERNET`. If that regresses, Android can promote the glasses hotspot to the
|
|
10
|
+
* default network and ACS traffic silently stops using cellular.
|
|
11
|
+
*/
|
|
12
|
+
class ScopedNetworkRequestSpecTest {
|
|
13
|
+
|
|
14
|
+
@Test
|
|
15
|
+
fun `the softap request removes the internet capability`() {
|
|
16
|
+
val spec = ScopedNetworkRequestSpec.forSoftAp("MentraLive-1234", "hunter2")
|
|
17
|
+
|
|
18
|
+
assertThat(spec.removedCapabilities).contains(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
|
19
|
+
assertThat(spec.avoidsInternetCapability).isTrue()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Test
|
|
23
|
+
fun `the softap request is wifi only`() {
|
|
24
|
+
val spec = ScopedNetworkRequestSpec.forSoftAp("MentraLive-1234", "hunter2")
|
|
25
|
+
|
|
26
|
+
assertThat(spec.transportTypes).containsExactly(NetworkCapabilities.TRANSPORT_WIFI)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Test
|
|
30
|
+
fun `ssid and passphrase are carried through`() {
|
|
31
|
+
val spec = ScopedNetworkRequestSpec.forSoftAp("MentraLive-1234", "hunter2")
|
|
32
|
+
|
|
33
|
+
assertThat(spec.ssid).isEqualTo("MentraLive-1234")
|
|
34
|
+
assertThat(spec.passphrase).isEqualTo("hunter2")
|
|
35
|
+
assertThat(spec.hasPassphrase).isTrue()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@Test
|
|
39
|
+
fun `an open network reports no passphrase`() {
|
|
40
|
+
assertThat(ScopedNetworkRequestSpec.forSoftAp("Open-AP", "").hasPassphrase).isFalse()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A spec that kept the internet capability must not read as safe. */
|
|
44
|
+
@Test
|
|
45
|
+
fun `avoidsInternetCapability is false when the capability is not removed`() {
|
|
46
|
+
val unsafe =
|
|
47
|
+
ScopedNetworkRequestSpec(
|
|
48
|
+
ssid = "x",
|
|
49
|
+
passphrase = "y",
|
|
50
|
+
transportTypes = setOf(NetworkCapabilities.TRANSPORT_WIFI),
|
|
51
|
+
removedCapabilities = emptySet(),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
assertThat(unsafe.avoidsInternetCapability).isFalse()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.hotspot
|
|
2
|
+
|
|
3
|
+
import org.assertj.core.api.Assertions.assertThat
|
|
4
|
+
import org.junit.Test
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Covers the pure formatter. The `Log.i` wrapper is a one-liner and is exercised on device.
|
|
8
|
+
*/
|
|
9
|
+
class SoftApTraceTest {
|
|
10
|
+
|
|
11
|
+
@Test
|
|
12
|
+
fun `format carries the grep marker`() {
|
|
13
|
+
assertThat(SoftApTrace.format("t1", "scoped_network_available", 12))
|
|
14
|
+
.contains("SOFTAP_TRACE")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Test
|
|
18
|
+
fun `format includes traceId stage and elapsed`() {
|
|
19
|
+
assertThat(SoftApTrace.format("abc123", "ice_selected_pair", 450))
|
|
20
|
+
.isEqualTo("[SOFTAP_TRACE] traceId=abc123 stage=ice_selected_pair elapsedMs=450")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Test
|
|
24
|
+
fun `format omits traceId when absent`() {
|
|
25
|
+
assertThat(SoftApTrace.format("", "boot", 0))
|
|
26
|
+
.isEqualTo("[SOFTAP_TRACE] stage=boot elapsedMs=0")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Test
|
|
30
|
+
fun `format appends fields in order`() {
|
|
31
|
+
assertThat(SoftApTrace.format("t", "whip_request", 7, "method" to "POST", "status" to 201))
|
|
32
|
+
.endsWith("method=POST status=201")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Test
|
|
36
|
+
fun `sanitize redacts the hotspot password`() {
|
|
37
|
+
assertThat(SoftApTrace.sanitize("password", "hunter2")).isEqualTo("<redacted>")
|
|
38
|
+
assertThat(SoftApTrace.sanitize("hotspotPassword", "hunter2")).isEqualTo("<redacted>")
|
|
39
|
+
assertThat(SoftApTrace.sanitize("psk", "hunter2")).isEqualTo("<redacted>")
|
|
40
|
+
assertThat(SoftApTrace.sanitize("passphrase", "hunter2")).isEqualTo("<redacted>")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Test
|
|
44
|
+
fun `sanitize redacts tokens and credentials`() {
|
|
45
|
+
assertThat(SoftApTrace.sanitize("token", "eyJhbGciOi")).isEqualTo("<redacted>")
|
|
46
|
+
assertThat(SoftApTrace.sanitize("acsToken", "eyJhbGciOi")).isEqualTo("<redacted>")
|
|
47
|
+
assertThat(SoftApTrace.sanitize("Authorization", "Bearer x")).isEqualTo("<redacted>")
|
|
48
|
+
assertThat(SoftApTrace.sanitize("meetingUrl", "https://teams.microsoft.com/l/x"))
|
|
49
|
+
.isEqualTo("<redacted>")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Test
|
|
53
|
+
fun `format never leaks a secret value into the line`() {
|
|
54
|
+
val line = SoftApTrace.format(
|
|
55
|
+
"t", "hotspot_started", 5,
|
|
56
|
+
"ssid" to "MentraLive", "password" to "hunter2",
|
|
57
|
+
)
|
|
58
|
+
assertThat(line).doesNotContain("hunter2")
|
|
59
|
+
assertThat(line).contains("ssid=MentraLive")
|
|
60
|
+
assertThat(line).contains("password=<redacted>")
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Test
|
|
64
|
+
fun `sanitize keeps the local whip url which is diagnostic`() {
|
|
65
|
+
assertThat(SoftApTrace.sanitize("whipUrl", "http://192.168.43.20:8790/whip/abc"))
|
|
66
|
+
.isEqualTo("http://192.168.43.20:8790/whip/abc")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Test
|
|
70
|
+
fun `sanitize strips query strings that may carry tokens`() {
|
|
71
|
+
assertThat(SoftApTrace.sanitize("playbackUrl", "https://example.com/live?token=secret123"))
|
|
72
|
+
.isEqualTo("https://example.com/live?<redacted>")
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Test
|
|
76
|
+
fun `sanitize strips userinfo from urls`() {
|
|
77
|
+
val result = SoftApTrace.sanitize("endpoint", "https://user:pw@example.com/x")
|
|
78
|
+
assertThat(result).doesNotContain("pw@")
|
|
79
|
+
assertThat(result).contains("<redacted>@example.com/x")
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Test
|
|
83
|
+
fun `sanitize quotes values containing spaces`() {
|
|
84
|
+
assertThat(SoftApTrace.sanitize("reason", "two words")).isEqualTo("\"two words\"")
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Test
|
|
88
|
+
fun `sanitize renders null and empty`() {
|
|
89
|
+
assertThat(SoftApTrace.sanitize("reason", null)).isEqualTo("null")
|
|
90
|
+
assertThat(SoftApTrace.sanitize("reason", "")).isEqualTo("\"\"")
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Test
|
|
94
|
+
fun `newTraceId produces distinct ids`() {
|
|
95
|
+
assertThat(SoftApTrace.newTraceId()).isNotEqualTo(SoftApTrace.newTraceId())
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.hotspot
|
|
2
|
+
|
|
3
|
+
import org.assertj.core.api.Assertions.assertThat
|
|
4
|
+
import org.assertj.core.api.Assertions.assertThatThrownBy
|
|
5
|
+
import org.junit.Test
|
|
6
|
+
|
|
7
|
+
class UnavailableRetryTest {
|
|
8
|
+
|
|
9
|
+
@Test
|
|
10
|
+
fun `asks once more after an Unavailable`() {
|
|
11
|
+
var requests = 0
|
|
12
|
+
val result = ScopedSoftApNetwork.retryUnavailableOnce(
|
|
13
|
+
request = { if (++requests == 1) throw ScopedNetworkError.Unavailable("glasses") else "joined" },
|
|
14
|
+
settle = {},
|
|
15
|
+
released = { false },
|
|
16
|
+
)
|
|
17
|
+
assertThat(result).isEqualTo("joined")
|
|
18
|
+
assertThat(requests).isEqualTo(2)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Test
|
|
22
|
+
fun `a release during the settle stops the second request`() {
|
|
23
|
+
var requests = 0
|
|
24
|
+
var released = false
|
|
25
|
+
assertThatThrownBy {
|
|
26
|
+
ScopedSoftApNetwork.retryUnavailableOnce(
|
|
27
|
+
request = { requests++; throw ScopedNetworkError.Unavailable("glasses") },
|
|
28
|
+
settle = { released = true },
|
|
29
|
+
released = { released },
|
|
30
|
+
)
|
|
31
|
+
}.isInstanceOf(ScopedNetworkError.Unavailable::class.java)
|
|
32
|
+
assertThat(requests).isEqualTo(1)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Test
|
|
36
|
+
fun `a release before the settle skips it`() {
|
|
37
|
+
var settled = false
|
|
38
|
+
assertThatThrownBy {
|
|
39
|
+
ScopedSoftApNetwork.retryUnavailableOnce<String>(
|
|
40
|
+
request = { throw ScopedNetworkError.Unavailable("glasses") },
|
|
41
|
+
settle = { settled = true },
|
|
42
|
+
released = { true },
|
|
43
|
+
)
|
|
44
|
+
}.isInstanceOf(ScopedNetworkError.Unavailable::class.java)
|
|
45
|
+
assertThat(settled).isFalse()
|
|
46
|
+
}
|
|
47
|
+
}
|
package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTrackerTest.kt
CHANGED
|
@@ -19,6 +19,32 @@ class ClassicAudioConnectionTrackerTest {
|
|
|
19
19
|
ClassicAudioProfile.HEADSET to false))).isEmpty()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
private val both = setOf(ClassicAudioProfile.A2DP, ClassicAudioProfile.HEADSET)
|
|
23
|
+
|
|
24
|
+
@Test
|
|
25
|
+
fun `android Disconnect drops every connected profile together`() {
|
|
26
|
+
val at = mapOf(ClassicAudioProfile.HEADSET to 1_000L, ClassicAudioProfile.A2DP to 1_001L)
|
|
27
|
+
assertThat(wholeClassicDeviceDisconnecting(both, at, 1_001L, 3_000L)).isTrue()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Test
|
|
31
|
+
fun `turning off Media or Call audio is not a disconnect`() {
|
|
32
|
+
assertThat(wholeClassicDeviceDisconnecting(both, mapOf(ClassicAudioProfile.A2DP to 1_000L), 1_000L, 3_000L)).isFalse()
|
|
33
|
+
assertThat(wholeClassicDeviceDisconnecting(both, mapOf(ClassicAudioProfile.HEADSET to 1_000L), 1_000L, 3_000L)).isFalse()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Test
|
|
37
|
+
fun `unworn glasses with only A2DP up are disconnected by that profile alone`() {
|
|
38
|
+
val a2dp = setOf(ClassicAudioProfile.A2DP)
|
|
39
|
+
assertThat(wholeClassicDeviceDisconnecting(a2dp, mapOf(ClassicAudioProfile.A2DP to 1_000L), 1_000L, 3_000L)).isTrue()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Test
|
|
43
|
+
fun `two profile toggles far apart are not one disconnect`() {
|
|
44
|
+
val at = mapOf(ClassicAudioProfile.HEADSET to 1_000L, ClassicAudioProfile.A2DP to 10_000L)
|
|
45
|
+
assertThat(wholeClassicDeviceDisconnecting(both, at, 10_000L, 3_000L)).isFalse()
|
|
46
|
+
}
|
|
47
|
+
|
|
22
48
|
private val address = "AA:BB:CC:DD:EE:FF"
|
|
23
49
|
|
|
24
50
|
private fun snapshot(tracker: ClassicAudioConnectionTracker, vararg profiles: ClassicAudioProfile) {
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
package com.mentra.bluetoothsdk.sgcs
|
|
2
|
+
|
|
3
|
+
import android.os.Looper
|
|
4
|
+
import androidx.test.core.app.ApplicationProvider
|
|
5
|
+
import com.mentra.bluetoothsdk.Bridge
|
|
6
|
+
import com.mentra.bluetoothsdk.utils.ConnTypes
|
|
7
|
+
import java.time.Duration
|
|
8
|
+
import org.json.JSONObject
|
|
9
|
+
import org.junit.Assert.assertEquals
|
|
10
|
+
import org.junit.Assert.assertNotEquals
|
|
11
|
+
import org.junit.Assert.assertNotNull
|
|
12
|
+
import org.junit.Test
|
|
13
|
+
import org.junit.runner.RunWith
|
|
14
|
+
import org.robolectric.RobolectricTestRunner
|
|
15
|
+
import org.robolectric.Shadows.shadowOf
|
|
16
|
+
import org.robolectric.annotation.Config
|
|
17
|
+
import org.robolectric.annotation.LooperMode
|
|
18
|
+
|
|
19
|
+
@RunWith(RobolectricTestRunner::class)
|
|
20
|
+
@Config(sdk = [33], shadows = [G1PairingTest.ShadowLc3Cpp::class], instrumentedPackages = ["com.mentra.lc3Lib"])
|
|
21
|
+
@LooperMode(LooperMode.Mode.PAUSED)
|
|
22
|
+
class MentraLiveGlassesReadyBurstTest {
|
|
23
|
+
@Test fun `buffered phone_ready copies are one exchange with one init`() = withLive { live, inits ->
|
|
24
|
+
// Two SOC-ready heartbeats while the glasses boot: one exchange, sent twice.
|
|
25
|
+
receive(live, socReady())
|
|
26
|
+
val readyId = pendingReadyId(live)
|
|
27
|
+
receive(live, socReady())
|
|
28
|
+
assertEquals(readyId, pendingReadyId(live))
|
|
29
|
+
|
|
30
|
+
// The glasses answer every buffered copy; only the first followed a reset.
|
|
31
|
+
repeat(7) { receive(live, glassesReady("booted", readyId)) }
|
|
32
|
+
assertEquals(1, inits())
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Test fun `answers to a superseded exchange are ignored until the pending one arrives`() = withLive { live, inits ->
|
|
36
|
+
receive(live, socReady())
|
|
37
|
+
val first = pendingReadyId(live)
|
|
38
|
+
receive(live, glassesReady("booted", first))
|
|
39
|
+
invoke(live, "sendPhoneReady", "readiness re-run")
|
|
40
|
+
val second = pendingReadyId(live)
|
|
41
|
+
|
|
42
|
+
// The same process already reset for the first exchange; the pending one is still to come.
|
|
43
|
+
receive(live, glassesReady("booted", first))
|
|
44
|
+
assertEquals(1, inits())
|
|
45
|
+
receive(live, glassesReady("booted", second))
|
|
46
|
+
assertEquals(2, inits())
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Test fun `an answer from another glasses process is handled with no exchange pending`() = withLive { live, inits ->
|
|
50
|
+
receive(live, socReady())
|
|
51
|
+
val readyId = pendingReadyId(live)
|
|
52
|
+
receive(live, glassesReady("booted", readyId))
|
|
53
|
+
|
|
54
|
+
// A restarted process reset its transport for this copy, so it is not a repeat.
|
|
55
|
+
receive(live, glassesReady("restarted", readyId))
|
|
56
|
+
assertEquals(2, inits())
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Test fun `a restarted process answering an older copy is handled and the pending exchange still counts`() = withLive { live, inits ->
|
|
60
|
+
receive(live, socReady())
|
|
61
|
+
val first = pendingReadyId(live)
|
|
62
|
+
receive(live, glassesReady("booted", first))
|
|
63
|
+
invoke(live, "sendPhoneReady", "glasses session changed")
|
|
64
|
+
val second = pendingReadyId(live)
|
|
65
|
+
|
|
66
|
+
// The restarted process reset for a buffered copy of the old exchange, then resets
|
|
67
|
+
// again for the pending one: both answers follow a reset.
|
|
68
|
+
receive(live, glassesReady("restarted", first))
|
|
69
|
+
assertEquals(2, inits())
|
|
70
|
+
receive(live, glassesReady("restarted", second))
|
|
71
|
+
assertEquals(3, inits())
|
|
72
|
+
receive(live, glassesReady("restarted", second))
|
|
73
|
+
assertEquals(3, inits())
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Test fun `the readiness exchange ends with the BLE session`() = withLive { live, _ ->
|
|
77
|
+
receive(live, socReady())
|
|
78
|
+
val first = pendingReadyId(live)
|
|
79
|
+
invoke(live, "updateConnectionState", ConnTypes.DISCONNECTED)
|
|
80
|
+
|
|
81
|
+
receive(live, socReady())
|
|
82
|
+
assertNotEquals(first, pendingReadyId(live))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Test fun `glasses without readyId keep initializing on every answer`() = withLive { live, inits ->
|
|
86
|
+
receive(live, glassesReady("legacy", null))
|
|
87
|
+
receive(live, glassesReady("legacy", null))
|
|
88
|
+
assertEquals(2, inits())
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Runs `body` on a fresh MentraLive with a live link, counting SOC inits (one version
|
|
93
|
+
* request each). glasses_ready is only accepted on a live link.
|
|
94
|
+
*/
|
|
95
|
+
private fun withLive(body: (MentraLive, () -> Int) -> Unit) {
|
|
96
|
+
Bridge.initialize(ApplicationProvider.getApplicationContext())
|
|
97
|
+
val live = MentraLive()
|
|
98
|
+
MentraLive::class.java.getDeclaredField("isConnected").apply { isAccessible = true }.set(live, true)
|
|
99
|
+
var inits = 0
|
|
100
|
+
val sink = Bridge.addEventSink { type, event ->
|
|
101
|
+
if (type == "log" && event["message"].toString().contains("Requesting version info from ASG client")) {
|
|
102
|
+
inits++
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
body(live) { inits }
|
|
107
|
+
} finally {
|
|
108
|
+
Bridge.removeEventSink(sink)
|
|
109
|
+
live.destroy()
|
|
110
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofSeconds(2))
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private fun socReady() = JSONObject().put("C", "sr_hrt").put("B", JSONObject().put("ready", 1))
|
|
115
|
+
|
|
116
|
+
private fun glassesReady(sid: String, readyId: String?) = JSONObject().apply {
|
|
117
|
+
put("type", "glasses_ready")
|
|
118
|
+
put("sid", sid)
|
|
119
|
+
if (readyId != null) put("readyId", readyId)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private fun pendingReadyId(live: MentraLive): String {
|
|
123
|
+
val readyId = MentraLive::class.java.getDeclaredField("pendingReadyId")
|
|
124
|
+
.apply { isAccessible = true }
|
|
125
|
+
.get(live) as String?
|
|
126
|
+
assertNotNull("SOC ready should start a readiness exchange", readyId)
|
|
127
|
+
return readyId!!
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private fun receive(live: MentraLive, json: JSONObject) {
|
|
131
|
+
MentraLive::class.java.getDeclaredMethod("processJsonMessage", JSONObject::class.java)
|
|
132
|
+
.apply { isAccessible = true }
|
|
133
|
+
.invoke(live, json)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private fun invoke(live: MentraLive, name: String, argument: String) {
|
|
137
|
+
MentraLive::class.java.getDeclaredMethod(name, String::class.java)
|
|
138
|
+
.apply { isAccessible = true }
|
|
139
|
+
.invoke(live, argument)
|
|
140
|
+
}
|
|
141
|
+
}
|