Fixes and improvements: LVGL, services and kernel symbols (#587)
This commit is contained in:
committed by
GitHub
parent
d4ef83e316
commit
cd2d9d6158
@@ -48,9 +48,9 @@ void addService(std::shared_ptr<const ServiceManifest> manifest, bool autoStart)
|
||||
return;
|
||||
}
|
||||
|
||||
// Intentionally never freed: services are registered once and live for the
|
||||
// process lifetime (there is no removeService()). Keeps id's backing string
|
||||
// alive for cManifest.id below.
|
||||
// Intentionally never freed: removeService() only unregisters the manifest
|
||||
// from the kernel, it doesn't own this allocation. Keeps id's backing
|
||||
// string alive for cManifest.id below.
|
||||
auto* persistentManifest = new std::shared_ptr(manifest);
|
||||
auto* cManifest = new ::ServiceManifest {
|
||||
.id = (*persistentManifest)->id.c_str(),
|
||||
@@ -70,6 +70,29 @@ void addService(const ServiceManifest& manifest, bool autoStart) {
|
||||
addService(std::make_shared<const ServiceManifest>(manifest), autoStart);
|
||||
}
|
||||
|
||||
bool removeService(const std::string& id) {
|
||||
if (service_manager_get_state(id.c_str()) != SERVICE_STATE_STOPPED) {
|
||||
LOG_I(TAG, "Stopping %s before removal", id.c_str());
|
||||
if (!stopService(id)) {
|
||||
LOG_E(TAG, "Failed to stop %s before removal", id.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_I(TAG, "Removing %s", id.c_str());
|
||||
error_t error = service_manager_remove(id.c_str());
|
||||
if (error != ERROR_NONE) {
|
||||
LOG_E(TAG, "Failed to remove service %s: %s", id.c_str(), error_to_string(error));
|
||||
return false;
|
||||
}
|
||||
LOG_I(TAG, "Removed %s", id.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool removeService(const ServiceManifest& manifest) {
|
||||
return removeService(manifest.id);
|
||||
}
|
||||
|
||||
const ::ServiceManifest* findManifestById(const std::string& id) {
|
||||
return service_manager_find_manifest(id.c_str());
|
||||
}
|
||||
|
||||
@@ -178,10 +178,21 @@ void GuiService::redraw() {
|
||||
return;
|
||||
}
|
||||
|
||||
while (!lvgl_try_lock(1000)) {
|
||||
bool lvgl_locked = false;
|
||||
while (lvgl_is_running() && !(lvgl_locked = lvgl_try_lock(1000))) {
|
||||
LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "GuiService LVGL");
|
||||
}
|
||||
|
||||
if (!lvgl_locked) {
|
||||
unlock();
|
||||
return;
|
||||
}
|
||||
if (!lvgl_is_running()) {
|
||||
lvgl_unlock();
|
||||
unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
lv_obj_clean(appRootWidget);
|
||||
|
||||
if (appToRender != nullptr) {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <Tactility/service/rtctime/RtcTimeService.h>
|
||||
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <tactility/filesystem/file_system.h>
|
||||
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/module.h>
|
||||
|
||||
#include <lvgl/lvgl.h>
|
||||
#include <lvgl/lvgl_icon_statusbar.h>
|
||||
|
||||
Reference in New Issue
Block a user