@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.
Files changed (215) hide show
  1. package/MIGRATION.md +16 -7
  2. package/README.md +40 -13
  3. package/android/build.gradle +60 -51
  4. package/android/gradle.properties +3 -0
  5. package/android/settings.gradle +47 -3
  6. package/android/src/main/assets/nimo/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
  7. package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
  8. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -1
  9. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +77 -6
  10. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +41 -0
  11. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +114 -122
  12. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +2 -2
  13. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
  14. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +31 -10
  15. package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +57 -196
  16. package/android/src/main/java/com/mentra/bluetoothsdk/OtaManifest.kt +1 -16
  17. package/android/src/main/java/com/mentra/bluetoothsdk/debug/BleTraceLogger.kt +10 -1
  18. package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
  19. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/Ipv4Prefix.kt +51 -0
  20. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/NetworkFacts.kt +81 -0
  21. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkError.kt +108 -0
  22. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadiness.kt +103 -0
  23. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpec.kt +44 -0
  24. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkState.kt +117 -0
  25. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedSoftApNetwork.kt +598 -0
  26. package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/SoftApTrace.kt +143 -0
  27. package/android/src/main/java/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt +0 -7
  28. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTracker.kt +15 -0
  29. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +274 -56
  30. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +5 -5
  31. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +210 -325
  32. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +0 -35
  33. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +2 -10
  34. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdater.kt +213 -0
  35. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocol.kt +112 -0
  36. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
  37. package/android/src/main/java/com/mentra/bluetoothsdk/streaming/StreamModels.kt +17 -6
  38. package/android/src/main/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueue.kt +92 -0
  39. package/android/src/main/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHost.kt +169 -0
  40. package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +74 -115
  41. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +348 -357
  42. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetector.kt +211 -0
  43. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngine.kt +137 -0
  44. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SttTextFormatter.kt +52 -0
  45. package/android/src/main/java/com/mentra/bluetoothsdk/stt/WakeWordDetector.kt +235 -0
  46. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AvifExifStripper.java +2 -2
  47. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +3 -3
  48. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +11 -0
  49. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/AudioRouteWatcher.kt +120 -0
  50. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +181 -16
  51. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlayback.kt +177 -0
  52. package/android/src/test/java/com/mentra/bluetoothsdk/BesCrashReportWaitersTest.kt +112 -0
  53. package/android/src/test/java/com/mentra/bluetoothsdk/StreamRequestCaptureAudioTest.kt +23 -4
  54. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/Ipv4PrefixTest.kt +59 -0
  55. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/NetworkFactsTest.kt +59 -0
  56. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedLocalNetworkPermissionTest.kt +35 -0
  57. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkErrorTest.kt +85 -0
  58. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkLifecycleTest.kt +164 -0
  59. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadinessTest.kt +141 -0
  60. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpecTest.kt +56 -0
  61. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/SoftApTraceTest.kt +97 -0
  62. package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/UnavailableRetryTest.kt +47 -0
  63. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTrackerTest.kt +26 -0
  64. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveGlassesReadyBurstTest.kt +141 -0
  65. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +183 -0
  66. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +3 -3
  67. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveRgbLedResponseTest.kt +76 -0
  68. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
  69. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
  70. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareTargetTest.kt +15 -0
  71. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdaterTest.kt +76 -0
  72. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocolTest.kt +77 -0
  73. package/android/src/test/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNamingTest.kt +23 -0
  74. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoReadinessDriverTest.kt +31 -1
  75. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueueTest.kt +81 -0
  76. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHostTest.kt +216 -0
  77. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/STTToolsExtractionTest.kt +108 -0
  78. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetectorTest.kt +126 -0
  79. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngineTest.kt +245 -0
  80. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SttTextFormatterTest.kt +67 -0
  81. package/android/src/testDebug/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlaybackTest.kt +76 -0
  82. package/build/BluetoothSdk.types.d.ts +103 -5
  83. package/build/BluetoothSdk.types.d.ts.map +1 -1
  84. package/build/BluetoothSdk.types.js.map +1 -1
  85. package/build/_private/BluetoothSdkModule.d.ts +42 -8
  86. package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
  87. package/build/_private/BluetoothSdkModule.js +1 -0
  88. package/build/_private/BluetoothSdkModule.js.map +1 -1
  89. package/build/_private/MentraLocalNetworkModule.d.ts +1 -1
  90. package/build/_private/MentraLocalNetworkModule.d.ts.map +1 -1
  91. package/build/_private/MentraLocalNetworkModule.js.map +1 -1
  92. package/build/generated/changelogCatalog.d.ts +2 -2
  93. package/build/generated/changelogCatalog.js +2 -2
  94. package/build/generated/changelogCatalog.js.map +1 -1
  95. package/build/generated/releaseMetadata.js +5 -5
  96. package/build/generated/releaseMetadata.js.map +1 -1
  97. package/build/index.d.ts +1 -1
  98. package/build/index.d.ts.map +1 -1
  99. package/build/index.js +7 -1
  100. package/build/index.js.map +1 -1
  101. package/build/ota-server/MentraOtaServerModule.d.ts +0 -2
  102. package/build/ota-server/MentraOtaServerModule.d.ts.map +1 -1
  103. package/build/ota-server/MentraOtaServerModule.js.map +1 -1
  104. package/build/ota-server/MentraOtaServerModule.web.d.ts +0 -1
  105. package/build/ota-server/MentraOtaServerModule.web.d.ts.map +1 -1
  106. package/build/ota-server/MentraOtaServerModule.web.js +0 -3
  107. package/build/ota-server/MentraOtaServerModule.web.js.map +1 -1
  108. package/build/ota-transport/index.d.ts +3 -3
  109. package/build/ota-transport/index.d.ts.map +1 -1
  110. package/build/ota-transport/index.js +4 -4
  111. package/build/ota-transport/index.js.map +1 -1
  112. package/build/react/useGlassesConnection.d.ts +1 -1
  113. package/build/react/useGlassesConnection.d.ts.map +1 -1
  114. package/build/react/useGlassesConnection.js +3 -3
  115. package/build/react/useGlassesConnection.js.map +1 -1
  116. package/build/react/useMentraBluetooth.d.ts +1 -1
  117. package/build/react/useMentraBluetooth.d.ts.map +1 -1
  118. package/build/react/useMentraBluetooth.js +1 -1
  119. package/build/react/useMentraBluetooth.js.map +1 -1
  120. package/ios/BluetoothSdkModule.swift +73 -22
  121. package/ios/LocalIPv4.swift +0 -61
  122. package/ios/MentraBluetoothSDK.podspec +7 -1
  123. package/ios/MentraOtaServerModule.swift +0 -16
  124. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
  125. package/ios/Resources/NimoFirmware/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
  126. package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
  127. package/ios/Source/BesCrashReportWaiters.swift +64 -0
  128. package/ios/Source/BluetoothSdkDefaults.swift +4 -4
  129. package/ios/Source/Bridge.swift +14 -0
  130. package/ios/Source/DeviceManager.swift +43 -22
  131. package/ios/Source/GeneratedChangelogCatalog.swift +2 -2
  132. package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
  133. package/ios/Source/MentraBluetoothSDK.swift +35 -16
  134. package/ios/Source/OtaManifest.swift +1 -17
  135. package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
  136. package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
  137. package/ios/Source/audio/SpeechActivity.swift +277 -0
  138. package/ios/Source/events/BluetoothEvents.swift +41 -0
  139. package/ios/Source/internal/BleTraceLogger.swift +14 -1
  140. package/ios/Source/internal/BluetoothAvailability.swift +15 -5
  141. package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
  142. package/ios/Source/sgcs/MentraLive.swift +195 -66
  143. package/ios/Source/sgcs/Nimo.swift +249 -276
  144. package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
  145. package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
  146. package/ios/Source/sgcs/NimoFirmwareUpdater.swift +260 -0
  147. package/ios/Source/sgcs/NimoOtaProtocol.swift +159 -0
  148. package/ios/Source/sgcs/SGCManager.swift +6 -0
  149. package/ios/Source/streaming/StreamModels.swift +15 -6
  150. package/ios/Source/stt/STTTools.swift +13 -31
  151. package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
  152. package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
  153. package/ios/Source/stt/WakeWordDetector.swift +145 -0
  154. package/ios/Source/utils/BoundedWait.swift +44 -0
  155. package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
  156. package/ios/Source/utils/SttModelTraits.swift +62 -0
  157. package/ios/Tests/BesCrashReportTests.swift +142 -0
  158. package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
  159. package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
  160. package/ios/Tests/GlassesAudioSetupPolicyTests.swift +9 -3
  161. package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
  162. package/ios/Tests/MentraLiveAudioSetupTests.swift +6 -12
  163. package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
  164. package/ios/Tests/MentraLiveSessionReadinessTests.swift +179 -10
  165. package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
  166. package/ios/Tests/NimoOtaProtocolTests.swift +78 -0
  167. package/ios/Tests/PcmStreamTests.swift +299 -0
  168. package/ios/Tests/SpeechActivityTests.swift +238 -0
  169. package/ios/Tests/StreamRequestTests.swift +18 -0
  170. package/ios/Tests/SttModelTraitsTests.swift +62 -0
  171. package/package.json +2 -2
  172. package/plugin/build/withAndroid.js +9 -11
  173. package/plugin/build/withKotlinVersion.d.ts +2 -0
  174. package/plugin/build/withKotlinVersion.js +46 -0
  175. package/src/BluetoothSdk.types.ts +107 -5
  176. package/src/_private/BluetoothSdkModule.ts +45 -8
  177. package/src/_private/MentraLocalNetworkModule.ts +5 -1
  178. package/src/generated/changelogCatalog.ts +2 -2
  179. package/src/generated/releaseMetadata.ts +5 -5
  180. package/src/index.ts +13 -1
  181. package/src/ota-server/MentraOtaServerModule.ts +0 -2
  182. package/src/ota-server/MentraOtaServerModule.web.ts +0 -4
  183. package/src/ota-transport/index.ts +4 -5
  184. package/src/react/useGlassesConnection.ts +4 -4
  185. package/src/react/useMentraBluetooth.ts +2 -2
  186. package/android/silero/LICENSE.md +0 -17
  187. package/android/silero/build.gradle +0 -50
  188. package/android/silero/proguard-rules.pro +0 -24
  189. package/android/silero/src/androidTest/assets/hello.wav +0 -0
  190. package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
  191. package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
  192. package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
  193. package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
  194. package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
  195. package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
  196. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
  197. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
  198. package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
  199. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
  200. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
  201. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
  202. package/android/src/main/java/com/mentra/bluetoothsdk/ScopedNetworkReadiness.kt +0 -17
  203. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
  204. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
  205. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
  206. package/android/src/test/java/com/mentra/bluetoothsdk/ScopedNetworkReadinessTest.kt +0 -39
  207. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
  208. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
  209. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
  210. package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
  211. package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
  212. package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
  213. package/ios/Tests/NimoResourceSessionTests.swift +0 -476
  214. /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
  215. /package/android/{silero/src/main/assets → src/main/assets/vad}/silero_vad.onnx +0 -0
