package com.jovan.assistant.data import android.content.Context import android.content.SharedPreferences import kotlinx.coroutines.flow.MutableStateFlow /** Local settings, shared by the UI and the background service (same process). */ object Prefs { private lateinit var sp: SharedPreferences fun init(ctx: Context) { sp = ctx.applicationContext.getSharedPreferences("assistant", Context.MODE_PRIVATE) } var wakeWord: String get() = sp.getString("wake", "jovan") ?: "jovan" set(v) { sp.edit().putString("wake", v.trim().lowercase().ifBlank { "jovan" }).apply() } /** Epoch millis until which command execution is blocked by SecurityGuard. */ var blockedUntil: Long get() = sp.getLong("blockedUntil", 0L) set(v) { sp.edit().putLong("blockedUntil", v).apply() } } enum class WakeStatus(val label: String) { OFF("Stopped"), LISTENING_WAKE("Listening for wake word"), AWAITING_COMMAND("Waiting for your command"), PROCESSING("Processing command"), BLOCKED("Protective block active"), ERROR("Recognizer error") } /** Process-wide live state observed by the dashboard. */ object AssistantState { val wakeStatus = MutableStateFlow(WakeStatus.OFF) val lastHeard = MutableStateFlow("") val accessibilityConnected = MutableStateFlow(false) } data class LogEntry( var id: String = "", var ts: Long = 0L, var type: String = "", var message: String = "", var level: String = "info" // info | warn | error | critical )