mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-09-12 21:30:02 -04:00
perf(startup): move WorkManager and AppFunctions init off the main thread (#6648)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b5152d14a0
commit
8321df705a
2 files changed
+7
-4
No files matched your search
@@ -17,6 +17,7 @@
|
||||
package org.meshtastic.app
|
||||
|
||||
import androidx.appfunctions.AppFunctionConfiguration
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.java.KoinJavaComponent.getKoin
|
||||
import org.meshtastic.app.ai.appfunctions.AppFunctionStateSync
|
||||
import org.meshtastic.app.ai.appfunctions.MeshtasticAppFunctions
|
||||
@@ -36,7 +37,8 @@ class GoogleMeshUtilApplication :
|
||||
// Start the AppFunctions enabled-state sync. Resolved here (after startKoin has bound
|
||||
// androidContext) rather than via createdAtStart so that Koin graphs built outside a
|
||||
// running app — verification tests, previews — stay lazily constructible.
|
||||
getKoin().get<AppFunctionStateSync>()
|
||||
// Off-main: construction forces the AppFunctionsPrefs subgraph and fires AppSearch binder calls.
|
||||
applicationScope.launch { getKoin().get<AppFunctionStateSync>() }
|
||||
}
|
||||
|
||||
override val appFunctionConfiguration: AppFunctionConfiguration
|
||||
|
||||
@@ -68,7 +68,7 @@ open class MeshUtilApplication :
|
||||
Configuration.Provider,
|
||||
SingletonImageLoader.Factory {
|
||||
|
||||
private val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
protected val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
|
||||
/** Supplies Coil's process-wide loader without retaining an Activity in its singleton factory. */
|
||||
override fun newImageLoader(context: Context): ImageLoader = get<ImageLoader>()
|
||||
@@ -83,8 +83,9 @@ open class MeshUtilApplication :
|
||||
workManagerFactory()
|
||||
}
|
||||
|
||||
// Schedule periodic MeshLog cleanup
|
||||
scheduleMeshLogCleanup()
|
||||
// Schedule periodic MeshLog cleanup. Off-main: WorkManager uses on-demand init here
|
||||
// (the startup provider is removed), so getInstance() opens WorkManager's Room DB.
|
||||
applicationScope.launch { scheduleMeshLogCleanup() }
|
||||
|
||||
// Generate and publish widget preview for Android 15+ widget picker
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
|
||||
Reference in new issue
Block a user