@mentra/bluetooth-sdk 3.5.0-dev.1260 → 3.5.0-dev.1261
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/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +318 -18
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleUploadService.java +13 -6
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +291 -14
- package/build/generated/releaseMetadata.js +5 -5
- package/build/generated/releaseMetadata.js.map +1 -1
- package/ios/Source/BluetoothSdkDefaults.swift +1 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
- package/ios/Source/sgcs/MentraLive.swift +310 -28
- package/ios/Tests/IncidentLogDispatchTests.swift +257 -5
- package/package.json +2 -2
- package/src/generated/releaseMetadata.ts +5 -5
package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt
CHANGED
|
@@ -9,6 +9,7 @@ import com.mentra.bluetoothsdk.BluetoothSdkException
|
|
|
9
9
|
import com.mentra.bluetoothsdk.Bridge
|
|
10
10
|
import com.mentra.bluetoothsdk.DeviceStore
|
|
11
11
|
import com.mentra.bluetoothsdk.utils.IncidentLogBleRelayNaming
|
|
12
|
+
import java.io.File
|
|
12
13
|
import java.net.ServerSocket
|
|
13
14
|
import java.net.SocketException
|
|
14
15
|
import java.nio.charset.StandardCharsets
|
|
@@ -52,6 +53,15 @@ class MentraLiveIncidentDispatchTest {
|
|
|
52
53
|
prefs.edit().remove("core_token").commit()
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
@Test fun `no Core URL rejects instead of sending logs anywhere else`() = withLive { live ->
|
|
57
|
+
ready(live)
|
|
58
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
59
|
+
expectCode("core_url_unavailable") { live.sendIncidentId(incident, null) }
|
|
60
|
+
expectCode("core_url_unavailable") { live.sendIncidentId(incident, " ") }
|
|
61
|
+
assertTrue(queuedWrites(live).isEmpty())
|
|
62
|
+
assertTrue((get(live, "bleIncidentLogRelays") as Map<*, *>).isEmpty())
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
@Test fun `deletes the Core token older builds left in plain storage`() {
|
|
56
66
|
val context = ApplicationProvider.getApplicationContext<android.content.Context>()
|
|
57
67
|
val prefs = context.getSharedPreferences("augmentos_auth_prefs", android.content.Context.MODE_PRIVATE)
|
|
@@ -60,6 +70,14 @@ class MentraLiveIncidentDispatchTest {
|
|
|
60
70
|
assertFalse(prefs.contains("core_token"))
|
|
61
71
|
}
|
|
62
72
|
|
|
73
|
+
@Test fun `the Core URL stays on the phone`() = withLive { live ->
|
|
74
|
+
ready(live)
|
|
75
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
76
|
+
live.sendIncidentId(incident, apiBase)
|
|
77
|
+
assertTrue(wire(live).contains("upload_incident_logs"))
|
|
78
|
+
assertFalse(wire(live).contains("apiBaseUrl"))
|
|
79
|
+
}
|
|
80
|
+
|
|
63
81
|
@Test fun `current token is queued before upload and never logged`() = withLive { live ->
|
|
64
82
|
ready(live)
|
|
65
83
|
val token = "synthetic-${UUID.randomUUID()}"
|
|
@@ -116,24 +134,243 @@ class MentraLiveIncidentDispatchTest {
|
|
|
116
134
|
assertEquals(incident, relayOwner(live, IncidentLogBleRelayNaming.bleFileBaseName(incident, 'L')))
|
|
117
135
|
|
|
118
136
|
receiveRelayFile(live, name, "owner-evidence")
|
|
119
|
-
|
|
120
|
-
|
|
137
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
138
|
+
assertNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
139
|
+
assertEquals(incident, relayOwner(live, name))
|
|
121
140
|
val confirmation = wire(live).substringAfterLast("transfer_complete")
|
|
122
141
|
assertTrue(confirmation.contains(name) && confirmation.contains("\"success\":true"))
|
|
123
142
|
|
|
124
|
-
// The
|
|
143
|
+
// The BES bytes are held and the logcat name is still in flight, so the colliding
|
|
144
|
+
// report is still refused.
|
|
125
145
|
val logName = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'L')
|
|
126
146
|
expectCode("incident_relay_busy") { live.sendIncidentId(collidingIncident, cloud.base) }
|
|
127
147
|
receiveRelayFile(live, logName, "owner-logcat")
|
|
128
|
-
assertEquals("/api/client/reports/$incident/artifacts owner-logcat", cloud
|
|
129
|
-
|
|
148
|
+
assertEquals("/api/client/reports/$incident/artifacts owner-logcat", nextUpload(cloud))
|
|
149
|
+
assertEquals("/api/client/reports/$incident/artifacts owner-evidence", nextUpload(cloud))
|
|
150
|
+
awaitMain { relayOwner(live, logName) == null && relayOwner(live, name) == null }
|
|
130
151
|
|
|
131
152
|
live.sendIncidentId(collidingIncident, cloud.base)
|
|
132
153
|
receiveRelayFile(live, name, "second-evidence")
|
|
154
|
+
awaitMain { wire(live).substringAfterLast("transfer_complete").contains("\"success\":true") }
|
|
155
|
+
assertNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
156
|
+
receiveRelayFile(live, logName, "second-logcat")
|
|
157
|
+
assertEquals(
|
|
158
|
+
"/api/client/reports/$collidingIncident/artifacts second-logcat",
|
|
159
|
+
nextUpload(cloud),
|
|
160
|
+
)
|
|
133
161
|
assertEquals(
|
|
134
162
|
"/api/client/reports/$collidingIncident/artifacts second-evidence",
|
|
135
|
-
cloud
|
|
163
|
+
nextUpload(cloud),
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@Test fun `saves the bes log and uploads the mtk log before it`() = withLive { live ->
|
|
169
|
+
ready(live)
|
|
170
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
171
|
+
withCloud { cloud ->
|
|
172
|
+
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
173
|
+
val logName = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'L')
|
|
174
|
+
live.sendIncidentId(incident, cloud.base)
|
|
175
|
+
val bes = """{"retryKey":"bes-crash","entries":[{"source":"BES"}]}"""
|
|
176
|
+
receiveRelayFile(live, name, bes)
|
|
177
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
178
|
+
assertNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
179
|
+
assertEquals(incident, relayOwner(live, name))
|
|
180
|
+
|
|
181
|
+
receiveRelayFile(live, logName, """{"entries":[{"source":"MTK"}]}""")
|
|
182
|
+
assertEquals(
|
|
183
|
+
"""/api/client/reports/$incident/artifacts {"entries":[{"source":"MTK"}]}""",
|
|
184
|
+
nextUpload(cloud),
|
|
185
|
+
)
|
|
186
|
+
assertEquals(
|
|
187
|
+
"/api/client/reports/$incident/artifacts $bes",
|
|
188
|
+
nextUpload(cloud),
|
|
136
189
|
)
|
|
190
|
+
awaitMain { relayOwner(live, name) == null && relayOwner(live, logName) == null }
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@Test fun `a held BES log is durably persisted and re-uploaded after process death`() = withLive { live ->
|
|
195
|
+
ready(live)
|
|
196
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
197
|
+
withCloud { cloud ->
|
|
198
|
+
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
199
|
+
live.sendIncidentId(incident, cloud.base)
|
|
200
|
+
val bes = """{"source":"BES"}"""
|
|
201
|
+
receiveRelayFile(live, name, bes)
|
|
202
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
203
|
+
// Acknowledged to the glasses but not uploaded yet: the bytes must already be on disk.
|
|
204
|
+
assertNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
205
|
+
assertTrue(besHeldFile(incident).exists())
|
|
206
|
+
|
|
207
|
+
// Process death before the MTK log arrives: a fresh instance owns no relay and the
|
|
208
|
+
// glasses will not resend, so it must finish the upload from the durable copy.
|
|
209
|
+
val revived = MentraLive()
|
|
210
|
+
try {
|
|
211
|
+
invokeResume(revived)
|
|
212
|
+
assertEquals("/api/client/reports/$incident/artifacts $bes", nextUpload(cloud))
|
|
213
|
+
awaitMain { !besHeldFile(incident).exists() }
|
|
214
|
+
} finally {
|
|
215
|
+
revived.destroy()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@Test fun `a BES upload that fails during an outage is retried until Cloud confirms it`() = withLive { live ->
|
|
221
|
+
ready(live)
|
|
222
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
223
|
+
withCloud { cloud ->
|
|
224
|
+
cloud.status = 500
|
|
225
|
+
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
226
|
+
live.sendIncidentId(incident, cloud.base)
|
|
227
|
+
val bes = """{"source":"BES"}"""
|
|
228
|
+
receiveRelayFile(live, name, bes)
|
|
229
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
230
|
+
|
|
231
|
+
// No MTK log arrives, so after the hold the phone uploads the BES itself; both
|
|
232
|
+
// attempts fail against the outage.
|
|
233
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(31_000))
|
|
234
|
+
awaitMain { cloud.requests.isNotEmpty() }
|
|
235
|
+
var attempts = 0
|
|
236
|
+
while (cloud.requests.poll(300, TimeUnit.MILLISECONDS) != null) attempts++
|
|
237
|
+
assertTrue("expected at least one failed BES attempt", attempts >= 1)
|
|
238
|
+
// The acknowledged artifact is retained, not stranded: still owned and still on disk.
|
|
239
|
+
assertEquals(incident, relayOwner(live, name))
|
|
240
|
+
assertTrue(besHeldFile(incident).exists())
|
|
241
|
+
|
|
242
|
+
// Connectivity returns and the scheduled retry confirms the upload.
|
|
243
|
+
cloud.status = 200
|
|
244
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(61_000))
|
|
245
|
+
assertEquals("/api/client/reports/$incident/artifacts $bes", nextUpload(cloud))
|
|
246
|
+
awaitMain { relayOwner(live, name) == null && !besHeldFile(incident).exists() }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@Test fun `a saved BES log waits for its own account and Core`() = withLive { live ->
|
|
251
|
+
ready(live)
|
|
252
|
+
DeviceStore.set("bluetooth", "core_token", jwt("https://core-a", "user-a"))
|
|
253
|
+
withCloud { cloud ->
|
|
254
|
+
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
255
|
+
live.sendIncidentId(incident, cloud.base)
|
|
256
|
+
val bes = """{"source":"BES"}"""
|
|
257
|
+
receiveRelayFile(live, name, bes)
|
|
258
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
259
|
+
endProcess(live)
|
|
260
|
+
|
|
261
|
+
val revived = MentraLive()
|
|
262
|
+
try {
|
|
263
|
+
for (other in listOf(jwt("https://core-b", "user-a"), jwt("https://core-a", "user-b"))) {
|
|
264
|
+
DeviceStore.set("bluetooth", "core_token", other)
|
|
265
|
+
invokeResume(revived)
|
|
266
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(61_000))
|
|
267
|
+
assertNull(cloud.requests.poll(300, TimeUnit.MILLISECONDS))
|
|
268
|
+
}
|
|
269
|
+
assertTrue(besHeldFile(incident).exists())
|
|
270
|
+
|
|
271
|
+
DeviceStore.set("bluetooth", "core_token", jwt("https://core-a", "user-a"))
|
|
272
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(61_000))
|
|
273
|
+
assertEquals("/api/client/reports/$incident/artifacts $bes", nextUpload(cloud))
|
|
274
|
+
awaitMain { !besHeldFile(incident).exists() }
|
|
275
|
+
} finally {
|
|
276
|
+
revived.destroy()
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private fun jwt(iss: String, sub: String): String {
|
|
282
|
+
val claims = """{"iss":"$iss","sub":"$sub"}""".toByteArray(StandardCharsets.UTF_8)
|
|
283
|
+
return "h." + java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(claims) + ".s"
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
@Test fun `an MTK transfer cut off partway stops holding the BES log`() = withLive { live ->
|
|
287
|
+
ready(live)
|
|
288
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
289
|
+
withCloud { cloud ->
|
|
290
|
+
val besName = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
291
|
+
val mtkName = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'L')
|
|
292
|
+
live.sendIncidentId(incident, cloud.base)
|
|
293
|
+
val bes = """{"source":"BES"}"""
|
|
294
|
+
receiveRelayFile(live, besName, bes)
|
|
295
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
296
|
+
// Part of the MTK file arrived, then the link dropped: nothing will ever finish it.
|
|
297
|
+
val mtkRelay = (get(live, "bleIncidentLogRelays") as Map<*, *>)[mtkName]!!
|
|
298
|
+
mtkRelay.javaClass.getDeclaredField("session").apply { isAccessible = true }
|
|
299
|
+
.set(mtkRelay, MentraLive.FileTransferSession(mtkName, 100_000))
|
|
300
|
+
|
|
301
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(31_000))
|
|
302
|
+
assertNull(cloud.requests.poll(300, TimeUnit.MILLISECONDS))
|
|
303
|
+
|
|
304
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(121_000))
|
|
305
|
+
assertEquals("/api/client/reports/$incident/artifacts $bes", nextUpload(cloud))
|
|
306
|
+
awaitMain { !besHeldFile(incident).exists() }
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
@Test fun `a BES log that cannot be saved is refused so the glasses keep their copy`() = withLive { live ->
|
|
311
|
+
ready(live)
|
|
312
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
313
|
+
withCloud { cloud ->
|
|
314
|
+
// A file where the directory belongs makes every save fail.
|
|
315
|
+
besHeldDir().deleteRecursively()
|
|
316
|
+
besHeldDir().writeText("not a directory")
|
|
317
|
+
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
318
|
+
live.sendIncidentId(incident, cloud.base)
|
|
319
|
+
receiveRelayFile(live, name, """{"source":"BES"}""")
|
|
320
|
+
awaitMain { wire(live).contains("\"success\":false") }
|
|
321
|
+
assertFalse(wire(live).contains("\"success\":true"))
|
|
322
|
+
assertEquals(incident, relayOwner(live, name))
|
|
323
|
+
besHeldDir().delete()
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@Test fun `a BES log Cloud permanently refuses is dropped instead of retried forever`() = withLive { live ->
|
|
328
|
+
ready(live)
|
|
329
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
330
|
+
withCloud { cloud ->
|
|
331
|
+
cloud.status = 404
|
|
332
|
+
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
333
|
+
live.sendIncidentId(incident, cloud.base)
|
|
334
|
+
receiveRelayFile(live, name, """{"source":"BES"}""")
|
|
335
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
336
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(31_000))
|
|
337
|
+
awaitMain { relayOwner(live, name) == null && !besHeldFile(incident).exists() }
|
|
338
|
+
assertNotNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
339
|
+
assertNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
340
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(61_000))
|
|
341
|
+
assertNull(cloud.requests.poll(300, TimeUnit.MILLISECONDS))
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@Test fun `reconnecting during an outage does not start a second resume of a saved BES log`() = withLive { live ->
|
|
346
|
+
ready(live)
|
|
347
|
+
DeviceStore.set("bluetooth", "core_token", "synthetic")
|
|
348
|
+
withCloud { cloud ->
|
|
349
|
+
cloud.status = 500
|
|
350
|
+
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
351
|
+
live.sendIncidentId(incident, cloud.base)
|
|
352
|
+
receiveRelayFile(live, name, """{"source":"BES"}""")
|
|
353
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
354
|
+
endProcess(live)
|
|
355
|
+
|
|
356
|
+
val revived = MentraLive()
|
|
357
|
+
try {
|
|
358
|
+
invokeResume(revived)
|
|
359
|
+
awaitMain { cloud.requests.isNotEmpty() }
|
|
360
|
+
while (cloud.requests.poll(300, TimeUnit.MILLISECONDS) != null) {}
|
|
361
|
+
invokeResume(revived)
|
|
362
|
+
invokeResume(revived)
|
|
363
|
+
shadowOf(Looper.getMainLooper()).idle()
|
|
364
|
+
assertNull(cloud.requests.poll(300, TimeUnit.MILLISECONDS))
|
|
365
|
+
|
|
366
|
+
cloud.status = 200
|
|
367
|
+
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(61_000))
|
|
368
|
+
awaitMain { !besHeldFile(incident).exists() }
|
|
369
|
+
assertNotNull(cloud.requests.poll(300, TimeUnit.MILLISECONDS))
|
|
370
|
+
assertNull(cloud.requests.poll(300, TimeUnit.MILLISECONDS))
|
|
371
|
+
} finally {
|
|
372
|
+
revived.destroy()
|
|
373
|
+
}
|
|
137
374
|
}
|
|
138
375
|
}
|
|
139
376
|
|
|
@@ -146,19 +383,19 @@ class MentraLiveIncidentDispatchTest {
|
|
|
146
383
|
live.sendIncidentId(incident, cloud.base)
|
|
147
384
|
val staleRelay = (get(live, "bleIncidentLogRelays") as Map<*, *>)[name]!!
|
|
148
385
|
receiveRelayFile(live, name, "owner")
|
|
149
|
-
|
|
150
|
-
awaitMain { relayOwner(live, name) == null }
|
|
386
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
151
387
|
receiveRelayFile(live, logName, "owner-logcat")
|
|
152
|
-
assertNotNull(cloud
|
|
153
|
-
|
|
388
|
+
assertNotNull(nextUpload(cloud))
|
|
389
|
+
assertNotNull(nextUpload(cloud))
|
|
390
|
+
awaitMain { relayOwner(live, name) == null && relayOwner(live, logName) == null }
|
|
154
391
|
|
|
155
392
|
live.sendIncidentId(collidingIncident, cloud.base)
|
|
156
393
|
val confirmationsBefore = wire(live).split("transfer_complete").size
|
|
157
394
|
|
|
158
|
-
// A late callback of the first report's
|
|
395
|
+
// A late callback of the first report's file arrives while the colliding report owns the name.
|
|
159
396
|
uploadWith(live, staleRelay, name, "late-owner-evidence")
|
|
160
|
-
|
|
161
|
-
repeat(
|
|
397
|
+
assertNull(cloud.requests.poll(400, TimeUnit.MILLISECONDS))
|
|
398
|
+
repeat(20) { shadowOf(Looper.getMainLooper()).idle(); Thread.sleep(10) }
|
|
162
399
|
|
|
163
400
|
assertEquals(confirmationsBefore, wire(live).split("transfer_complete").size)
|
|
164
401
|
assertEquals(collidingIncident, relayOwner(live, name))
|
|
@@ -171,11 +408,17 @@ class MentraLiveIncidentDispatchTest {
|
|
|
171
408
|
withCloud { cloud ->
|
|
172
409
|
cloud.status = 500
|
|
173
410
|
val name = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'B')
|
|
411
|
+
val logName = IncidentLogBleRelayNaming.bleFileBaseName(incident, 'L')
|
|
174
412
|
live.sendIncidentId(incident, cloud.base)
|
|
175
413
|
receiveRelayFile(live, name, "owner-evidence")
|
|
176
|
-
|
|
414
|
+
awaitMain { wire(live).contains("\"success\":true") }
|
|
415
|
+
assertNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
416
|
+
receiveRelayFile(live, logName, "owner-logcat")
|
|
417
|
+
assertEquals("/api/client/reports/$incident/artifacts owner-logcat", nextUpload(cloud))
|
|
418
|
+
assertNull(cloud.requests.poll(200, TimeUnit.MILLISECONDS))
|
|
177
419
|
awaitMain { wire(live).contains("\"success\":false") }
|
|
178
420
|
assertEquals(incident, relayOwner(live, name))
|
|
421
|
+
assertEquals(incident, relayOwner(live, logName))
|
|
179
422
|
expectCode("incident_relay_busy") { live.sendIncidentId(collidingIncident, cloud.base) }
|
|
180
423
|
live.sendIncidentId(incident, cloud.base)
|
|
181
424
|
|
|
@@ -244,6 +487,19 @@ class MentraLiveIncidentDispatchTest {
|
|
|
244
487
|
|
|
245
488
|
private fun receiveRelayFile(live: MentraLive, name: String, payload: String) {
|
|
246
489
|
uploadWith(live, (get(live, "bleIncidentLogRelays") as Map<*, *>)[name]!!, name, payload)
|
|
490
|
+
// The relay posts its save-or-upload onto the paused main looper.
|
|
491
|
+
shadowOf(Looper.getMainLooper()).idle()
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
private fun nextUpload(cloud: FakeCloud): String {
|
|
495
|
+
val deadline = System.currentTimeMillis() + 5_000
|
|
496
|
+
while (cloud.requests.isEmpty() && System.currentTimeMillis() < deadline) {
|
|
497
|
+
shadowOf(Looper.getMainLooper()).idle()
|
|
498
|
+
Thread.sleep(10)
|
|
499
|
+
}
|
|
500
|
+
val request = cloud.requests.poll(200, TimeUnit.MILLISECONDS)
|
|
501
|
+
assertNotNull(request)
|
|
502
|
+
return request!!
|
|
247
503
|
}
|
|
248
504
|
|
|
249
505
|
private fun uploadWith(live: MentraLive, relay: Any, name: String, payload: String) {
|
|
@@ -289,9 +545,30 @@ class MentraLiveIncidentDispatchTest {
|
|
|
289
545
|
DeviceStore.set("glasses", "connected", connected ?: false)
|
|
290
546
|
live.destroy()
|
|
291
547
|
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofSeconds(2))
|
|
548
|
+
// destroy() deliberately keeps the durable held-BES copies on disk; clear the shared
|
|
549
|
+
// external dir so one test's unfinished upload cannot leak into the next.
|
|
550
|
+
besHeldDir().deleteRecursively()
|
|
292
551
|
}
|
|
293
552
|
}
|
|
294
553
|
|
|
554
|
+
private fun besHeldDir(): File {
|
|
555
|
+
val context = ApplicationProvider.getApplicationContext<android.content.Context>()
|
|
556
|
+
return File(context.getExternalFilesDir(null), "MentraLive_HeldBes")
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
private fun besHeldFile(incidentId: String): File = File(besHeldDir(), "$incidentId.json")
|
|
560
|
+
|
|
561
|
+
// The process died: the in-memory hold and its timers are gone, and the saved file remains.
|
|
562
|
+
private fun endProcess(live: MentraLive) {
|
|
563
|
+
MentraLive::class.java.getDeclaredMethod("clearHeldBesLogs")
|
|
564
|
+
.apply { isAccessible = true }.invoke(live)
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
private fun invokeResume(live: MentraLive) {
|
|
568
|
+
MentraLive::class.java.getDeclaredMethod("resumePersistedBesUploads")
|
|
569
|
+
.apply { isAccessible = true }.invoke(live)
|
|
570
|
+
}
|
|
571
|
+
|
|
295
572
|
private fun expectCode(code: String, body: () -> Unit) {
|
|
296
573
|
try { body(); fail("Expected $code") } catch (error: BluetoothSdkException) { assertEquals(code, error.code) }
|
|
297
574
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const BLUETOOTH_SDK_RELEASE_METADATA = Object.freeze({
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"familyBaseVersion": "3.5.0",
|
|
4
|
-
"releaseIdentity": "3.5.0-dev.
|
|
5
|
-
"releaseSetId": "mentra-3.5.0-dev.
|
|
6
|
-
"sourceCommit": "
|
|
7
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
8
|
-
"otaManifestSha256": "
|
|
4
|
+
"releaseIdentity": "3.5.0-dev.1261",
|
|
5
|
+
"releaseSetId": "mentra-3.5.0-dev.1261",
|
|
6
|
+
"sourceCommit": "c8f6349da74f3a0ae62c979a59aafbf62c644f7c",
|
|
7
|
+
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1261.json",
|
|
8
|
+
"otaManifestSha256": "fc13b964185dce4340c5e6f2481c3894c7b53ee1d57d6119dbcaad64e8ff0496"
|
|
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,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,kIAAkI;IACpJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\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 BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.5.0\",\n \"releaseIdentity\": \"3.5.0-dev.
|
|
1
|
+
{"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,uBAAuB;IACvC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,kIAAkI;IACpJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\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 BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.5.0\",\n \"releaseIdentity\": \"3.5.0-dev.1261\",\n \"releaseSetId\": \"mentra-3.5.0-dev.1261\",\n \"sourceCommit\": \"c8f6349da74f3a0ae62c979a59aafbf62c644f7c\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1261.json\",\n \"otaManifestSha256\": \"fc13b964185dce4340c5e6f2481c3894c7b53ee1d57d6119dbcaad64e8ff0496\"\n})\n"]}
|
|
@@ -16,7 +16,7 @@ enum BluetoothSdkDefaults {
|
|
|
16
16
|
/// silently disable it on every pair the app touches.
|
|
17
17
|
static let autoPowerOffEnabled = true
|
|
18
18
|
private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
|
|
19
|
-
private static let swiftPackageSdkVersion = "3.5.0-dev.
|
|
19
|
+
private static let swiftPackageSdkVersion = "3.5.0-dev.1261"
|
|
20
20
|
private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
|
|
21
21
|
|
|
22
22
|
private static func normalizedSdkVersion(_ value: String?) -> String? {
|
|
@@ -3,9 +3,9 @@ import Foundation
|
|
|
3
3
|
/// Generated by release CI. Do not edit in a release checkout.
|
|
4
4
|
enum GeneratedReleaseMetadata {
|
|
5
5
|
static let familyBaseVersion = "3.5.0"
|
|
6
|
-
static let releaseIdentity = "3.5.0-dev.
|
|
7
|
-
static let releaseSetId = "mentra-3.5.0-dev.
|
|
8
|
-
static let sourceCommit = "
|
|
9
|
-
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.
|
|
10
|
-
static let otaManifestSha256 = "
|
|
6
|
+
static let releaseIdentity = "3.5.0-dev.1261"
|
|
7
|
+
static let releaseSetId = "mentra-3.5.0-dev.1261"
|
|
8
|
+
static let sourceCommit = "c8f6349da74f3a0ae62c979a59aafbf62c644f7c"
|
|
9
|
+
static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1261.json"
|
|
10
|
+
static let otaManifestSha256 = "fc13b964185dce4340c5e6f2481c3894c7b53ee1d57d6119dbcaad64e8ff0496"
|
|
11
11
|
}
|