refactor: migrate from Hilt to Koin and expand KMP common modules (#4746)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-03-09 20:19:46 -05:00 committed by GitHub
parent a5390a80e7
commit 875cf1cff2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
440 changed files with 3738 additions and 3508 deletions

View file

@ -1,52 +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 <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.app
import androidx.work.Configuration
import dagger.hilt.android.EntryPointAccessors
/**
* A lightweight application class for Robolectric tests.
*
* It prevents heavy background initialization (WorkManager, DatabaseManager) by default to avoid resource leaks and
* flaky native SQLite issues on the JVM.
*/
class MeshTestApplication : MeshUtilApplication() {
override fun onCreate() {
// Only run real onCreate logic if a test explicitly asks for it
if (shouldInitialize) {
super.onCreate()
}
}
override fun onTerminate() {
if (shouldInitialize) {
val entryPoint = EntryPointAccessors.fromApplication(this, AppEntryPoint::class.java)
entryPoint.databaseManager().close()
}
super.onTerminate()
}
override val workManagerConfiguration: Configuration
get() = Configuration.Builder().setMinimumLoggingLevel(android.util.Log.DEBUG).build()
companion object {
/** Set to true in a test @Before block if you need real DB/WorkManager init. */
var shouldInitialize = false
}
}

View file

@ -0,0 +1,56 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package org.meshtastic.app.di
import android.app.Application
import android.content.Context
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.SavedStateHandle
import androidx.work.WorkManager
import androidx.work.WorkerParameters
import io.ktor.client.HttpClient
import io.ktor.client.engine.HttpClientEngine
import kotlinx.coroutines.CoroutineDispatcher
import okhttp3.OkHttpClient
import org.junit.Test
import org.koin.test.verify.verify
import org.meshtastic.core.model.util.NodeIdLookup
class KoinVerificationTest {
@Test
fun verifyKoinConfiguration() {
AppKoinModule()
.module()
.verify(
extraTypes =
listOf(
Application::class,
Context::class,
Lifecycle::class,
SavedStateHandle::class,
WorkerParameters::class,
WorkManager::class,
CoroutineDispatcher::class,
NodeIdLookup::class,
HttpClient::class,
HttpClientEngine::class,
OkHttpClient::class,
),
)
}
}