From 60d1a75838129ad6158b0401251019378c57d6b3 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sun, 18 Jan 2026 22:38:02 +0100 Subject: [PATCH] integrate AppManager and UpdateService into kernel with Lua API registration --- src/main/cpp/kernel.cpp | 29 +++++++++++++++++++++++++++-- src/main/cpp/kernel.h | 3 +++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/cpp/kernel.cpp b/src/main/cpp/kernel.cpp index 55b8005..e1fa2f2 100644 --- a/src/main/cpp/kernel.cpp +++ b/src/main/cpp/kernel.cpp @@ -3,6 +3,9 @@ #include "render_target.h" #include "logger.h" #include "assets_manager.h" +#include "apps/app_manager.h" +#include "apps/update_service.h" +#include "apps/app_api.h" #include "aidl/com/omixlab/mosis/IMosisListener.h" #include #include @@ -18,6 +21,8 @@ // Global state for Lua access static Rml::Context* g_context = nullptr; static Rml::ElementDocument* g_document = nullptr; +static mosis::AppManager* g_app_manager = nullptr; +static mosis::UpdateService* g_update_service = nullptr; using namespace aidl::com::omixlab::mosis; using namespace aidl::android::hardware; @@ -141,12 +146,18 @@ static int LuaLoadScreen(lua_State* L) } // Register Lua functions for navigation -static void RegisterLuaFunctions() +static void RegisterLuaFunctions(const std::string& current_app_id, bool is_system_app) { lua_State* L = Rml::Lua::Interpreter::GetLuaState(); lua_pushcfunction(L, LuaLoadScreen); lua_setglobal(L, "loadScreen"); Logger::Log("Registered Lua loadScreen function"); + + // Register app management APIs + if (g_app_manager && g_update_service) { + mosis::RegisterAppAPIs(L, g_app_manager, g_update_service, current_app_id, is_system_app); + Logger::Log("Registered Lua app management APIs"); + } } void Kernel::main_loop() @@ -184,8 +195,22 @@ void Kernel::main_loop() Rml::Lua::Initialise(); Logger::Log("RmlUi Lua bindings initialized"); + // Initialize app management system + // TODO: Get data root from Android context (for now use a placeholder) + std::string data_root = "/data/data/com.omixlab.mosis/files"; + m_app_manager = std::make_unique(data_root); + m_update_service = std::make_unique( + m_app_manager.get(), "https://portal.mosis.dev/api/v1"); + g_app_manager = m_app_manager.get(); + g_update_service = m_update_service.get(); + Logger::Log("App management system initialized"); + + // Start background update checks (every 24 hours) + m_update_service->Start(std::chrono::hours(24)); + // Register navigation functions with Lua - RegisterLuaFunctions(); + // Home screen is a system app with full access + RegisterLuaFunctions("com.mosis.home", true); g_context = Rml::CreateContext("default", Rml::Vector2i(540, 960)); if (!g_context) diff --git a/src/main/cpp/kernel.h b/src/main/cpp/kernel.h index 62e6819..3869481 100644 --- a/src/main/cpp/kernel.h +++ b/src/main/cpp/kernel.h @@ -11,6 +11,7 @@ namespace egl { class Context; } namespace aidl::com::omixlab::mosis { class IMosisListener; } namespace aidl::android::hardware { struct HardwareBuffer; } namespace Rml { class Context; } +namespace mosis { class AppManager; class UpdateService; } class Kernel { @@ -18,6 +19,8 @@ class Kernel std::unique_ptr m_render_target; std::unordered_map> m_listeners; std::unique_ptr m_aidl_buffer; + std::unique_ptr m_app_manager; + std::unique_ptr m_update_service; std::vector> m_tasks; std::mutex m_mutex; std::thread m_main_loop_thread;