diff --git a/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt b/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt index f40c733d1..c93978051 100644 --- a/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt +++ b/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt @@ -26,6 +26,7 @@ import com.geeksville.mesh.BuildConfig import com.geeksville.mesh.CoroutineDispatchers import com.geeksville.mesh.MeshProtos import com.geeksville.mesh.android.BinaryLogFile +import com.geeksville.mesh.android.BuildUtils import com.geeksville.mesh.android.GeeksvilleApplication import com.geeksville.mesh.android.Logging import com.geeksville.mesh.concurrent.handledLaunch @@ -143,6 +144,14 @@ class RadioInterfaceService @Inject constructor( return BuildConfig.DEBUG || (context as GeeksvilleApplication).isInTestLab } + /** + * Determines whether to default to mock interface for device address. + * This keeps the decision logic separate and easy to extend. + */ + private fun shouldDefaultToMockInterface(): Boolean { + return BuildUtils.isEmulator + } + /** Return the device we are configured to use, or null for none * device address strings are of the form: * @@ -156,7 +165,7 @@ class RadioInterfaceService @Inject constructor( var address = prefs.getString(DEVADDR_KEY, null) // If we are running on the emulator we default to the mock interface, so we can have some data to show to the user - if (address == null && isMockInterface()) { + if (address == null && shouldDefaultToMockInterface()) { address = mockInterfaceAddress }