integrate AppManager and UpdateService into kernel with Lua API registration
This commit is contained in:
@@ -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 <android/hardware_buffer.h>
|
||||
#include <android/asset_manager.h>
|
||||
@@ -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<mosis::AppManager>(data_root);
|
||||
m_update_service = std::make_unique<mosis::UpdateService>(
|
||||
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)
|
||||
|
||||
@@ -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<RenderTarget> m_render_target;
|
||||
std::unordered_map<pid_t, std::shared_ptr<aidl::com::omixlab::mosis::IMosisListener>> m_listeners;
|
||||
std::unique_ptr<aidl::android::hardware::HardwareBuffer> m_aidl_buffer;
|
||||
std::unique_ptr<mosis::AppManager> m_app_manager;
|
||||
std::unique_ptr<mosis::UpdateService> m_update_service;
|
||||
std::vector<std::function<void(Rml::Context*)>> m_tasks;
|
||||
std::mutex m_mutex;
|
||||
std::thread m_main_loop_thread;
|
||||
|
||||
Reference in New Issue
Block a user