fix(fdroid): prevent NotImplementedError crash on firmware release fetch (#5197)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: garthvh <1795163+garthvh@users.noreply.github.com>
This commit is contained in:
James Rich
2026-04-20 20:02:07 -05:00
committed by GitHub
parent 14e8ab4e2b
commit a1bdd09d4d

View File

@@ -25,12 +25,18 @@ import org.meshtastic.core.network.service.ApiService
@Module
class FDroidNetworkModule {
/**
* F-Droid builds intentionally avoid network calls to the Meshtastic API.
*
* We throw [UnsupportedOperationException] (an [Exception], not an [Error]) so that `safeCatching {}` in the
* repositories captures the failure and falls back to the bundled JSON assets instead of crashing the app.
*/
@Single
fun provideApiService(): ApiService = object : ApiService {
override suspend fun getDeviceHardware(): List<NetworkDeviceHardware> =
throw NotImplementedError("API calls to getDeviceHardware are not supported on Fdroid builds.")
throw UnsupportedOperationException("getDeviceHardware is not supported on F-Droid builds.")
override suspend fun getFirmwareReleases(): NetworkFirmwareReleases =
throw NotImplementedError("API calls to getFirmwareReleases are not supported on Fdroid builds.")
throw UnsupportedOperationException("getFirmwareReleases is not supported on F-Droid builds.")
}
}