@mentra/glasses-media 3.3.0-dev.382 → 3.3.0-dev.391

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.
@@ -447,13 +447,6 @@ class InternetHold(private val context: Context) {
447
447
  private fun cellularIsValidated(manager: ConnectivityManager): Boolean =
448
448
  findValidatedCellular(manager) != null
449
449
 
450
- private fun findValidatedCellular(manager: ConnectivityManager): Network? =
451
- manager.allNetworks.firstOrNull { network ->
452
- val capabilities = manager.getNetworkCapabilities(network) ?: return@firstOrNull false
453
- capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) &&
454
- isValidatedInternet(capabilities)
455
- }
456
-
457
450
  private fun connectivityManager(): ConnectivityManager? =
458
451
  context.applicationContext.getSystemService(ConnectivityManager::class.java)
459
452
 
@@ -466,6 +459,14 @@ class InternetHold(private val context: Context) {
466
459
 
467
460
  private const val DEFAULT_POLL_MS = 200L
468
461
 
462
+ /** Exclude validated carrier IMS/DUN networks that do not provide app internet. */
463
+ internal fun findValidatedCellular(manager: ConnectivityManager): Network? =
464
+ manager.allNetworks.firstOrNull { network ->
465
+ val capabilities = manager.getNetworkCapabilities(network) ?: return@firstOrNull false
466
+ capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) &&
467
+ isValidatedInternet(capabilities)
468
+ }
469
+
469
470
  fun isValidatedInternet(capabilities: NetworkCapabilities): Boolean =
470
471
  capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
471
472
  capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
@@ -2,9 +2,10 @@ package com.mentra.glassesmedia.publisher
2
2
 
3
3
  import android.content.Context
4
4
  import android.net.ConnectivityManager
5
- import android.net.NetworkCapabilities
6
5
  import android.os.Handler
7
6
  import android.os.HandlerThread
7
+ import com.mentra.glassesmedia.network.InternetHold
8
+ import com.mentra.glassesmedia.trace.SoftApTrace
8
9
  import com.mentra.glassesmedia.source.I420Planes
9
10
  import java.io.IOException
10
11
  import java.util.concurrent.CountDownLatch
@@ -65,12 +66,9 @@ class PhoneWhipPublisher(
65
66
  val url = endpoint.toHttpUrl()
66
67
  require(url.isHttps) { "Managed WHIP requires HTTPS" }
67
68
  val manager = context.getSystemService(ConnectivityManager::class.java)
68
- val internet = manager.allNetworks.firstOrNull { network ->
69
- manager.getNetworkCapabilities(network)?.let {
70
- it.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) &&
71
- it.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
72
- } == true
73
- } ?: error("Phone mobile data is unavailable")
69
+ val internet = InternetHold.findValidatedCellular(manager)
70
+ ?: error("Phone mobile data is unavailable")
71
+ SoftApTrace.stage("whip_uplink_network", "network" to internet)
74
72
  client = OkHttpClient.Builder().socketFactory(internet.socketFactory)
75
73
  .dns(object : okhttp3.Dns { override fun lookup(hostname: String) = internet.getAllByName(hostname).toList() })
76
74
  .callTimeout(20, TimeUnit.SECONDS).followRedirects(false).build()
@@ -167,7 +165,12 @@ class PhoneWhipPublisher(
167
165
  val request = Request.Builder().url(endpoint)
168
166
  .post(pc.localDescription.description.toRequestBody("application/sdp".toMediaType())).build()
169
167
  http.newCall(request).enqueue(object : Callback {
170
- override fun onFailure(call: Call, error: IOException) { queue.post { fail("WHIP signaling failed") } }
168
+ override fun onFailure(call: Call, error: IOException) {
169
+ // Exception messages can contain the credential-bearing publish URL. Record types only.
170
+ SoftApTrace.failure("whip_uplink_signaling", "error" to error.javaClass.simpleName,
171
+ "cause" to error.cause?.javaClass?.simpleName)
172
+ queue.post { fail("WHIP signaling failed (${error.javaClass.simpleName})") }
173
+ }
171
174
  override fun onResponse(call: Call, response: Response) {
172
175
  response.use {
173
176
  val location = response.header("Location")?.let { request.url.resolve(it) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/glasses-media",
3
- "version": "3.3.0-dev.382",
3
+ "version": "3.3.0-dev.391",
4
4
  "description": "Shared native glasses media receivers and local network transport",
5
5
  "license": "MIT",
6
6
  "author": "Mentra Community",