mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-05-12 16:55:02 -04:00
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:
@@ -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.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user