App and Service improvements (#106)

This commit is contained in:
Ken Van Hoeylandt
2024-12-05 22:46:27 +01:00
committed by GitHub
parent e86a11b7e2
commit 50ee77d572
69 changed files with 692 additions and 596 deletions
@@ -3,7 +3,7 @@
#include "Mutex.h"
#include "ScreenshotTask.h"
#include "service/Service.h"
#include "service/ServiceContext.h"
#include "service/ServiceRegistry.h"
#include "TactilityCore.h"
@@ -11,7 +11,7 @@ namespace tt::service::screenshot {
#define TAG "screenshot_service"
extern const Manifest manifest;
extern const ServiceManifest manifest;
typedef struct {
Mutex* mutex;
@@ -41,12 +41,12 @@ static void service_data_unlock(ServiceData* data) {
tt_check(tt_mutex_release(data->mutex) == TtStatusOk);
}
static void on_start(Service& service) {
static void on_start(ServiceContext& service) {
ServiceData* data = service_data_alloc();
service.setData(data);
}
static void on_stop(Service& service) {
static void on_stop(ServiceContext& service) {
auto* data = static_cast<ServiceData*>(service.getData());
if (data->task) {
task::free(data->task);
@@ -95,7 +95,7 @@ void startTimed(const char* path, uint8_t delay_in_seconds, uint8_t amount) {
}
void stop() {
_Nullable Service* service = findServiceById(manifest.id);
_Nullable ServiceContext* service = findServiceById(manifest.id);
if (service == nullptr) {
TT_LOG_E(TAG, "Service not found");
return;
@@ -132,7 +132,7 @@ bool isStarted() {
return getMode() != ScreenshotModeNone;
}
extern const Manifest manifest = {
extern const ServiceManifest manifest = {
.id = "Screenshot",
.onStart = &on_start,
.onStop = &on_stop
@@ -1,7 +1,7 @@
#include "ScreenshotTask.h"
#include "lv_screenshot.h"
#include "app/App.h"
#include "app/AppContext.h"
#include "Mutex.h"
#include "TactilityCore.h"
#include "Thread.h"
@@ -98,9 +98,9 @@ static int32_t screenshot_task(void* context) {
break; // Interrupted loop
}
} else if (data->work.type == TASK_WORK_TYPE_APPS) {
app::App* _Nullable app = loader::getCurrentApp();
app::AppContext* _Nullable app = loader::getCurrentApp();
if (app) {
const app::Manifest& manifest = app->getManifest();
const app::AppManifest& manifest = app->getManifest();
if (manifest.id != last_app_id) {
delay_ms(100);
last_app_id = manifest.id;