@@ -0,0 +1,598 @@
1
+ package com.mentra.bluetoothsdk.hotspot
2
+
3
+ import android.content.Context
4
+ import android.content.pm.PackageManager
5
+ import android.net.ConnectivityManager
6
+ import android.net.LinkProperties
7
+ import android.net.Network
8
+ import android.net.NetworkCapabilities
9
+ import android.net.NetworkRequest
10
+ import android.net.wifi.WifiManager
11
+ import android.net.wifi.WifiNetworkSpecifier
12
+ import android.os.Build
13
+ import java.net.Inet4Address
14
+ import java.util.concurrent.CountDownLatch
15
+
16
+ /**
17
+ * Joins the glasses' SoftAP as a scoped, internet-less network and keeps the [Network] handle
18
+ * in-process.
19
+ *
20
+ * Gallery sync and hotspot OTA (through `MentraLocalNetworkModule`), Mentra Call and the managed
21
+ * relay all join through this class, so the hotspot has one join on Android. Callers that use
22
+ * libwebrtc bind their sockets to the [Network] it produces.
23
+ *
24
+ * ## Dual-homing
25
+ *
26
+ * The request drops `NET_CAPABILITY_INTERNET` (see [ScopedNetworkRequestSpec]), so Android never
27
+ * promotes the hotspot to the default network and ACS keeps using cellular.
28
+ */
29
+ class ScopedSoftApNetwork(private val context: Context) {
30
+
31
+ /** Notified on the ConnectivityManager callback thread. */
32
+ interface Listener {
33
+ fun onAvailable(network: Network, localIpv4: String)
34
+
35
+ fun onLost(error: ScopedNetworkError)
36
+ }
37
+
38
+ private val lock = Any()
39
+ private val state = ScopedNetworkState()
40
+ private val readiness = ScopedNetworkReadiness()
41
+
42
+ private var callback: ConnectivityManager.NetworkCallback? = null
43
+ /** The pending request's wait, so [release] can end it at once. */
44
+ private var pendingReady: CountDownLatch? = null
45
+ /** Counts [release] calls; a join that saw one stops instead of retrying. */
46
+ private var releases = 0
47
+ private var network: Network? = null
48
+ private var localIpv4: String? = null
49
+ private var spec: ScopedNetworkRequestSpec? = null
50
+ private var listener: Listener? = null
51
+
52
+ /** The joined network, or null. Pass this to anything that must send over the SoftAP link. */
53
+ fun network(): Network? = synchronized(lock) { network }
54
+
55
+ /** This phone's address on the hotspot subnet, e.g. `192.168.43.20`. */
56
+ fun localIpv4(): String? = synchronized(lock) { localIpv4 }
57
+
58
+ /**
59
+ * The subnet this phone joined, straight from `LinkProperties`.
60
+ *
61
+ * This is the invariant every SoftAP media check is written against: the selected ICE candidate
62
+ * has to be on *this* prefix, not merely on some private range. Reading the prefix length rather
63
+ * than assuming /24 is what keeps the check true when an OEM hands out a different hotspot
64
+ * subnet.
65
+ */
66
+ fun scopedPrefix(): Ipv4Prefix? {
67
+ val net = network() ?: return null
68
+ val properties = connectivityManager().getLinkProperties(net) ?: return null
69
+ return properties.linkAddresses
70
+ .firstOrNull { it.address is Inet4Address }
71
+ ?.let { link -> link.address.hostAddress?.let { Ipv4Prefix(it, link.prefixLength) } }
72
+ }
73
+
74
+ fun isAvailable(): Boolean = synchronized(lock) { state.phase == ScopedNetworkState.Phase.AVAILABLE }
75
+
76
+ /** Station radio on? `WifiNetworkSpecifier` is a no-op while this is false. */
77
+ fun isWifiEnabled(): Boolean {
78
+ val wifi = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as? WifiManager
79
+ return wifi?.isWifiEnabled == true
80
+ }
81
+
82
+ /**
83
+ * Block until the station radio is on, or [timeoutMs] elapses. Used after the system Wi-Fi
84
+ * panel is shown: the join must wait for the user, not abort and remint ACS over a broken
85
+ * default route.
86
+ */
87
+ fun awaitWifiEnabled(timeoutMs: Long = WIFI_ENABLE_WAIT_MS): Boolean {
88
+ if (isWifiEnabled()) return true
89
+ val deadline = android.os.SystemClock.elapsedRealtime() + timeoutMs
90
+ while (android.os.SystemClock.elapsedRealtime() < deadline) {
91
+ Thread.sleep(WIFI_ENABLE_POLL_MS)
92
+ if (isWifiEnabled()) return true
93
+ }
94
+ return isWifiEnabled()
95
+ }
96
+
97
+ /**
98
+ * True when a VPN is this app's default network — i.e. our UID falls inside its captured
99
+ * ranges. A VPN that excludes us (split tunneling) or is simply installed does not count: the
100
+ * default network is then cellular/Wi-Fi and the hotspot path works.
101
+ */
102
+ fun isVpnCapturingApp(): Boolean {
103
+ val manager = connectivityManager()
104
+ val active = manager.activeNetwork ?: return false
105
+ val capabilities = manager.getNetworkCapabilities(active) ?: return false
106
+ return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)
107
+ }
108
+
109
+ /** Verdict of [probeGateway]: [detail] is one human-readable line for the UI and the trace. */
110
+ data class GatewayProbe(val reachable: Boolean, val detail: String)
111
+
112
+ /**
113
+ * The hotspot's own address on the joined network — the DHCP server, since the glasses
114
+ * deliberately advertise no default route. Falls back to `.1` of the phone's /24.
115
+ */
116
+ fun gatewayIpv4(): String? {
117
+ val net = network() ?: return null
118
+ val properties = connectivityManager().getLinkProperties(net)
119
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
120
+ properties?.dhcpServerAddress?.hostAddress?.let { return it }
121
+ }
122
+ val local = localIpv4() ?: return null
123
+ val prefix = local.substringBeforeLast('.', "")
124
+ return if (prefix.isEmpty()) null else "$prefix.1"
125
+ }
126
+
127
+ /**
128
+ * Prove the phone can reach the glasses over the network it just joined.
129
+ *
130
+ * TCP, through [Network.getSocketFactory], so the kernel routes via the hotspot's table rather
131
+ * than the cellular default that unbound sockets would take. A *refused* connection is a pass:
132
+ * the SYN arrived and the RST came back, which is the reachability question. Only a timeout or
133
+ * an unreachable-network error is a fail.
134
+ */
135
+ fun probeGateway(timeoutMs: Int = GATEWAY_PROBE_TIMEOUT_MS): GatewayProbe {
136
+ val net = network() ?: return GatewayProbe(false, "no scoped network")
137
+ val gateway = gatewayIpv4() ?: return GatewayProbe(false, "no gateway address on the scoped network")
138
+ var lastFailure = "no ports tried"
139
+ for (port in GATEWAY_PROBE_PORTS) {
140
+ val startedAt = android.os.SystemClock.elapsedRealtime()
141
+ val socket =
142
+ try {
143
+ net.socketFactory.createSocket()
144
+ } catch (error: java.io.IOException) {
145
+ // netd answers EPERM when a VPN owns our UID and forbids binding elsewhere.
146
+ val message = error.message ?: error.javaClass.simpleName
147
+ val detail =
148
+ if (message.contains("EPERM")) {
149
+ "cannot bind to the hotspot network ($message): a VPN is capturing this app"
150
+ } else {
151
+ "cannot bind to the hotspot network: $message"
152
+ }
153
+ SoftApTrace.failure("gateway_probe", "gateway" to gateway, "result" to detail)
154
+ return GatewayProbe(false, detail)
155
+ }
156
+ try {
157
+ socket.connect(java.net.InetSocketAddress(gateway, port), timeoutMs)
158
+ val elapsed = android.os.SystemClock.elapsedRealtime() - startedAt
159
+ SoftApTrace.stage("gateway_probe", "gateway" to gateway, "port" to port, "result" to "connected", "ms" to elapsed)
160
+ return GatewayProbe(true, "tcp $gateway:$port connected in ${elapsed}ms")
161
+ } catch (error: java.net.ConnectException) {
162
+ val elapsed = android.os.SystemClock.elapsedRealtime() - startedAt
163
+ val message = error.message ?: ""
164
+ if (message.contains("refused", ignoreCase = true)) {
165
+ SoftApTrace.stage("gateway_probe", "gateway" to gateway, "port" to port, "result" to "refused", "ms" to elapsed)
166
+ return GatewayProbe(true, "tcp $gateway:$port refused (host answered) in ${elapsed}ms")
167
+ }
168
+ lastFailure = "tcp $gateway:$port $message"
169
+ } catch (error: java.net.SocketTimeoutException) {
170
+ lastFailure = "tcp $gateway:$port timed out after ${timeoutMs}ms"
171
+ } catch (error: java.io.IOException) {
172
+ lastFailure = "tcp $gateway:$port ${error.message ?: error.javaClass.simpleName}"
173
+ } finally {
174
+ runCatching { socket.close() }
175
+ }
176
+ }
177
+ SoftApTrace.failure("gateway_probe", "gateway" to gateway, "result" to lastFailure)
178
+ return GatewayProbe(false, lastFailure)
179
+ }
180
+
181
+ /**
182
+ * Whether the local-network permission is granted. Below the SDK level that enforces it, access
183
+ * is implicit and this reports true.
184
+ */
185
+ fun hasLocalNetworkPermission(): Boolean =
186
+ hasLocalNetworkPermission(Build.VERSION.SDK_INT, context.applicationInfo.targetSdkVersion) {
187
+ context.checkSelfPermission(ScopedNetworkError.LOCAL_NETWORK_PERMISSION) ==
188
+ PackageManager.PERMISSION_GRANTED
189
+ }
190
+
191
+ /**
192
+ * Join [ssid] and block until it is usable or the request fails. An Unavailable request is
193
+ * made once more after a short settle; every caller gets that retry.
194
+ * [incoming] is false for a caller that only dials the glasses (gallery): a VPN that
195
+ * captures the app blocks the glasses reaching us, not us reaching them.
196
+ *
197
+ * @throws ScopedNetworkError on permission denial, timeout, or an unavailable network
198
+ */
199
+ @Throws(ScopedNetworkError::class)
200
+ fun join(ssid: String, passphrase: String, listener: Listener? = null, incoming: Boolean = true): Network {
201
+ if (!hasLocalNetworkPermission()) {
202
+ SoftApTrace.failure("scoped_join_permission_denied", "ssid" to ssid)
203
+ throw ScopedNetworkError.PermissionDenied(ScopedNetworkError.LOCAL_NETWORK_PERMISSION)
204
+ }
205
+
206
+ // A disabled radio makes WifiNetworkSpecifier fail as Unavailable in under 10ms, which is
207
+ // indistinguishable from a hotspot that never came up. Report the real cause instead.
208
+ if (!isWifiEnabled()) {
209
+ SoftApTrace.failure("scoped_join_wifi_disabled", "ssid" to ssid)
210
+ throw ScopedNetworkError.WifiDisabled()
211
+ }
212
+
213
+ // The specifier join would succeed, but the glasses could never complete a TCP handshake
214
+ // to our listener and we could not bind to the hotspot. Fail here, where the message can
215
+ // say why, instead of ten seconds into the camera step.
216
+ if (incoming && isVpnCapturingApp()) {
217
+ SoftApTrace.failure("scoped_join_vpn_captures_app", "ssid" to ssid)
218
+ throw ScopedNetworkError.VpnCapturesApp()
219
+ }
220
+
221
+ val releasesAtStart = synchronized(lock) { releases }
222
+ return retryUnavailableOnce(
223
+ request = { requestOnce(ssid, passphrase, listener) },
224
+ settle = {
225
+ SoftApTrace.stage("scoped_join_unavailable_retry", "ssid" to ssid, "settleMs" to UNAVAILABLE_RETRY_SETTLE_MS)
226
+ Thread.sleep(UNAVAILABLE_RETRY_SETTLE_MS)
227
+ },
228
+ released = { synchronized(lock) { releases } != releasesAtStart },
229
+ )
230
+ }
231
+
232
+ @Throws(ScopedNetworkError::class)
233
+ private fun requestOnce(ssid: String, passphrase: String, listener: Listener?): Network {
234
+ synchronized(lock) { releaseLocked() }
235
+
236
+ val requestSpec = ScopedNetworkRequestSpec.forSoftAp(ssid, passphrase)
237
+ val manager = connectivityManager()
238
+ val ready = CountDownLatch(1)
239
+
240
+ val generation: Int
241
+ synchronized(lock) {
242
+ pendingReady = ready
243
+ generation = state.startRequest()
244
+ spec = requestSpec
245
+ this.listener = listener
246
+ readiness.reset()
247
+ }
248
+ SoftApTrace.stage(
249
+ "scoped_join_requested",
250
+ "ssid" to ssid,
251
+ "avoidsInternetCapability" to requestSpec.avoidsInternetCapability,
252
+ )
253
+ val startedAtMs = System.currentTimeMillis()
254
+
255
+ val networkCallback =
256
+ object : ConnectivityManager.NetworkCallback() {
257
+ override fun onAvailable(available: Network) {
258
+ val properties = manager.getLinkProperties(available)
259
+ val resolvedIpv4 = firstIpv4(properties)
260
+ synchronized(lock) {
261
+ if (!state.onAvailable(generation)) return
262
+ network = available
263
+ localIpv4 = resolvedIpv4
264
+ readiness.onAvailable()
265
+ readiness.seedLinkProperties(properties?.interfaceName, resolvedIpv4)
266
+ }
267
+ SoftApTrace.stage(
268
+ "scoped_network_available",
269
+ "ssid" to ssid,
270
+ "localIpv4" to resolvedIpv4,
271
+ "joinMs" to (System.currentTimeMillis() - startedAtMs),
272
+ "defaultNetworkIsCellular" to defaultNetworkIsCellular(manager),
273
+ )
274
+ // Does the address we were just handed exist in the kernel's interface table,
275
+ // and under the name LinkProperties claims? ICE gathers from that table, so a
276
+ // mismatch here is the difference between a hotspot candidate and none. The
277
+ // address can also land in the table *after* onAvailable, which is why this is
278
+ // only a snapshot for the trace and readiness is decided by polling below.
279
+ val table = NetworkFacts.snapshot()
280
+ SoftApTrace.stage(
281
+ "scoped_network_ifaddrs",
282
+ "localIpv4" to resolvedIpv4,
283
+ "claimed" to (properties?.interfaceName ?: "none"),
284
+ "owner" to (resolvedIpv4?.let { NetworkFacts.ownerOf(it, table) } ?: "ABSENT"),
285
+ "gatherable" to NetworkFacts.render(NetworkFacts.gatherable(table)),
286
+ )
287
+ if (readiness.callbacksSatisfied()) ready.countDown()
288
+ }
289
+
290
+ /**
291
+ * The callback Android says to read properties from. It also arrives again when
292
+ * DHCP completes, which is the case `onAvailable` alone missed.
293
+ */
294
+ override fun onLinkPropertiesChanged(
295
+ changed: Network,
296
+ properties: LinkProperties,
297
+ ) {
298
+ val address = firstIpv4(properties)
299
+ synchronized(lock) {
300
+ if (!state.accepts(generation)) return
301
+ // Sticky, unlike the readiness observation: the WHIP listener is bound to
302
+ // this address and mid-call disappearance is `onLost`'s business, so a
303
+ // transient property update must not blank the ingest URL.
304
+ if (address != null) localIpv4 = address
305
+ readiness.onLinkProperties(properties.interfaceName, address)
306
+ }
307
+ SoftApTrace.stage(
308
+ "scoped_link_properties",
309
+ "interface" to (properties.interfaceName ?: "none"),
310
+ "localIpv4" to (address ?: "none"),
311
+ )
312
+ if (readiness.callbacksSatisfied()) ready.countDown()
313
+ }
314
+
315
+ override fun onCapabilitiesChanged(
316
+ changed: Network,
317
+ capabilities: NetworkCapabilities,
318
+ ) {
319
+ // A background network is not usable by the app yet; wait for the foreground.
320
+ if (!capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_FOREGROUND)) return
321
+ synchronized(lock) {
322
+ if (!state.accepts(generation)) return
323
+ readiness.onCapabilities()
324
+ }
325
+ if (readiness.callbacksSatisfied()) ready.countDown()
326
+ }
327
+
328
+ override fun onUnavailable() {
329
+ synchronized(lock) { if (!state.onUnavailable(generation)) return }
330
+ SoftApTrace.failure("scoped_network_unavailable", "ssid" to ssid)
331
+ ready.countDown()
332
+ }
333
+
334
+ override fun onLost(lost: Network) {
335
+ val notify: Listener?
336
+ synchronized(lock) {
337
+ if (!state.onLost(generation)) return
338
+ network = null
339
+ localIpv4 = null
340
+ notify = this@ScopedSoftApNetwork.listener
341
+ }
342
+ SoftApTrace.failure("scoped_network_lost", "ssid" to ssid)
343
+ ready.countDown()
344
+ notify?.onLost(ScopedNetworkError.Lost(ssid))
345
+ }
346
+ }
347
+
348
+ synchronized(lock) { callback = networkCallback }
349
+
350
+ try {
351
+ // No timeout: Android's "Connect to device?" prompt stays up only while the request
352
+ // does, and a person may take as long as they like to answer it. The engine keeps the
353
+ // glasses AP up meanwhile. The join ends on joining, a refusal, or release().
354
+ manager.requestNetwork(request(requestSpec), networkCallback)
355
+ } catch (error: SecurityException) {
356
+ synchronized(lock) { state.onRequestFailed(generation, permissionDenied = true) }
357
+ clearCallback(networkCallback)
358
+ SoftApTrace.failure("scoped_join_security_exception", "ssid" to ssid)
359
+ throw ScopedNetworkError.PermissionDenied(ScopedNetworkError.LOCAL_NETWORK_PERMISSION)
360
+ } catch (error: Exception) {
361
+ synchronized(lock) { state.onRequestFailed(generation, permissionDenied = false) }
362
+ clearCallback(networkCallback)
363
+ SoftApTrace.failure("scoped_join_request_failed", "ssid" to ssid)
364
+ throw ScopedNetworkError.RequestFailed(error.message ?: "unknown")
365
+ }
366
+
367
+ ready.await()
368
+
369
+ val joinedNetwork =
370
+ synchronized(lock) {
371
+ network.takeIf { state.phase == ScopedNetworkState.Phase.AVAILABLE }
372
+ }
373
+ if (joinedNetwork != null) {
374
+ val verdict = awaitReadiness(ssid)
375
+ val notify = synchronized(lock) { listener }
376
+ notify?.onAvailable(joinedNetwork, verdict.address)
377
+ probeUnmarkedUdpSend(verdict.address)
378
+ return joinedNetwork
379
+ }
380
+
381
+ throw synchronized(lock) {
382
+ // A release() wakes the wait with no failure recorded.
383
+ val failure = ScopedNetworkError.from(state.failure, ssid) ?: ScopedNetworkError.Cancelled(ssid)
384
+ releaseLocked()
385
+ failure
386
+ }
387
+ }
388
+
389
+ /**
390
+ * Block until the joined network is ready for ICE, or fail with the source that never reported.
391
+ *
392
+ * The kernel interface table is the one input with no callback, so it is polled: the hotspot
393
+ * address is regularly absent when `onAvailable` returns and appears a moment later. Starting
394
+ * ingest before it exists produced an answer with zero candidates, which looked identical to a
395
+ * binding bug and was misdiagnosed as one.
396
+ */
397
+ @Throws(ScopedNetworkError::class)
398
+ private fun awaitReadiness(ssid: String): ScopedNetworkReadiness.Verdict.Ready {
399
+ val deadline = android.os.SystemClock.elapsedRealtime() + READINESS_WAIT_MS
400
+ var verdict: ScopedNetworkReadiness.Verdict
401
+ while (true) {
402
+ val address = readiness.observations.linkAddress
403
+ readiness.onInterfaceTable(address?.let { NetworkFacts.ownerOf(it) })
404
+ verdict = readiness.verdict()
405
+ if (verdict is ScopedNetworkReadiness.Verdict.Ready) break
406
+ if (android.os.SystemClock.elapsedRealtime() >= deadline) break
407
+ Thread.sleep(READINESS_POLL_MS)
408
+ }
409
+
410
+ val observed = readiness.observations
411
+ if (verdict is ScopedNetworkReadiness.Verdict.Ready) {
412
+ SoftApTrace.stage(
413
+ "scoped_network_ready",
414
+ "localIpv4" to verdict.address,
415
+ "claimed" to (verdict.interfaceName ?: "none"),
416
+ "owner" to verdict.owner,
417
+ "agrees" to (verdict.interfaceName == null || verdict.interfaceName == verdict.owner),
418
+ "capabilitiesSeen" to observed.capabilities,
419
+ )
420
+ return verdict
421
+ }
422
+
423
+ val waiting = verdict as ScopedNetworkReadiness.Verdict.Waiting
424
+ SoftApTrace.failure(
425
+ "scoped_network_not_ready",
426
+ "ssid" to ssid,
427
+ "missing" to waiting.missing,
428
+ "localIpv4" to (observed.linkAddress ?: "none"),
429
+ "claimed" to (observed.linkInterface ?: "none"),
430
+ "capabilitiesSeen" to observed.capabilities,
431
+ "gatherable" to NetworkFacts.render(NetworkFacts.gatherable()),
432
+ )
433
+ release()
434
+ throw ScopedNetworkError.NotReady(ssid, waiting.missing)
435
+ }
436
+
437
+ /**
438
+ * Whether an unmarked UDP socket on the hotspot address can even be created and written to.
439
+ *
440
+ * Diagnostic only, and deliberately not a gate. A successful `send` means the OS accepted the
441
+ * datagram; it says nothing about whether the glasses received it or can reply, so it cannot
442
+ * establish that unmarked UDP works. What it *can* do is separate "bind refused outright" from
443
+ * "bound fine, nothing came back", which is the FAILED_BINDING hypothesis. The real answer to
444
+ * whether this path carries traffic is the ICE connectivity-check result.
445
+ */
446
+ private fun probeUnmarkedUdpSend(address: String) {
447
+ val gateway = gatewayIpv4()
448
+ val result =
449
+ runCatching {
450
+ java.net.DatagramSocket(0, java.net.InetAddress.getByName(address)).use { socket ->
451
+ val target = gateway ?: return@runCatching "bound to $address; no gateway to send to"
452
+ socket.send(
453
+ java.net.DatagramPacket(
454
+ ByteArray(1),
455
+ 1,
456
+ java.net.InetAddress.getByName(target),
457
+ UDP_PROBE_PORT,
458
+ ),
459
+ )
460
+ "bound to ${socket.localAddress?.hostAddress}:${socket.localPort}, send accepted"
461
+ }
462
+ }
463
+ SoftApTrace.stage(
464
+ "unmarked_udp_send",
465
+ "address" to address,
466
+ "gateway" to (gateway ?: "none"),
467
+ "accepted" to result.isSuccess,
468
+ "detail" to
469
+ (result.getOrNull() ?: result.exceptionOrNull()?.let { "${it.javaClass.simpleName}: ${it.message}" }),
470
+ "proves" to "the OS accepted a datagram; not that the glasses received one",
471
+ )
472
+ }
473
+
474
+ /** Drop the network. A join in progress on another thread stops waiting and fails. */
475
+ fun release() {
476
+ synchronized(lock) {
477
+ releases++
478
+ pendingReady?.countDown()
479
+ releaseLocked()
480
+ }
481
+ }
482
+
483
+ private fun releaseLocked() {
484
+ pendingReady = null
485
+ val active = callback
486
+ if (active != null) {
487
+ runCatching { connectivityManager().unregisterNetworkCallback(active) }
488
+ SoftApTrace.stage("scoped_network_released")
489
+ }
490
+ callback = null
491
+ network = null
492
+ localIpv4 = null
493
+ spec = null
494
+ listener = null
495
+ state.release()
496
+ state.reset()
497
+ }
498
+
499
+ private fun clearCallback(expected: ConnectivityManager.NetworkCallback) {
500
+ synchronized(lock) {
501
+ if (callback !== expected) return
502
+ runCatching { connectivityManager().unregisterNetworkCallback(expected) }
503
+ callback = null
504
+ }
505
+ }
506
+
507
+ private fun connectivityManager(): ConnectivityManager =
508
+ requireNotNull(context.getSystemService(ConnectivityManager::class.java)) {
509
+ "ConnectivityManager is unavailable"
510
+ }
511
+
512
+
513
+
514
+ /** Translate the pure spec into the framework request. */
515
+ private fun request(spec: ScopedNetworkRequestSpec): NetworkRequest {
516
+ val specifier =
517
+ WifiNetworkSpecifier.Builder()
518
+ .setSsid(spec.ssid)
519
+ .apply { if (spec.hasPassphrase) setWpa2Passphrase(spec.passphrase) }
520
+ .build()
521
+
522
+ val builder = NetworkRequest.Builder()
523
+ spec.transportTypes.forEach { builder.addTransportType(it) }
524
+ spec.removedCapabilities.forEach { builder.removeCapability(it) }
525
+ return builder.setNetworkSpecifier(specifier).build()
526
+ }
527
+
528
+ private fun firstIpv4(properties: LinkProperties?): String? =
529
+ properties
530
+ ?.linkAddresses
531
+ ?.firstOrNull { it.address is Inet4Address }
532
+ ?.address
533
+ ?.hostAddress
534
+
535
+ /** Dual-homing check: the default route must still be cellular after the scoped join. */
536
+ private fun defaultNetworkIsCellular(manager: ConnectivityManager): Boolean {
537
+ val active = manager.activeNetwork ?: return false
538
+ val capabilities = manager.getNetworkCapabilities(active) ?: return false
539
+ return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
540
+ }
541
+
542
+ companion object {
543
+ /** Android 17. `ACCESS_LOCAL_NETWORK` is enforced for apps targeting SDK 37+. */
544
+ const val LOCAL_NETWORK_ENFORCED_SDK = 37
545
+
546
+ /** Legacy targets retain implicit LAN access, even when the runtime grant reports denied. */
547
+ internal fun hasLocalNetworkPermission(
548
+ sdkInt: Int,
549
+ targetSdkInt: Int,
550
+ permissionGranted: () -> Boolean,
551
+ ): Boolean =
552
+ sdkInt < LOCAL_NETWORK_ENFORCED_SDK ||
553
+ targetSdkInt < LOCAL_NETWORK_ENFORCED_SDK ||
554
+ permissionGranted()
555
+
556
+ /** How long we hold the scoped-join step open for the user to flip the Wi-Fi toggle. */
557
+ const val WIFI_ENABLE_WAIT_MS = 90_000L
558
+ const val WIFI_ENABLE_POLL_MS = 300L
559
+ /** Radio + scan need a beat after `isWifiEnabled` flips before specifier can see the AP. */
560
+ const val WIFI_ENABLE_SETTLE_MS = 1_500L
561
+
562
+ /** The gap before [join] asks again after an Unavailable while leaving another AP. */
563
+ private const val UNAVAILABLE_RETRY_SETTLE_MS = 2_000L
564
+
565
+ /**
566
+ * Leaving the phone's current Wi-Fi (office AP, a phone hotspot) can make the first
567
+ * specifier fail as Unavailable: Samsung assoc-rejects the glasses SoftAP (status 1025)
568
+ * after dropping the old network. The same request from the now idle STA succeeds, so
569
+ * [join] asks once more, unless it was released before or during the settle.
570
+ */
571
+ internal fun <T> retryUnavailableOnce(request: () -> T, settle: () -> Unit, released: () -> Boolean): T =
572
+ try {
573
+ request()
574
+ } catch (error: ScopedNetworkError.Unavailable) {
575
+ if (released()) throw error
576
+ settle()
577
+ if (released()) throw error
578
+ request()
579
+ }
580
+
581
+ /**
582
+ * dnsmasq (DHCP/DNS) on the hotspot, then the glasses' local HTTP servers. Any answer —
583
+ * accept or refuse — proves the path; only silence fails it.
584
+ */
585
+ private val GATEWAY_PROBE_PORTS = intArrayOf(53, 8089, 80)
586
+ private const val GATEWAY_PROBE_TIMEOUT_MS = 2_000
587
+
588
+ /**
589
+ * How long the address is given to appear in the kernel table after the callbacks agree.
590
+ * Generous because failing here aborts the call, and the observed lag is sub-second.
591
+ */
592
+ private const val READINESS_WAIT_MS = 5_000L
593
+ private const val READINESS_POLL_MS = 150L
594
+
595
+ /** dnsmasq on the hotspot. Nothing is expected back; only the send is being observed. */
596
+ private const val UDP_PROBE_PORT = 53
597
+ }
598
+ }