From 807db83f53491298c4edfeb99294b3d4f3d1c84c Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Tue, 17 Mar 2026 14:06:01 -0500 Subject: [PATCH] feat: service extraction (#4828) --- app/src/main/AndroidManifest.xml | 10 +- .../org/meshtastic/app/MeshServiceClient.kt | 4 +- .../org/meshtastic/app/MeshUtilApplication.kt | 2 +- .../org/meshtastic/app/di/AppKoinModule.kt | 4 +- .../domain/worker/WorkManagerMessageQueue.kt | 1 + .../main/kotlin/org/meshtastic/app/ui/Main.kt | 2 +- .../extract_services_20260317/index.md | 5 + .../extract_services_20260317/metadata.json | 8 ++ .../archive/extract_services_20260317/plan.md | 44 +++++++ .../archive/extract_services_20260317/spec.md | 32 +++++ conductor/product.md | 2 +- conductor/tech-stack.md | 3 + conductor/tracks.md | 2 - .../core/data/manager/CommandSenderImpl.kt | 6 +- .../meshtastic/core/model/DeviceVersion.kt | 5 + core/network/build.gradle.kts | 3 + .../radio/AndroidRadioInterfaceService.kt | 9 +- .../core/network}/radio/BleRadioInterface.kt | 4 +- .../radio/BleRadioInterfaceFactory.kt | 2 +- .../network}/radio/BleRadioInterfaceSpec.kt | 2 +- .../core/network}/radio/InterfaceFactory.kt | 2 +- .../core/network}/radio/SerialInterface.kt | 8 +- .../network}/radio/SerialInterfaceFactory.kt | 4 +- .../network}/radio/SerialInterfaceSpec.kt | 4 +- .../core/network}/radio/TCPInterface.kt | 2 +- .../network}/radio/TCPInterfaceFactory.kt | 2 +- .../core/network}/radio/TCPInterfaceSpec.kt | 2 +- .../repository/ConnectivityManager.kt | 2 +- .../network}/repository/NetworkRepository.kt | 2 +- .../core/network}/repository/NsdManager.kt | 4 +- .../network}/repository/ProbeTableProvider.kt | 4 +- .../network}/repository/SerialConnection.kt | 2 +- .../repository/SerialConnectionImpl.kt | 4 +- .../repository/SerialConnectionListener.kt | 2 +- .../repository/UsbBroadcastReceiver.kt | 2 +- .../core/network}/repository/UsbManager.kt | 2 +- .../core/network}/repository/UsbRepository.kt | 2 +- .../network/radio/BleRadioInterfaceTest.kt | 2 +- .../network}/radio/InterfaceFactorySpi.kt | 2 +- .../core/network}/radio/InterfaceSpec.kt | 2 +- .../core/network}/radio/MockInterface.kt | 2 +- .../network}/radio/MockInterfaceFactory.kt | 2 +- .../core/network}/radio/MockInterfaceSpec.kt | 2 +- .../core/network}/radio/NopInterface.kt | 2 +- .../network}/radio/NopInterfaceFactory.kt | 2 +- .../core/network}/radio/NopInterfaceSpec.kt | 2 +- .../core/network}/radio/StreamInterface.kt | 2 +- .../network}/repository/NetworkConstants.kt | 2 +- .../src/androidMain}/res/raw/alert.mp3 | Bin core/service/build.gradle.kts | 1 + .../core}/service/AndroidMeshWorkerManager.kt | 4 +- .../service/AndroidRadioControllerImpl.kt | 2 +- .../core}/service/BootCompleteReceiver.kt | 2 +- .../org/meshtastic/core}/service/Constants.kt | 2 +- .../core}/service/MarkAsReadReceiver.kt | 2 +- .../meshtastic/core}/service/MeshService.kt | 42 ++----- .../service/MeshServiceNotificationsImpl.kt | 26 +++-- .../core}/service/MeshServiceStarter.kt | 7 +- .../core}/service/ReactionReceiver.kt | 2 +- .../meshtastic/core}/service/ReplyReceiver.kt | 2 +- .../core}/service/ServiceBroadcasts.kt | 2 +- .../service}/worker/MeshLogCleanupWorker.kt | 2 +- .../core/service}/worker/SendMessageWorker.kt | 2 +- .../service}/worker/ServiceKeepAliveWorker.kt | 9 +- .../core/service/MeshServiceOrchestrator.kt | 2 + .../service/MeshServiceOrchestratorTest.kt | 77 ++++++++++++ .../kotlin/org/meshtastic/desktop/Main.kt | 4 +- .../desktop/di/DesktopKoinModule.kt | 14 --- .../radio/DesktopMeshServiceController.kt | 110 ------------------ docs/kmp-status.md | 14 ++- docs/roadmap.md | 3 +- feature/connections/build.gradle.kts | 1 + .../connections/AndroidScannerViewModel.kt | 2 +- .../AndroidGetDiscoveredDevicesUseCase.kt | 6 +- .../ui/components/NetworkDevices.kt | 2 +- .../meshserviceexample/MainActivity.kt | 2 +- 76 files changed, 309 insertions(+), 257 deletions(-) create mode 100644 conductor/archive/extract_services_20260317/index.md create mode 100644 conductor/archive/extract_services_20260317/metadata.json create mode 100644 conductor/archive/extract_services_20260317/plan.md create mode 100644 conductor/archive/extract_services_20260317/spec.md rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/AndroidRadioInterfaceService.kt (97%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/BleRadioInterface.kt (99%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/BleRadioInterfaceFactory.kt (97%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/BleRadioInterfaceSpec.kt (97%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/InterfaceFactory.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/SerialInterface.kt (95%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/SerialInterfaceFactory.kt (90%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/SerialInterfaceSpec.kt (94%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/TCPInterface.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/TCPInterfaceFactory.kt (96%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/radio/TCPInterfaceSpec.kt (96%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/ConnectivityManager.kt (97%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/NetworkRepository.kt (98%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/NsdManager.kt (98%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/ProbeTableProvider.kt (94%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/SerialConnection.kt (95%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/SerialConnectionImpl.kt (98%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/SerialConnectionListener.kt (95%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/UsbBroadcastReceiver.kt (97%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/UsbManager.kt (97%) rename {feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections => core/network/src/androidMain/kotlin/org/meshtastic/core/network}/repository/UsbRepository.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/InterfaceFactorySpi.kt (96%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/InterfaceSpec.kt (96%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/MockInterface.kt (99%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/MockInterfaceFactory.kt (95%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/MockInterfaceSpec.kt (96%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/NopInterface.kt (95%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/NopInterfaceFactory.kt (95%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/NopInterfaceSpec.kt (96%) rename {app/src/main/kotlin/org/meshtastic/app/repository => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/radio/StreamInterface.kt (98%) rename {feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections => core/network/src/commonMain/kotlin/org/meshtastic/core/network}/repository/NetworkConstants.kt (93%) rename {app/src/main => core/resources/src/androidMain}/res/raw/alert.mp3 (100%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/AndroidMeshWorkerManager.kt (93%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/BootCompleteReceiver.kt (97%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/Constants.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/MarkAsReadReceiver.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/MeshService.kt (90%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/MeshServiceNotificationsImpl.kt (97%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/MeshServiceStarter.kt (92%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/ReactionReceiver.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/ReplyReceiver.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core}/service/ServiceBroadcasts.kt (99%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core/service}/worker/MeshLogCleanupWorker.kt (98%) rename {app/src/main/kotlin/org/meshtastic/app/messaging/domain => core/service/src/androidMain/kotlin/org/meshtastic/core/service}/worker/SendMessageWorker.kt (97%) rename {app/src/main/kotlin/org/meshtastic/app => core/service/src/androidMain/kotlin/org/meshtastic/core/service}/worker/ServiceKeepAliveWorker.kt (93%) create mode 100644 core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt delete mode 100644 desktop/src/main/kotlin/org/meshtastic/desktop/radio/DesktopMeshServiceController.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a19b6ff3c..7828802d9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -152,7 +152,7 @@ @@ -228,7 +228,7 @@ android:resource="@xml/device_filter" /> - @@ -252,9 +252,9 @@ android:path="com.geeksville.mesh" /> --> - - - + + + 80%) for all extracted and refactored code [9cff9bc] +- [x] Task: Remove any lingering unused dependencies or dead code in `app` [e39d2e2] +- [x] Task: Conductor - User Manual Verification 'Verification & Cleanup' (Protocol in workflow.md) + +## Phase: Review Fixes +- [x] Task: Apply review suggestions [1ae9fb6] \ No newline at end of file diff --git a/conductor/archive/extract_services_20260317/spec.md b/conductor/archive/extract_services_20260317/spec.md new file mode 100644 index 000000000..32d1eb803 --- /dev/null +++ b/conductor/archive/extract_services_20260317/spec.md @@ -0,0 +1,32 @@ +# Specification: Extract service/worker/radio files from `app` + +## Overview +This track aims to decouple the main `app` module by extracting Android-specific service, WorkManager worker, and radio connection files into `core:service` and `core:network` modules. The goal is to maximize code reuse across Kotlin Multiplatform (KMP) targets, clarify class responsibilities, and improve unit testability by isolating the network and service layers. + +## Goals +- **Decouple `app`:** Remove Android-specific service dependencies from the main app module. +- **KMP Preparation:** Migrate as much logic as possible into `commonMain` for reuse across platforms. +- **Desktop Integration:** If logic is successfully abstracted into `commonMain`, integrate and use it within the `desktop` target to ensure reusability. +- **Testability:** Isolate service and network layers to facilitate better unit testing. +- **Simplification:** Refactor logic during the move to clarify and simplify responsibilities. + +## Functional Requirements +- Identify all service, worker, and radio-related classes currently residing in the `app` module. +- Move Android-specific implementations (e.g., `Service`, `Worker`) to `core:service/androidMain` and `core:network/androidMain`. +- Extract platform-agnostic business logic and interfaces into `commonMain` within those core modules. +- Refactor existing logic where necessary to establish a clear delineation of responsibility. +- Update all dependency injections (Koin modules) and imports across the project to reflect the new locations. +- Attempt to wire up the newly abstracted shared logic within the `desktop` module if applicable. + +## Non-Functional Requirements +- **Architecture Compliance:** Changes must adhere to the MVI / Unidirectional Data Flow and KMP structures defined in `tech-stack.md`. +- **Performance:** Refactoring should not negatively impact app startup time or background processing efficiency. +- **Code Coverage:** Maintain or improve overall test coverage for the extracted components (>80% target). + +## Acceptance Criteria +- [ ] No service, worker, or radio connection classes remain in the `app` module. +- [ ] Extracted Android-specific classes compile successfully in `core:service/androidMain` and `core:network/androidMain`. +- [ ] Shared business logic compiles successfully in `core:service/commonMain` and `core:network/commonMain`. +- [ ] If logic is abstracted for reuse, it is integrated and utilized in the `desktop` target where applicable. +- [ ] The app compiles, installs, and runs without regressions in background processing or radio connectivity. +- [ ] Unit tests for the moved and refactored classes pass. \ No newline at end of file diff --git a/conductor/product.md b/conductor/product.md index 53a1d4dc2..ccbd0a648 100644 --- a/conductor/product.md +++ b/conductor/product.md @@ -20,6 +20,6 @@ Meshtastic-Android is a Kotlin Multiplatform (KMP) application designed to facil - Device configuration and firmware updates ## Key Architecture Goals -- Provide a robust, shared KMP core (`core:model`, `core:ble`, `core:repository`, `core:domain`, `core:data`, `core:network`) to support multiple platforms (Android, Desktop, iOS) +- Provide a robust, shared KMP core (`core:model`, `core:ble`, `core:repository`, `core:domain`, `core:data`, `core:network`, `core:service`) to support multiple platforms (Android, Desktop, iOS) - Ensure offline-first functionality and resilient data persistence (Room KMP) - Decouple UI logic into shared components (`core:ui`, `feature:*`) using Compose Multiplatform \ No newline at end of file diff --git a/conductor/tech-stack.md b/conductor/tech-stack.md index a9b6331f8..c6ea7ebbd 100644 --- a/conductor/tech-stack.md +++ b/conductor/tech-stack.md @@ -7,6 +7,9 @@ - **Compose Multiplatform:** Shared UI layer for rendering on Android and Desktop. - **Jetpack Compose:** Used where platform-specific UI (like charts or permissions) is necessary on Android. +## Background & Services +- **Platform Services:** Core service orchestrations and background work are abstracted into `core:service` to maximize logic reuse across targets, using platform-specific implementations (e.g., WorkManager/Service on Android) only where necessary. + ## Architecture - **MVI / Unidirectional Data Flow:** Shared view models using the multiplatform `androidx.lifecycle.ViewModel`. - **JetBrains Navigation 3:** Multiplatform fork for state-based, compose-first navigation without relying on `NavController`. diff --git a/conductor/tracks.md b/conductor/tracks.md index 0b5c54e3d..22d3d6494 100644 --- a/conductor/tracks.md +++ b/conductor/tracks.md @@ -1,5 +1,3 @@ # Project Tracks This file tracks all major tracks for the project. Each track has its own detailed plan in its respective folder. - ---- diff --git a/core/data/src/commonMain/kotlin/org/meshtastic/core/data/manager/CommandSenderImpl.kt b/core/data/src/commonMain/kotlin/org/meshtastic/core/data/manager/CommandSenderImpl.kt index b296cef01..1e5f5eaeb 100644 --- a/core/data/src/commonMain/kotlin/org/meshtastic/core/data/manager/CommandSenderImpl.kt +++ b/core/data/src/commonMain/kotlin/org/meshtastic/core/data/manager/CommandSenderImpl.kt @@ -258,7 +258,7 @@ class CommandSenderImpl( wantAck = true, id = requestId, channel = nodeManager.nodeDBbyNodeNum[destNum]?.channel ?: 0, - decoded = Data(portnum = PortNum.TRACEROUTE_APP, want_response = true), + decoded = Data(portnum = PortNum.TRACEROUTE_APP, want_response = true, dest = destNum), ), ) } @@ -296,7 +296,7 @@ class CommandSenderImpl( to = destNum, id = requestId, channel = nodeManager.nodeDBbyNodeNum[destNum]?.channel ?: 0, - decoded = Data(portnum = portNum, payload = payloadBytes, want_response = true), + decoded = Data(portnum = portNum, payload = payloadBytes, want_response = true, dest = destNum), ), ) } @@ -349,7 +349,7 @@ class CommandSenderImpl( wantAck = true, id = requestId, channel = nodeManager.nodeDBbyNodeNum[destNum]?.channel ?: 0, - decoded = Data(portnum = PortNum.NEIGHBORINFO_APP, want_response = true), + decoded = Data(portnum = PortNum.NEIGHBORINFO_APP, want_response = true, dest = destNum), ), ) } diff --git a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DeviceVersion.kt b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DeviceVersion.kt index d72d7775f..4816e9eb3 100644 --- a/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DeviceVersion.kt +++ b/core/model/src/commonMain/kotlin/org/meshtastic/core/model/DeviceVersion.kt @@ -52,4 +52,9 @@ data class DeviceVersion(val asString: String) : Comparable { } override fun compareTo(other: DeviceVersion): Int = asInt.compareTo(other.asInt) + + companion object { + const val MIN_FW_VERSION = "2.5.14" + const val ABS_MIN_FW_VERSION = "2.3.15" + } } diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index 06ac5016b..4fd91682f 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -51,7 +51,10 @@ kotlin { val jvmMain by getting { dependencies { implementation(libs.ktor.client.java) } } androidMain.dependencies { + implementation(projects.core.ble) + implementation(projects.core.prefs) implementation(libs.org.eclipse.paho.client.mqttv3) + implementation(libs.usb.serial.android) implementation(libs.coil.network.okhttp) implementation(libs.coil.svg) implementation(libs.ktor.client.okhttp) diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/AndroidRadioInterfaceService.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/AndroidRadioInterfaceService.kt similarity index 97% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/AndroidRadioInterfaceService.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/AndroidRadioInterfaceService.kt index 88d739fe0..c90ae08d0 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/AndroidRadioInterfaceService.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/AndroidRadioInterfaceService.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import android.app.Application import android.provider.Settings @@ -37,8 +37,8 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch import org.koin.core.annotation.Named import org.koin.core.annotation.Single -import org.meshtastic.app.BuildConfig import org.meshtastic.core.ble.BluetoothRepository +import org.meshtastic.core.common.BuildConfigProvider import org.meshtastic.core.common.util.BinaryLogFile import org.meshtastic.core.common.util.handledLaunch import org.meshtastic.core.common.util.ignoreException @@ -49,11 +49,11 @@ import org.meshtastic.core.model.ConnectionState import org.meshtastic.core.model.InterfaceId import org.meshtastic.core.model.MeshActivity import org.meshtastic.core.model.util.anonymize +import org.meshtastic.core.network.repository.NetworkRepository import org.meshtastic.core.repository.PlatformAnalytics import org.meshtastic.core.repository.RadioInterfaceService import org.meshtastic.core.repository.RadioPrefs import org.meshtastic.core.repository.RadioTransport -import org.meshtastic.feature.connections.repository.NetworkRepository import org.meshtastic.proto.Heartbeat import org.meshtastic.proto.ToRadio @@ -73,6 +73,7 @@ class AndroidRadioInterfaceService( private val dispatchers: CoroutineDispatchers, private val bluetoothRepository: BluetoothRepository, private val networkRepository: NetworkRepository, + private val buildConfigProvider: BuildConfigProvider, @Named("ProcessLifecycle") private val processLifecycle: Lifecycle, private val radioPrefs: RadioPrefs, private val interfaceFactory: Lazy, @@ -187,7 +188,7 @@ class AndroidRadioInterfaceService( interfaceFactory.value.toInterfaceAddress(interfaceId, rest) override fun isMockInterface(): Boolean = - BuildConfig.DEBUG || Settings.System.getString(context.contentResolver, "firebase.test.lab") == "true" + buildConfigProvider.isDebug || Settings.System.getString(context.contentResolver, "firebase.test.lab") == "true" override fun getDeviceAddress(): String? { // If the user has unpaired our device, treat things as if we don't have one diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterface.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterface.kt similarity index 99% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterface.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterface.kt index b37fa1c53..af4b9f320 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterface.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterface.kt @@ -14,7 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +@file:Suppress("TooManyFunctions", "TooGenericExceptionCaught") + +package org.meshtastic.core.network.radio import android.annotation.SuppressLint import co.touchlab.kermit.Logger diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterfaceFactory.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceFactory.kt similarity index 97% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterfaceFactory.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceFactory.kt index 341fe1afe..26956824c 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterfaceFactory.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceFactory.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.ble.BleConnectionFactory diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterfaceSpec.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceSpec.kt similarity index 97% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterfaceSpec.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceSpec.kt index aaa39b9bd..461ac4b65 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/BleRadioInterfaceSpec.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceSpec.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.repository.RadioInterfaceService diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceFactory.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/InterfaceFactory.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceFactory.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/InterfaceFactory.kt index 91f16e0d9..47a1365d2 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceFactory.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/InterfaceFactory.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.model.InterfaceId diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterface.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterface.kt similarity index 95% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterface.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterface.kt index c1f509499..2e97cff75 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterface.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterface.kt @@ -14,14 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import co.touchlab.kermit.Logger import org.meshtastic.core.common.util.nowMillis +import org.meshtastic.core.network.repository.SerialConnection +import org.meshtastic.core.network.repository.SerialConnectionListener +import org.meshtastic.core.network.repository.UsbRepository import org.meshtastic.core.repository.RadioInterfaceService -import org.meshtastic.feature.connections.repository.SerialConnection -import org.meshtastic.feature.connections.repository.SerialConnectionListener -import org.meshtastic.feature.connections.repository.UsbRepository import java.util.concurrent.atomic.AtomicReference /** An interface that assumes we are talking to a meshtastic device via USB serial */ diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterfaceFactory.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterfaceFactory.kt similarity index 90% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterfaceFactory.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterfaceFactory.kt index c7a123cc3..f8c53313b 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterfaceFactory.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterfaceFactory.kt @@ -14,11 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single +import org.meshtastic.core.network.repository.UsbRepository import org.meshtastic.core.repository.RadioInterfaceService -import org.meshtastic.feature.connections.repository.UsbRepository /** Factory for creating `SerialInterface` instances. */ @Single diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterfaceSpec.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterfaceSpec.kt similarity index 94% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterfaceSpec.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterfaceSpec.kt index 54a44485b..8597fd060 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/SerialInterfaceSpec.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/SerialInterfaceSpec.kt @@ -14,13 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import android.hardware.usb.UsbManager import com.hoho.android.usbserial.driver.UsbSerialDriver import org.koin.core.annotation.Single +import org.meshtastic.core.network.repository.UsbRepository import org.meshtastic.core.repository.RadioInterfaceService -import org.meshtastic.feature.connections.repository.UsbRepository /** Serial/USB interface backend implementation. */ @Single diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterface.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterface.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterface.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterface.kt index 8217302ce..adab96d4d 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterface.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterface.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import co.touchlab.kermit.Logger import org.meshtastic.core.common.util.handledLaunch diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterfaceFactory.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterfaceFactory.kt similarity index 96% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterfaceFactory.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterfaceFactory.kt index b11916940..003294448 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterfaceFactory.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterfaceFactory.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.di.CoroutineDispatchers diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterfaceSpec.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterfaceSpec.kt similarity index 96% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterfaceSpec.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterfaceSpec.kt index b48ee826c..2539bc13c 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/TCPInterfaceSpec.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/TCPInterfaceSpec.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.repository.RadioInterfaceService diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/ConnectivityManager.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ConnectivityManager.kt similarity index 97% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/ConnectivityManager.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ConnectivityManager.kt index e245f2419..559b873d3 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/ConnectivityManager.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ConnectivityManager.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository import android.net.ConnectivityManager import android.net.Network diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/NetworkRepository.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NetworkRepository.kt similarity index 98% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/NetworkRepository.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NetworkRepository.kt index f44f7f173..2e0f797ef 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/NetworkRepository.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NetworkRepository.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository import android.net.ConnectivityManager import android.net.nsd.NsdManager diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/NsdManager.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NsdManager.kt similarity index 98% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/NsdManager.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NsdManager.kt index 6e7bf2eec..ce272bf59 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/NsdManager.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NsdManager.kt @@ -14,7 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +@file:Suppress("SwallowedException") + +package org.meshtastic.core.network.repository import android.annotation.SuppressLint import android.net.nsd.NsdManager diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/ProbeTableProvider.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ProbeTableProvider.kt similarity index 94% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/ProbeTableProvider.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ProbeTableProvider.kt index 7d091f2ff..15558118e 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/ProbeTableProvider.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ProbeTableProvider.kt @@ -14,7 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +@file:Suppress("MagicNumber") + +package org.meshtastic.core.network.repository import com.hoho.android.usbserial.driver.CdcAcmSerialDriver import com.hoho.android.usbserial.driver.ProbeTable diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnection.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnection.kt similarity index 95% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnection.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnection.kt index cb9dc679b..2ec10b7f1 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnection.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnection.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository /** USB serial connection. */ interface SerialConnection : AutoCloseable { diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnectionImpl.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionImpl.kt similarity index 98% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnectionImpl.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionImpl.kt index a06d5492d..b2ccf6545 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnectionImpl.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionImpl.kt @@ -14,7 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +@file:Suppress("MagicNumber") + +package org.meshtastic.core.network.repository import android.hardware.usb.UsbManager import co.touchlab.kermit.Logger diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnectionListener.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionListener.kt similarity index 95% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnectionListener.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionListener.kt index 4dbc2b90d..b56236f5b 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/SerialConnectionListener.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionListener.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository /** Callbacks indicating state changes in the USB serial connection. */ interface SerialConnectionListener { diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbBroadcastReceiver.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbBroadcastReceiver.kt similarity index 97% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbBroadcastReceiver.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbBroadcastReceiver.kt index d472e3bf8..79d09639a 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbBroadcastReceiver.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbBroadcastReceiver.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository import android.content.BroadcastReceiver import android.content.Context diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbManager.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbManager.kt similarity index 97% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbManager.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbManager.kt index 66b3bb515..b36c5c3e9 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbManager.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbManager.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository import android.content.BroadcastReceiver import android.content.Context diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbRepository.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbRepository.kt similarity index 98% rename from feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbRepository.kt rename to core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbRepository.kt index e73871336..b4773dff3 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/repository/UsbRepository.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/UsbRepository.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository import android.app.Application import android.hardware.usb.UsbDevice diff --git a/core/network/src/androidUnitTest/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceTest.kt b/core/network/src/androidUnitTest/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceTest.kt index 706a47340..457a3a9d9 100644 --- a/core/network/src/androidUnitTest/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceTest.kt +++ b/core/network/src/androidUnitTest/kotlin/org/meshtastic/core/network/radio/BleRadioInterfaceTest.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import io.mockk.coEvery import io.mockk.every diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceFactorySpi.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/InterfaceFactorySpi.kt similarity index 96% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceFactorySpi.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/InterfaceFactorySpi.kt index b9856af82..5354f5500 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceFactorySpi.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/InterfaceFactorySpi.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.meshtastic.core.repository.RadioTransport diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceSpec.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/InterfaceSpec.kt similarity index 96% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceSpec.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/InterfaceSpec.kt index 7ac3619da..aec9ec667 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/InterfaceSpec.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/InterfaceSpec.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.meshtastic.core.repository.RadioInterfaceService import org.meshtastic.core.repository.RadioTransport diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterface.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterface.kt similarity index 99% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterface.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterface.kt index 776729bba..8de3000af 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterface.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterface.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import co.touchlab.kermit.Logger import kotlinx.coroutines.delay diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterfaceFactory.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterfaceFactory.kt similarity index 95% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterfaceFactory.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterfaceFactory.kt index 5f8328d3a..492b5782c 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterfaceFactory.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterfaceFactory.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.repository.RadioInterfaceService diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterfaceSpec.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterfaceSpec.kt similarity index 96% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterfaceSpec.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterfaceSpec.kt index 13dcadd50..0f77cb5dc 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/MockInterfaceSpec.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/MockInterfaceSpec.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.repository.RadioInterfaceService diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterface.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterface.kt similarity index 95% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterface.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterface.kt index e9eed976a..27348635c 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterface.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterface.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.meshtastic.core.repository.RadioTransport diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterfaceFactory.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterfaceFactory.kt similarity index 95% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterfaceFactory.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterfaceFactory.kt index 56d58b846..5d9991e34 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterfaceFactory.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterfaceFactory.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterfaceSpec.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterfaceSpec.kt similarity index 96% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterfaceSpec.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterfaceSpec.kt index 149a2469a..df77578bf 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/NopInterfaceSpec.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/NopInterfaceSpec.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import org.koin.core.annotation.Single import org.meshtastic.core.repository.RadioInterfaceService diff --git a/app/src/main/kotlin/org/meshtastic/app/repository/radio/StreamInterface.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/StreamInterface.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/repository/radio/StreamInterface.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/StreamInterface.kt index 477bd50d2..7414def38 100644 --- a/app/src/main/kotlin/org/meshtastic/app/repository/radio/StreamInterface.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/radio/StreamInterface.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.repository.radio +package org.meshtastic.core.network.radio import co.touchlab.kermit.Logger import kotlinx.coroutines.launch diff --git a/feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/repository/NetworkConstants.kt b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/repository/NetworkConstants.kt similarity index 93% rename from feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/repository/NetworkConstants.kt rename to core/network/src/commonMain/kotlin/org/meshtastic/core/network/repository/NetworkConstants.kt index 8a7cab5b6..e35abf554 100644 --- a/feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/repository/NetworkConstants.kt +++ b/core/network/src/commonMain/kotlin/org/meshtastic/core/network/repository/NetworkConstants.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.feature.connections.repository +package org.meshtastic.core.network.repository object NetworkConstants { const val SERVICE_PORT = 4403 diff --git a/app/src/main/res/raw/alert.mp3 b/core/resources/src/androidMain/res/raw/alert.mp3 similarity index 100% rename from app/src/main/res/raw/alert.mp3 rename to core/resources/src/androidMain/res/raw/alert.mp3 diff --git a/core/service/build.gradle.kts b/core/service/build.gradle.kts index 89476bb13..0d0b11699 100644 --- a/core/service/build.gradle.kts +++ b/core/service/build.gradle.kts @@ -36,6 +36,7 @@ kotlin { implementation(projects.core.data) implementation(projects.core.database) implementation(projects.core.model) + implementation(projects.core.navigation) implementation(projects.core.prefs) implementation(projects.core.proto) diff --git a/app/src/main/kotlin/org/meshtastic/app/service/AndroidMeshWorkerManager.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidMeshWorkerManager.kt similarity index 93% rename from app/src/main/kotlin/org/meshtastic/app/service/AndroidMeshWorkerManager.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidMeshWorkerManager.kt index 25e88a9ff..32530dcf4 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/AndroidMeshWorkerManager.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidMeshWorkerManager.kt @@ -14,15 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import androidx.work.ExistingWorkPolicy import androidx.work.OneTimeWorkRequestBuilder import androidx.work.WorkManager import androidx.work.workDataOf import org.koin.core.annotation.Single -import org.meshtastic.app.messaging.domain.worker.SendMessageWorker import org.meshtastic.core.repository.MeshWorkerManager +import org.meshtastic.core.service.worker.SendMessageWorker @Single class AndroidMeshWorkerManager(private val workManager: WorkManager) : MeshWorkerManager { diff --git a/core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidRadioControllerImpl.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidRadioControllerImpl.kt index b6a1b7273..cd4b317bd 100644 --- a/core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidRadioControllerImpl.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/AndroidRadioControllerImpl.kt @@ -200,7 +200,7 @@ class AndroidRadioControllerImpl( // Ensure service is running/restarted to handle the new address val intent = android.content.Intent().apply { - setClassName("com.geeksville.mesh", "org.meshtastic.app.service.MeshService") + setClassName("com.geeksville.mesh", "org.meshtastic.core.service.MeshService") } context.startForegroundService(intent) } diff --git a/app/src/main/kotlin/org/meshtastic/app/service/BootCompleteReceiver.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/BootCompleteReceiver.kt similarity index 97% rename from app/src/main/kotlin/org/meshtastic/app/service/BootCompleteReceiver.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/BootCompleteReceiver.kt index 732be7b19..b01475b6d 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/BootCompleteReceiver.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/BootCompleteReceiver.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.content.BroadcastReceiver import android.content.Context diff --git a/app/src/main/kotlin/org/meshtastic/app/service/Constants.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/Constants.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/service/Constants.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/Constants.kt index af5fdbdcd..4e0b5e7b8 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/Constants.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/Constants.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import org.meshtastic.core.api.MeshtasticIntent diff --git a/app/src/main/kotlin/org/meshtastic/app/service/MarkAsReadReceiver.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MarkAsReadReceiver.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/service/MarkAsReadReceiver.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/MarkAsReadReceiver.kt index ebe68c74d..966569f4f 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/MarkAsReadReceiver.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MarkAsReadReceiver.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.content.BroadcastReceiver import android.content.Context diff --git a/app/src/main/kotlin/org/meshtastic/app/service/MeshService.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshService.kt similarity index 90% rename from app/src/main/kotlin/org/meshtastic/app/service/MeshService.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshService.kt index afd31361c..2ed00ec6a 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/MeshService.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshService.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.app.Service import android.content.Context @@ -27,12 +27,8 @@ import co.touchlab.kermit.Logger import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach import org.koin.android.ext.android.inject -import org.meshtastic.app.BuildConfig import org.meshtastic.core.common.hasLocationPermission -import org.meshtastic.core.common.util.handledLaunch import org.meshtastic.core.common.util.toRemoteExceptions import org.meshtastic.core.model.DataPacket import org.meshtastic.core.model.DeviceVersion @@ -44,17 +40,12 @@ import org.meshtastic.core.model.RadioNotConnectedException import org.meshtastic.core.repository.CommandSender import org.meshtastic.core.repository.MeshConnectionManager import org.meshtastic.core.repository.MeshLocationManager -import org.meshtastic.core.repository.MeshMessageProcessor import org.meshtastic.core.repository.MeshRouter -import org.meshtastic.core.repository.MeshServiceNotifications import org.meshtastic.core.repository.NodeManager -import org.meshtastic.core.repository.PacketHandler import org.meshtastic.core.repository.RadioInterfaceService import org.meshtastic.core.repository.SERVICE_NOTIFY_ID import org.meshtastic.core.repository.ServiceBroadcasts import org.meshtastic.core.repository.ServiceRepository -import org.meshtastic.core.service.IMeshService -import org.meshtastic.feature.connections.NO_DEVICE_SELECTED import org.meshtastic.proto.PortNum @Suppress("TooManyFunctions", "LargeClass") @@ -64,21 +55,17 @@ class MeshService : Service() { private val serviceRepository: ServiceRepository by inject() - private val packetHandler: PacketHandler by inject() - private val serviceBroadcasts: ServiceBroadcasts by inject() private val nodeManager: NodeManager by inject() - private val messageProcessor: MeshMessageProcessor by inject() - private val commandSender: CommandSender by inject() private val locationManager: MeshLocationManager by inject() private val connectionManager: MeshConnectionManager by inject() - private val serviceNotifications: MeshServiceNotifications by inject() + private val orchestrator: MeshServiceOrchestrator by inject() private val router: MeshRouter by inject() @@ -102,8 +89,8 @@ class MeshService : Service() { startService(context) } - val minDeviceVersion = DeviceVersion(BuildConfig.MIN_FW_VERSION) - val absoluteMinDeviceVersion = DeviceVersion(BuildConfig.ABS_MIN_FW_VERSION) + val minDeviceVersion = DeviceVersion(DeviceVersion.MIN_FW_VERSION) + val absoluteMinDeviceVersion = DeviceVersion(DeviceVersion.ABS_MIN_FW_VERSION) } override fun onCreate() { @@ -121,29 +108,13 @@ class MeshService : Service() { throw e } Logger.i { "Creating mesh service" } - serviceNotifications.initChannels() - packetHandler.start(serviceScope) - router.start(serviceScope) - nodeManager.start(serviceScope) - connectionManager.start(serviceScope) - messageProcessor.start(serviceScope) - commandSender.start(serviceScope) - - serviceScope.handledLaunch { radioInterfaceService.connect() } - - radioInterfaceService.receivedData - .onEach { bytes -> messageProcessor.handleFromRadio(bytes, nodeManager.myNodeNum) } - .launchIn(serviceScope) - - serviceRepository.serviceAction.onEach(router.actionHandler::onServiceAction).launchIn(serviceScope) - - nodeManager.loadCachedNodeDB() + orchestrator.start() } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { val a = radioInterfaceService.getDeviceAddress() - val wantForeground = a != null && a != NO_DEVICE_SELECTED + val wantForeground = a != null && a != "n" val notification = connectionManager.updateStatusNotification() as android.app.Notification @@ -207,6 +178,7 @@ class MeshService : Service() { override fun onDestroy() { Logger.i { "Destroying mesh service" } ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE) + orchestrator.stop() serviceJob.cancel() super.onDestroy() } diff --git a/app/src/main/kotlin/org/meshtastic/app/service/MeshServiceNotificationsImpl.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceNotificationsImpl.kt similarity index 97% rename from app/src/main/kotlin/org/meshtastic/app/service/MeshServiceNotificationsImpl.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceNotificationsImpl.kt index e790d8d0d..ea17e4fc0 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/MeshServiceNotificationsImpl.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceNotificationsImpl.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.app.Notification import android.app.NotificationChannel @@ -40,11 +40,6 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.runBlocking import org.jetbrains.compose.resources.StringResource import org.koin.core.annotation.Single -import org.meshtastic.app.MainActivity -import org.meshtastic.app.R.raw -import org.meshtastic.app.service.MarkAsReadReceiver.Companion.MARK_AS_READ_ACTION -import org.meshtastic.app.service.ReactionReceiver.Companion.REACT_ACTION -import org.meshtastic.app.service.ReplyReceiver.Companion.KEY_TEXT_REPLY import org.meshtastic.core.common.util.nowMillis import org.meshtastic.core.model.DataPacket import org.meshtastic.core.model.Message @@ -55,6 +50,7 @@ import org.meshtastic.core.repository.MeshServiceNotifications import org.meshtastic.core.repository.NodeRepository import org.meshtastic.core.repository.PacketRepository import org.meshtastic.core.repository.SERVICE_NOTIFY_ID +import org.meshtastic.core.resources.R.raw import org.meshtastic.core.resources.Res import org.meshtastic.core.resources.client_notification import org.meshtastic.core.resources.getString @@ -87,6 +83,9 @@ import org.meshtastic.core.resources.no_local_stats import org.meshtastic.core.resources.powered import org.meshtastic.core.resources.reply import org.meshtastic.core.resources.you +import org.meshtastic.core.service.MarkAsReadReceiver.Companion.MARK_AS_READ_ACTION +import org.meshtastic.core.service.ReactionReceiver.Companion.REACT_ACTION +import org.meshtastic.core.service.ReplyReceiver.Companion.KEY_TEXT_REPLY import org.meshtastic.proto.ClientNotification import org.meshtastic.proto.DeviceMetrics import org.meshtastic.proto.LocalStats @@ -453,7 +452,7 @@ class MeshServiceNotificationsImpl( val summaryNotification = commonBuilder(NotificationType.DirectMessage) - .setSmallIcon(org.meshtastic.app.R.drawable.app_icon) + .setSmallIcon(context.applicationInfo.icon) .setStyle(messagingStyle) .setGroup(GROUP_KEY_MESSAGES) .setGroupSummary(true) @@ -697,14 +696,17 @@ class MeshServiceNotificationsImpl( // region Helper/Builder Methods private val openAppIntent: PendingIntent by lazy { - val intent = Intent(context, MainActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_SINGLE_TOP } + val intent = + Intent(context, Class.forName("org.meshtastic.app.MainActivity")).apply { + flags = Intent.FLAG_ACTIVITY_SINGLE_TOP + } PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) } private fun createOpenMessageIntent(contactKey: String): PendingIntent { val deepLinkUri = "$DEEP_LINK_BASE_URI/messages/$contactKey".toUri() val deepLinkIntent = - Intent(Intent.ACTION_VIEW, deepLinkUri, context, MainActivity::class.java).apply { + Intent(Intent.ACTION_VIEW, deepLinkUri, context, Class.forName("org.meshtastic.app.MainActivity")).apply { flags = Intent.FLAG_ACTIVITY_SINGLE_TOP } @@ -717,7 +719,7 @@ class MeshServiceNotificationsImpl( private fun createOpenWaypointIntent(waypointId: Int): PendingIntent { val deepLinkUri = "$DEEP_LINK_BASE_URI/map?waypointId=$waypointId".toUri() val deepLinkIntent = - Intent(Intent.ACTION_VIEW, deepLinkUri, context, MainActivity::class.java).apply { + Intent(Intent.ACTION_VIEW, deepLinkUri, context, Class.forName("org.meshtastic.app.MainActivity")).apply { flags = Intent.FLAG_ACTIVITY_SINGLE_TOP } @@ -730,7 +732,7 @@ class MeshServiceNotificationsImpl( private fun createOpenNodeDetailIntent(nodeNum: Int): PendingIntent { val deepLinkUri = "$DEEP_LINK_BASE_URI/node?destNum=$nodeNum".toUri() val deepLinkIntent = - Intent(Intent.ACTION_VIEW, deepLinkUri, context, MainActivity::class.java).apply { + Intent(Intent.ACTION_VIEW, deepLinkUri, context, Class.forName("org.meshtastic.app.MainActivity")).apply { flags = Intent.FLAG_ACTIVITY_SINGLE_TOP } @@ -811,7 +813,7 @@ class MeshServiceNotificationsImpl( type: NotificationType, contentIntent: PendingIntent? = null, ): NotificationCompat.Builder { - val smallIcon = org.meshtastic.app.R.drawable.app_icon + val smallIcon = context.applicationInfo.icon return NotificationCompat.Builder(context, type.channelId) .setSmallIcon(smallIcon) diff --git a/app/src/main/kotlin/org/meshtastic/app/service/MeshServiceStarter.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceStarter.kt similarity index 92% rename from app/src/main/kotlin/org/meshtastic/app/service/MeshServiceStarter.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceStarter.kt index 96ea0d9bf..463ec35ea 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/MeshServiceStarter.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshServiceStarter.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.app.ForegroundServiceStartNotAllowedException import android.content.Context @@ -23,8 +23,7 @@ import androidx.work.OneTimeWorkRequestBuilder import androidx.work.OutOfQuotaPolicy import androidx.work.WorkManager import co.touchlab.kermit.Logger -import org.meshtastic.app.BuildConfig -import org.meshtastic.app.worker.ServiceKeepAliveWorker +import org.meshtastic.core.service.worker.ServiceKeepAliveWorker // / Helper function to start running our service fun MeshService.Companion.startService(context: Context) { @@ -36,7 +35,7 @@ fun MeshService.Companion.startService(context: Context) { // Before binding we want to explicitly create - so the service stays alive forever (so it can keep // listening for the bluetooth packets arriving from the radio. And when they arrive forward them // to Signal or whatever. - Logger.i { "Trying to start service debug=${BuildConfig.DEBUG}" } + Logger.i { "Trying to start service debug=${false}" } val intent = createIntent(context) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { diff --git a/app/src/main/kotlin/org/meshtastic/app/service/ReactionReceiver.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/ReactionReceiver.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/service/ReactionReceiver.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/ReactionReceiver.kt index fec13effb..7a3e026a7 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/ReactionReceiver.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/ReactionReceiver.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.content.BroadcastReceiver import android.content.Context diff --git a/app/src/main/kotlin/org/meshtastic/app/service/ReplyReceiver.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/ReplyReceiver.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/service/ReplyReceiver.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/ReplyReceiver.kt index e09f6c656..4e82a735d 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/ReplyReceiver.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/ReplyReceiver.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.content.BroadcastReceiver import android.content.Context diff --git a/app/src/main/kotlin/org/meshtastic/app/service/ServiceBroadcasts.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/ServiceBroadcasts.kt similarity index 99% rename from app/src/main/kotlin/org/meshtastic/app/service/ServiceBroadcasts.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/ServiceBroadcasts.kt index 8b4ffc1a2..321968908 100644 --- a/app/src/main/kotlin/org/meshtastic/app/service/ServiceBroadcasts.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/ServiceBroadcasts.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.service +package org.meshtastic.core.service import android.content.Context import android.content.Intent diff --git a/app/src/main/kotlin/org/meshtastic/app/worker/MeshLogCleanupWorker.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/MeshLogCleanupWorker.kt similarity index 98% rename from app/src/main/kotlin/org/meshtastic/app/worker/MeshLogCleanupWorker.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/MeshLogCleanupWorker.kt index 11495b645..ed686d984 100644 --- a/app/src/main/kotlin/org/meshtastic/app/worker/MeshLogCleanupWorker.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/MeshLogCleanupWorker.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.worker +package org.meshtastic.core.service.worker import android.content.Context import androidx.work.CoroutineWorker diff --git a/app/src/main/kotlin/org/meshtastic/app/messaging/domain/worker/SendMessageWorker.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/SendMessageWorker.kt similarity index 97% rename from app/src/main/kotlin/org/meshtastic/app/messaging/domain/worker/SendMessageWorker.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/SendMessageWorker.kt index 19fb3324e..c12957eb7 100644 --- a/app/src/main/kotlin/org/meshtastic/app/messaging/domain/worker/SendMessageWorker.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/SendMessageWorker.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.messaging.domain.worker +package org.meshtastic.core.service.worker import android.content.Context import androidx.work.CoroutineWorker diff --git a/app/src/main/kotlin/org/meshtastic/app/worker/ServiceKeepAliveWorker.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/ServiceKeepAliveWorker.kt similarity index 93% rename from app/src/main/kotlin/org/meshtastic/app/worker/ServiceKeepAliveWorker.kt rename to core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/ServiceKeepAliveWorker.kt index b83fc9aff..9bda51e00 100644 --- a/app/src/main/kotlin/org/meshtastic/app/worker/ServiceKeepAliveWorker.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/ServiceKeepAliveWorker.kt @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.meshtastic.app.worker +package org.meshtastic.core.service.worker import android.app.Notification import android.content.Context @@ -26,11 +26,10 @@ import androidx.work.ForegroundInfo import androidx.work.WorkerParameters import co.touchlab.kermit.Logger import org.koin.android.annotation.KoinWorker -import org.meshtastic.app.R -import org.meshtastic.app.service.MeshService -import org.meshtastic.app.service.startService import org.meshtastic.core.repository.MeshServiceNotifications import org.meshtastic.core.repository.SERVICE_NOTIFY_ID +import org.meshtastic.core.service.MeshService +import org.meshtastic.core.service.startService /** * A worker whose sole purpose is to start the MeshService from the background. This is used as a fallback when @@ -81,7 +80,7 @@ class ServiceKeepAliveWorker( // We use "my_service" which matches NotificationType.ServiceState.channelId in MeshServiceNotificationsImpl return NotificationCompat.Builder(applicationContext, "my_service") - .setSmallIcon(R.drawable.ic_launcher_foreground) + .setSmallIcon(applicationContext.applicationInfo.icon) .setContentTitle("Resuming Mesh Service") .setPriority(NotificationCompat.PRIORITY_LOW) .setOngoing(true) diff --git a/core/service/src/commonMain/kotlin/org/meshtastic/core/service/MeshServiceOrchestrator.kt b/core/service/src/commonMain/kotlin/org/meshtastic/core/service/MeshServiceOrchestrator.kt index 0bcfb62d6..0faf332a8 100644 --- a/core/service/src/commonMain/kotlin/org/meshtastic/core/service/MeshServiceOrchestrator.kt +++ b/core/service/src/commonMain/kotlin/org/meshtastic/core/service/MeshServiceOrchestrator.kt @@ -22,6 +22,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import org.koin.core.annotation.Single import org.meshtastic.core.common.util.handledLaunch import org.meshtastic.core.repository.CommandSender import org.meshtastic.core.repository.MeshConnectionManager @@ -42,6 +43,7 @@ import org.meshtastic.core.repository.ServiceRepository * All injected dependencies are `commonMain` interfaces with real implementations in `core:data`. */ @Suppress("LongParameterList") +@Single class MeshServiceOrchestrator( private val radioInterfaceService: RadioInterfaceService, private val serviceRepository: ServiceRepository, diff --git a/core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt b/core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt new file mode 100644 index 000000000..3afc27cd5 --- /dev/null +++ b/core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2026 Meshtastic LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.meshtastic.core.service + +import io.mockk.every +import io.mockk.mockk +import io.mockk.verify +import kotlinx.coroutines.flow.MutableSharedFlow +import org.meshtastic.core.repository.CommandSender +import org.meshtastic.core.repository.MeshConnectionManager +import org.meshtastic.core.repository.MeshMessageProcessor +import org.meshtastic.core.repository.MeshRouter +import org.meshtastic.core.repository.MeshServiceNotifications +import org.meshtastic.core.repository.NodeManager +import org.meshtastic.core.repository.PacketHandler +import org.meshtastic.core.repository.RadioInterfaceService +import org.meshtastic.core.repository.ServiceRepository +import kotlin.test.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class MeshServiceOrchestratorTest { + + @Test + fun testStartWiresComponents() { + val radioInterfaceService = mockk(relaxed = true) + val serviceRepository = mockk(relaxed = true) + val packetHandler = mockk(relaxed = true) + val nodeManager = mockk(relaxed = true) + val messageProcessor = mockk(relaxed = true) + val commandSender = mockk(relaxed = true) + val connectionManager = mockk(relaxed = true) + val router = mockk(relaxed = true) + val serviceNotifications = mockk(relaxed = true) + + every { radioInterfaceService.receivedData } returns MutableSharedFlow() + every { serviceRepository.serviceAction } returns MutableSharedFlow() + + val orchestrator = + MeshServiceOrchestrator( + radioInterfaceService, + serviceRepository, + packetHandler, + nodeManager, + messageProcessor, + commandSender, + connectionManager, + router, + serviceNotifications, + ) + + assertFalse(orchestrator.isRunning) + orchestrator.start() + assertTrue(orchestrator.isRunning) + + verify { serviceNotifications.initChannels() } + verify { packetHandler.start(any()) } + verify { nodeManager.loadCachedNodeDB() } + + orchestrator.stop() + assertFalse(orchestrator.isRunning) + } +} diff --git a/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt b/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt index c1555c5db..4a8bd17ef 100644 --- a/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt +++ b/desktop/src/main/kotlin/org/meshtastic/desktop/Main.kt @@ -49,11 +49,11 @@ import org.koin.core.context.startKoin import org.meshtastic.core.datastore.UiPreferencesDataSource import org.meshtastic.core.navigation.SettingsRoutes import org.meshtastic.core.navigation.TopLevelDestination +import org.meshtastic.core.service.MeshServiceOrchestrator import org.meshtastic.core.ui.theme.AppTheme import org.meshtastic.desktop.data.DesktopPreferencesDataSource import org.meshtastic.desktop.di.desktopModule import org.meshtastic.desktop.di.desktopPlatformModule -import org.meshtastic.desktop.radio.DesktopMeshServiceController import org.meshtastic.desktop.ui.DesktopMainScreen import org.meshtastic.desktop.ui.navSavedStateConfig import java.util.Locale @@ -82,7 +82,7 @@ fun main() = application(exitProcessOnExit = false) { val systemLocale = remember { Locale.getDefault() } // Start the mesh service processing chain (desktop equivalent of Android's MeshService) - val meshServiceController = remember { koinApp.koin.get() } + val meshServiceController = remember { koinApp.koin.get() } DisposableEffect(Unit) { meshServiceController.start() onDispose { meshServiceController.stop() } diff --git a/desktop/src/main/kotlin/org/meshtastic/desktop/di/DesktopKoinModule.kt b/desktop/src/main/kotlin/org/meshtastic/desktop/di/DesktopKoinModule.kt index edaea3c50..2bc65cb0b 100644 --- a/desktop/src/main/kotlin/org/meshtastic/desktop/di/DesktopKoinModule.kt +++ b/desktop/src/main/kotlin/org/meshtastic/desktop/di/DesktopKoinModule.kt @@ -41,7 +41,6 @@ import org.meshtastic.core.repository.PlatformAnalytics import org.meshtastic.core.repository.RadioInterfaceService import org.meshtastic.core.repository.ServiceBroadcasts import org.meshtastic.core.repository.ServiceRepository -import org.meshtastic.desktop.radio.DesktopMeshServiceController import org.meshtastic.desktop.radio.DesktopRadioInterfaceService import org.meshtastic.desktop.stub.NoopAppWidgetUpdater import org.meshtastic.desktop.stub.NoopCompassHeadingProvider @@ -151,19 +150,6 @@ private fun desktopPlatformStubsModule() = module { single { NoopMagneticFieldProvider() } // Desktop mesh service controller — replaces Android's MeshService lifecycle - single { - DesktopMeshServiceController( - radioInterfaceService = get(), - serviceRepository = get(), - messageProcessor = get(), - connectionManager = get(), - packetHandler = get(), - router = get(), - nodeManager = get(), - commandSender = get(), - ) - } - // Ktor HttpClient for JVM/Desktop (equivalent of CoreNetworkAndroidModule on Android) single { HttpClient(Java) { install(ContentNegotiation) { json(get()) } } } diff --git a/desktop/src/main/kotlin/org/meshtastic/desktop/radio/DesktopMeshServiceController.kt b/desktop/src/main/kotlin/org/meshtastic/desktop/radio/DesktopMeshServiceController.kt deleted file mode 100644 index f6f725778..000000000 --- a/desktop/src/main/kotlin/org/meshtastic/desktop/radio/DesktopMeshServiceController.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2025-2026 Meshtastic LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.meshtastic.desktop.radio - -import co.touchlab.kermit.Logger -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.cancel -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import org.meshtastic.core.common.util.handledLaunch -import org.meshtastic.core.repository.CommandSender -import org.meshtastic.core.repository.MeshConnectionManager -import org.meshtastic.core.repository.MeshMessageProcessor -import org.meshtastic.core.repository.MeshRouter -import org.meshtastic.core.repository.NodeManager -import org.meshtastic.core.repository.PacketHandler -import org.meshtastic.core.repository.RadioInterfaceService -import org.meshtastic.core.repository.ServiceRepository - -/** - * Desktop equivalent of Android's `MeshService.onCreate()`. - * - * Starts the full message-processing chain that connects the radio transport layer to the business logic: - * ``` - * radioInterfaceService.receivedData - * → messageProcessor.handleFromRadio(bytes, myNodeNum) - * → FromRadioPacketHandler → MeshRouter/PacketHandler/etc. - * ``` - * - * On Android this chain runs inside an Android `Service` (foreground service with notifications). On Desktop there is - * no Android Service concept, so this controller manages the same lifecycle in-process, started at app launch time. - */ -@Suppress("LongParameterList") -class DesktopMeshServiceController( - private val radioInterfaceService: RadioInterfaceService, - private val serviceRepository: ServiceRepository, - private val messageProcessor: MeshMessageProcessor, - private val connectionManager: MeshConnectionManager, - private val packetHandler: PacketHandler, - private val router: MeshRouter, - private val nodeManager: NodeManager, - private val commandSender: CommandSender, -) { - private var serviceScope: CoroutineScope? = null - - /** - * Starts the mesh service processing chain. - * - * This should be called once at application startup (after Koin is initialized). It mirrors the initialization - * logic from `MeshService.onCreate()`. - */ - @Suppress("InjectDispatcher") - fun start() { - if (serviceScope != null) { - Logger.w { "DesktopMeshServiceController: Already started, ignoring duplicate start()" } - return - } - - Logger.i { "DesktopMeshServiceController: Starting mesh service processing chain" } - val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) - serviceScope = scope - - // Start all processing components (same order as MeshService.onCreate) - packetHandler.start(scope) - router.start(scope) - nodeManager.start(scope) - connectionManager.start(scope) - messageProcessor.start(scope) - commandSender.start(scope) - - // Auto-connect to saved device address (mirrors MeshService.onCreate) - scope.handledLaunch { radioInterfaceService.connect() } - - // Wire the data flow: radio → message processor - radioInterfaceService.receivedData - .onEach { bytes -> messageProcessor.handleFromRadio(bytes, nodeManager.myNodeNum) } - .launchIn(scope) - - // Wire service actions to the router - serviceRepository.serviceAction.onEach(router.actionHandler::onServiceAction).launchIn(scope) - - // Load any cached node database - nodeManager.loadCachedNodeDB() - - Logger.i { "DesktopMeshServiceController: Processing chain started" } - } - - /** Stops the mesh service processing chain and cancels all coroutines. */ - fun stop() { - Logger.i { "DesktopMeshServiceController: Stopping" } - serviceScope?.cancel("DesktopMeshServiceController stopped") - serviceScope = null - } -} diff --git a/docs/kmp-status.md b/docs/kmp-status.md index 0659dedb9..2f5f2861f 100644 --- a/docs/kmp-status.md +++ b/docs/kmp-status.md @@ -120,7 +120,7 @@ Based on the latest codebase investigation, the following steps are proposed to - Parity tests exist in `core:navigation/commonTest` (`NavigationParityTest`) and `desktop/test` (`DesktopTopLevelDestinationParityTest`). - Remaining parity work is documented in [`decisions/navigation3-parity-2026-03.md`](./decisions/navigation3-parity-2026-03.md): serializer registration validation and platform exception tracking. -## Remaining App-Only ViewModels +## App Module Thinning Status All major ViewModels have now been extracted to `commonMain` and no longer rely on Android-specific subclasses. Platform-specific dependencies (like `android.net.Uri` or Location permissions) have been successfully isolated behind injected `core:repository` interfaces (e.g., `FileService`, `LocationService`). @@ -133,6 +133,18 @@ Extracted to shared `commonMain` (no longer app-only): - `ChannelViewModel` → `feature:settings/commonMain` - `NodeMapViewModel` → `feature:map/commonMain` +Extracted to core KMP modules (Android-specific implementations): +- Android Services, WorkManager Workers, and BroadcastReceivers → `core:service/androidMain` +- BLE, USB/Serial, TCP radio connections, and NsdManager → `core:network/androidMain` + +Remaining to be extracted from `:app` to achieve a true thin-shell module: +- Navigation routes (`ChannelsNavigation.kt`, `SettingsNavigation.kt`, etc.) +- Android App Widgets (`LocalStatsWidget.kt`, `AndroidAppWidgetUpdater.kt`) +- Message Queue implementation (`WorkManagerMessageQueue.kt`) +- Location provider bindings (`AndroidMeshLocationManager.kt`) +- Top-level UI composition (`ui/Main.kt`, `ui/node/AdaptiveNodeListScreen.kt`) +- Root Activity and Koin bootstrapping (`MainActivity.kt`, `MeshUtilApplication.kt`, `MeshServiceClient.kt`) + ## Prerelease Dependencies | Dependency | Version | Why | diff --git a/docs/roadmap.md b/docs/roadmap.md index 4174c7562..630984bc6 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -87,7 +87,8 @@ These items address structural gaps identified in the March 2026 architecture re 1. **App module thinning** — Extracted ChannelViewModel, NodeMapViewModel, NodeContextMenu, EmptyDetailPlaceholder to shared modules. - ✅ **Done:** Extracted remaining 5 ViewModels: `SettingsViewModel`, `RadioConfigViewModel`, `DebugViewModel`, `MetricsViewModel`, `UIViewModel` to shared KMP modules. - - **Next:** Extract service/worker/radio files from `app` to `core:service/androidMain` and `core:network/androidMain`. + - ✅ **Done:** Extracted service, worker, and radio files from `app` to `core:service/androidMain` and `core:network/androidMain`. + - **Next:** Extract remaining Android-specific files (e.g., Navigation files, App Widgets, message queues, and root Activity logic) out of `:app` to establish a truly thin app module. 2. **Serial/USB transport** — direct radio connection on Desktop via jSerialComm 3. **MQTT transport** — cloud relay operation (KMP, benefits all targets) 4. **Evaluate KMP-native mocking** — Evaluate `mockative` or similar to replace `mockk` in `commonMain` of `core:testing` for iOS readiness. diff --git a/feature/connections/build.gradle.kts b/feature/connections/build.gradle.kts index 6b43d6376..292ebfa15 100644 --- a/feature/connections/build.gradle.kts +++ b/feature/connections/build.gradle.kts @@ -50,6 +50,7 @@ kotlin { implementation(projects.core.service) implementation(projects.core.ui) implementation(projects.core.ble) + implementation(projects.core.network) implementation(projects.feature.settings) implementation(libs.jetbrains.lifecycle.viewmodel.compose) diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/AndroidScannerViewModel.kt b/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/AndroidScannerViewModel.kt index fd97362c8..9a065a83a 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/AndroidScannerViewModel.kt +++ b/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/AndroidScannerViewModel.kt @@ -27,12 +27,12 @@ import org.meshtastic.core.ble.BluetoothRepository import org.meshtastic.core.datastore.RecentAddressesDataSource import org.meshtastic.core.model.RadioController import org.meshtastic.core.model.util.anonymize +import org.meshtastic.core.network.repository.UsbRepository import org.meshtastic.core.repository.RadioInterfaceService import org.meshtastic.core.repository.ServiceRepository import org.meshtastic.feature.connections.model.AndroidUsbDeviceData import org.meshtastic.feature.connections.model.DeviceListEntry import org.meshtastic.feature.connections.model.GetDiscoveredDevicesUseCase -import org.meshtastic.feature.connections.repository.UsbRepository @KoinViewModel @Suppress("LongParameterList", "TooManyFunctions") diff --git a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt b/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt index 5289f10c3..d620a4933 100644 --- a/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt +++ b/feature/connections/src/androidMain/kotlin/org/meshtastic/feature/connections/domain/usecase/AndroidGetDiscoveredDevicesUseCase.kt @@ -28,6 +28,9 @@ import org.meshtastic.core.common.database.DatabaseManager import org.meshtastic.core.datastore.RecentAddressesDataSource import org.meshtastic.core.datastore.model.RecentAddress import org.meshtastic.core.model.Node +import org.meshtastic.core.network.repository.NetworkRepository +import org.meshtastic.core.network.repository.NetworkRepository.Companion.toAddressString +import org.meshtastic.core.network.repository.UsbRepository import org.meshtastic.core.repository.NodeRepository import org.meshtastic.core.repository.RadioInterfaceService import org.meshtastic.core.resources.Res @@ -38,9 +41,6 @@ import org.meshtastic.feature.connections.model.DeviceListEntry import org.meshtastic.feature.connections.model.DiscoveredDevices import org.meshtastic.feature.connections.model.GetDiscoveredDevicesUseCase import org.meshtastic.feature.connections.model.getMeshtasticShortName -import org.meshtastic.feature.connections.repository.NetworkRepository -import org.meshtastic.feature.connections.repository.NetworkRepository.Companion.toAddressString -import org.meshtastic.feature.connections.repository.UsbRepository import java.util.Locale @Suppress("LongParameterList") diff --git a/feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/components/NetworkDevices.kt b/feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/components/NetworkDevices.kt index ce530bac7..b775b715e 100644 --- a/feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/components/NetworkDevices.kt +++ b/feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/components/NetworkDevices.kt @@ -50,6 +50,7 @@ import kotlinx.coroutines.launch import org.jetbrains.compose.resources.stringResource import org.meshtastic.core.common.util.isValidAddress import org.meshtastic.core.model.ConnectionState +import org.meshtastic.core.network.repository.NetworkConstants import org.meshtastic.core.resources.Res import org.meshtastic.core.resources.add_network_device import org.meshtastic.core.resources.address @@ -60,7 +61,6 @@ import org.meshtastic.core.resources.no_network_devices_found import org.meshtastic.core.resources.recent_network_devices import org.meshtastic.feature.connections.ScannerViewModel import org.meshtastic.feature.connections.model.DeviceListEntry -import org.meshtastic.feature.connections.repository.NetworkConstants @OptIn(ExperimentalMaterial3Api::class) @Composable diff --git a/mesh_service_example/src/main/kotlin/com/meshtastic/android/meshserviceexample/MainActivity.kt b/mesh_service_example/src/main/kotlin/com/meshtastic/android/meshserviceexample/MainActivity.kt index 758e9c0b3..26063e2b7 100644 --- a/mesh_service_example/src/main/kotlin/com/meshtastic/android/meshserviceexample/MainActivity.kt +++ b/mesh_service_example/src/main/kotlin/com/meshtastic/android/meshserviceexample/MainActivity.kt @@ -134,7 +134,7 @@ class MainActivity : ComponentActivity() { Log.i(TAG, "Found service in package: ${serviceInfo.packageName}") } else { Log.w(TAG, "No service found for action com.geeksville.mesh.Service. Falling back to default.") - intent.setClassName("com.geeksville.mesh", "org.meshtastic.app.service.MeshService") + intent.setClassName("com.geeksville.mesh", "org.meshtastic.core.service.MeshService") } val success = bindService(intent, serviceConnection, BIND_AUTO_CREATE)