integrate sandbox manager with app lifecycle (LaunchApp, StopApp, IsAppRunning)
This commit is contained in:
@@ -11,9 +11,10 @@ set(AIDL_EXE "${ANDROID_SDK}/build-tools/36.1.0/aidl.exe")
|
||||
# Find Lua from vcpkg
|
||||
find_package(Lua REQUIRED)
|
||||
|
||||
# Find nlohmann_json and minizip for app management
|
||||
# Find nlohmann_json, minizip and sqlite3 for app management and sandbox
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
find_package(minizip CONFIG REQUIRED)
|
||||
find_package(unofficial-sqlite3 CONFIG REQUIRED)
|
||||
|
||||
# Fetch RmlUi from GitHub with Lua bindings enabled
|
||||
include(FetchContent)
|
||||
@@ -70,6 +71,28 @@ add_library(mosis-service SHARED
|
||||
apps/app_manager.cpp
|
||||
apps/app_api.cpp
|
||||
apps/update_service.cpp
|
||||
sandbox/lua_sandbox.cpp
|
||||
sandbox/permission_gate.cpp
|
||||
sandbox/audit_log.cpp
|
||||
sandbox/rate_limiter.cpp
|
||||
sandbox/path_sandbox.cpp
|
||||
sandbox/timer_manager.cpp
|
||||
sandbox/json_api.cpp
|
||||
sandbox/crypto_api.cpp
|
||||
sandbox/virtual_fs.cpp
|
||||
sandbox/database_manager.cpp
|
||||
sandbox/http_validator.cpp
|
||||
sandbox/network_manager.cpp
|
||||
sandbox/websocket_manager.cpp
|
||||
sandbox/camera_interface.cpp
|
||||
sandbox/microphone_interface.cpp
|
||||
sandbox/audio_output.cpp
|
||||
sandbox/location_interface.cpp
|
||||
sandbox/sensor_interface.cpp
|
||||
sandbox/bluetooth_interface.cpp
|
||||
sandbox/contacts_interface.cpp
|
||||
sandbox/message_bus.cpp
|
||||
sandbox/sandbox_manager.cpp
|
||||
)
|
||||
target_compile_definitions(mosis-service PUBLIC
|
||||
RMLUI_NUM_MSAA_SAMPLES=2
|
||||
@@ -86,6 +109,8 @@ target_link_libraries(mosis-service
|
||||
rmlui rmlui_lua
|
||||
nlohmann_json::nlohmann_json
|
||||
minizip::minizip
|
||||
unofficial::sqlite3::sqlite3
|
||||
${LUA_LIBRARIES}
|
||||
)
|
||||
|
||||
add_library(mosis-test SHARED
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "app_manager.h"
|
||||
#include "../logger.h"
|
||||
|
||||
// TODO: Integrate with sandbox manager when available
|
||||
// #include "../sandbox/sandbox_manager.h"
|
||||
#include "../sandbox/sandbox_manager.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -180,10 +179,10 @@ bool AppManager::Uninstall(const std::string& package_id, bool keep_data) {
|
||||
LOG_INFO("Uninstalling app: %s (keep_data=%d)", package_id.c_str(), keep_data);
|
||||
|
||||
// Stop app if running
|
||||
// TODO: Integrate with sandbox manager
|
||||
// if (m_sandbox_manager && m_sandbox_manager->IsAppRunning(package_id)) {
|
||||
// m_sandbox_manager->StopApp(package_id);
|
||||
// }
|
||||
if (m_sandbox_manager && m_sandbox_manager->IsAppRunning(package_id)) {
|
||||
LOG_INFO("Stopping running app before uninstall: %s", package_id.c_str());
|
||||
m_sandbox_manager->StopApp(package_id);
|
||||
}
|
||||
|
||||
// Remove files
|
||||
std::string install_path = it->second.install_path;
|
||||
@@ -315,29 +314,48 @@ bool AppManager::RestoreAppData(const std::string& package_id) {
|
||||
}
|
||||
|
||||
bool AppManager::LaunchApp(const std::string& package_id) {
|
||||
// TODO: Integrate with sandbox manager
|
||||
auto app = GetApp(package_id);
|
||||
if (!app) {
|
||||
LOG_ERROR("Cannot launch app: not installed: %s", package_id.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("Launching app: %s (sandbox integration pending)", package_id.c_str());
|
||||
// When sandbox is integrated:
|
||||
// std::string app_path = app->install_path + "/package";
|
||||
// return m_sandbox_manager->StartApp(package_id, app_path, app->permissions, app->is_system_app);
|
||||
if (!m_sandbox_manager) {
|
||||
LOG_ERROR("Cannot launch app: sandbox manager not set");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_sandbox_manager->IsAppRunning(package_id)) {
|
||||
LOG_WARN("App already running: %s", package_id.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string app_path = app->install_path + "/package";
|
||||
LOG_INFO("Launching app: %s from %s", package_id.c_str(), app_path.c_str());
|
||||
|
||||
return m_sandbox_manager->StartApp(package_id, app_path, app->permissions, app->is_system_app);
|
||||
}
|
||||
|
||||
bool AppManager::StopApp(const std::string& package_id) {
|
||||
// TODO: Integrate with sandbox manager
|
||||
LOG_INFO("Stopping app: %s (sandbox integration pending)", package_id.c_str());
|
||||
if (!m_sandbox_manager) {
|
||||
LOG_ERROR("Cannot stop app: sandbox manager not set");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_sandbox_manager->IsAppRunning(package_id)) {
|
||||
LOG_WARN("App not running: %s", package_id.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_INFO("Stopping app: %s", package_id.c_str());
|
||||
return m_sandbox_manager->StopApp(package_id);
|
||||
}
|
||||
|
||||
bool AppManager::IsAppRunning(const std::string& package_id) const {
|
||||
// TODO: Integrate with sandbox manager
|
||||
if (!m_sandbox_manager) {
|
||||
return false;
|
||||
}
|
||||
return m_sandbox_manager->IsAppRunning(package_id);
|
||||
}
|
||||
|
||||
void AppManager::SetSandboxManager(LuaSandboxManager* manager) {
|
||||
|
||||
@@ -379,9 +379,10 @@ std::optional<FileStat> VirtualFS::Stat(const std::string& path, std::string& er
|
||||
}
|
||||
|
||||
auto ftime = fs::last_write_time(physical_path, ec);
|
||||
auto sctp = std::chrono::time_point_cast<std::chrono::seconds>(
|
||||
std::chrono::clock_cast<std::chrono::system_clock>(ftime));
|
||||
stat.modified = sctp.time_since_epoch().count();
|
||||
// Convert file_time_type to system_clock (portable workaround for clock_cast)
|
||||
auto file_time_ns = ftime.time_since_epoch();
|
||||
auto sys_time_ns = std::chrono::duration_cast<std::chrono::seconds>(file_time_ns);
|
||||
stat.modified = sys_time_ns.count();
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"lua",
|
||||
"freetype",
|
||||
"nlohmann-json",
|
||||
"minizip"
|
||||
"minizip",
|
||||
"sqlite3"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user