chore: fix regressions in the release (#4398)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-02-01 17:18:06 -06:00 committed by GitHub
parent 6eb42cc180
commit 221e774471
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 71 additions and 32 deletions

View file

@ -113,13 +113,18 @@ constructor(
private fun fromRadioPacketFlow(): Flow<ByteArray> = channelFlow {
while (isActive) {
// Use safe call and Elvis operator for cleaner loop termination if read fails or returns empty
val packet =
fromRadioCharacteristic?.read()?.takeIf { it.isNotEmpty() }
?: run {
Logger.d { "[$address] fromRadio queue drain complete (read empty/null)" }
break
}
try {
fromRadioCharacteristic?.read()?.takeIf { it.isNotEmpty() }
} catch (e: Exception) {
Logger.w(e) { "[$address] Error reading fromRadioCharacteristic (likely disconnected)" }
null
}
if (packet == null) {
Logger.d { "[$address] fromRadio queue drain complete or error reading characteristic" }
break
}
send(packet)
}
}
@ -221,6 +226,11 @@ constructor(
.onEach { state ->
Logger.i { "[$address] BLE connection state changed to $state" }
if (state is ConnectionState.Disconnected) {
toRadioCharacteristic = null
fromNumCharacteristic = null
fromRadioCharacteristic = null
logRadioCharacteristic = null
val uptime =
if (connectionStartTime > 0) {
System.currentTimeMillis() - connectionStartTime

View file

@ -140,9 +140,7 @@ class MeshService : Service() {
SERVICE_NOTIFY_ID,
notification,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
var types =
ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE or
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
var types = ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
if (hasLocationPermission()) {
types = types or ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION
}