fix: centralize and strictly enforce connection limits (#618)

This commit is contained in:
callebtc
2026-01-15 16:00:48 +07:00
committed by GitHub
parent 83fbcca557
commit c64ea0a021
4 changed files with 103 additions and 131 deletions
@@ -381,8 +381,13 @@ class BluetoothGattClientManager(
return
}
if (connectionTracker.isConnectionLimitReached()) {
Log.d(TAG, "Connection limit reached (${powerManager.getMaxConnections()})")
// Check if connection limit is reached
val dbg = try { com.bitchat.android.ui.debug.DebugSettingsManager.getInstance() } catch (_: Exception) { null }
val maxOverall = dbg?.maxConnectionsOverall?.value ?: powerManager.getMaxConnections()
val maxClient = dbg?.maxClientConnections?.value ?: maxOverall
if (!connectionTracker.canConnectAsClient(maxOverall, maxClient)) {
Log.d(TAG, "Client connection limit reached (overall: $maxOverall, client: $maxClient)")
return
}