fix(regression): replace lost ringtone and canned message handling (#2672)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-08-09 11:55:42 -05:00 committed by GitHub
parent a83724a5a8
commit e471636dd1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 17 deletions

View file

@ -103,7 +103,6 @@ import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
import java.util.Random
import java.util.UUID
@ -233,7 +232,7 @@ class MeshService :
private val notificationSummary: String
get() =
when (connectionRouter.connectionState.value) {
ConnectionState.CONNECTED -> getString(R.string.connected_count, numOnlineNodes)
ConnectionState.CONNECTED -> getString(R.string.connected_count, numOnlineNodes.toString())
ConnectionState.DISCONNECTED -> getString(R.string.disconnected)
ConnectionState.DEVICE_SLEEP -> getString(R.string.device_sleeping)
ConnectionState.CONNECTING -> getString(R.string.connecting_to_device)
@ -436,7 +435,7 @@ class MeshService :
* switching to a new device connection to prevent state from a previous session from affecting the new one. It
* ensures a clean slate for node information, configurations, pending operations, and cached data.
*/
private fun resetState() = serviceScope.launch {
private fun resetState() = serviceScope.handledLaunch {
debug("Discarding NodeDB and resetting all service state for new device connection")
clearDatabases()
// Core Node and Config data
@ -465,6 +464,10 @@ class MeshService :
batteryPercentCooldowns.clear()
radioConfigRepository.clearChannelSet()
radioConfigRepository.clearLocalConfig()
radioConfigRepository.clearLocalModuleConfig()
info("MeshService state has been reset for a new device session.")
}
@ -1550,11 +1553,6 @@ class MeshService :
),
)
rawMyNodeInfo = myInfo
serviceScope.handledLaunch {
radioConfigRepository.clearChannelSet()
radioConfigRepository.clearLocalConfig()
radioConfigRepository.clearLocalModuleConfig()
}
}
private fun handleDeviceUiConfig(deviceuiConfig: DeviceUIProtos.DeviceUIConfig) {
@ -1967,20 +1965,28 @@ class MeshService :
)
}
override fun setRingtone(destNum: Int, ringtone: String?) {
TODO("Not yet implemented")
override fun setRingtone(destNum: Int, ringtone: String) = toRemoteExceptions {
sendToRadio(newMeshPacketTo(destNum).buildAdminPacket { setRingtoneMessage = ringtone })
}
override fun getRingtone(requestId: Int, destNum: Int) {
TODO("Not yet implemented")
override fun getRingtone(id: Int, destNum: Int) = toRemoteExceptions {
sendToRadio(
newMeshPacketTo(destNum).buildAdminPacket(id = id, wantResponse = true) {
getRingtoneRequest = true
},
)
}
override fun setCannedMessages(destNum: Int, messages: String?) {
TODO("Not yet implemented")
override fun setCannedMessages(destNum: Int, messages: String) = toRemoteExceptions {
sendToRadio(newMeshPacketTo(destNum).buildAdminPacket { setCannedMessageModuleMessages = messages })
}
override fun getCannedMessages(requestId: Int, destNum: Int) {
TODO("Not yet implemented")
override fun getCannedMessages(id: Int, destNum: Int) = toRemoteExceptions {
sendToRadio(
newMeshPacketTo(destNum).buildAdminPacket(id = id, wantResponse = true) {
getCannedMessageModuleMessagesRequest = true
},
)
}
override fun setChannel(payload: ByteArray) = toRemoteExceptions {