fix: Refactor BLE exceptions and handle ServiceAction exceptions (#2294)

This commit is contained in:
James Rich 2025-06-29 12:45:09 +00:00 committed by GitHub
parent a0f614808c
commit deb36b6647
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 10 deletions

View file

@ -17,10 +17,10 @@
package com.geeksville.mesh.service
import java.io.IOException
import java.util.*
import android.os.RemoteException
import java.util.UUID
open class BLEException(msg: String) : IOException(msg)
open class BLEException(msg: String) : RemoteException(msg)
open class BLECharacteristicNotFoundException(uuid: UUID) :
BLEException("Can't get characteristic $uuid")

View file

@ -81,6 +81,7 @@ import com.geeksville.mesh.repository.radio.RadioServiceConnectionState
import com.geeksville.mesh.telemetry
import com.geeksville.mesh.user
import com.geeksville.mesh.util.anonymize
import com.geeksville.mesh.util.ignoreException
import com.geeksville.mesh.util.toOneLineString
import com.geeksville.mesh.util.toPIIString
import com.geeksville.mesh.util.toRemoteExceptions
@ -1932,12 +1933,14 @@ class MeshService : Service(), Logging {
}
private fun onServiceAction(action: ServiceAction) {
when (action) {
is ServiceAction.GetDeviceMetadata -> getDeviceMetadata(action.destNum)
is ServiceAction.Favorite -> favoriteNode(action.node)
is ServiceAction.Ignore -> ignoreNode(action.node)
is ServiceAction.Reaction -> sendReaction(action)
is ServiceAction.AddSharedContact -> importContact(action.contact)
ignoreException {
when (action) {
is ServiceAction.GetDeviceMetadata -> getDeviceMetadata(action.destNum)
is ServiceAction.Favorite -> favoriteNode(action.node)
is ServiceAction.Ignore -> ignoreNode(action.node)
is ServiceAction.Reaction -> sendReaction(action)
is ServiceAction.AddSharedContact -> importContact(action.contact)
}
}
}

View file

@ -17,5 +17,7 @@
package com.geeksville.mesh.service
import android.os.RemoteException
open class RadioNotConnectedException(message: String = "Not connected to radio") :
BLEException(message)
RemoteException(message)