mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
chore: fix regressions in the release (#4398)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
6eb42cc180
commit
221e774471
9 changed files with 71 additions and 32 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue