Improved startup sequence (#20)
* Improved startup sequence * updated comments/order
This commit is contained in:
parent
ccbe6b7ab8
commit
a2f0399c9f
@ -7,18 +7,36 @@
|
||||
|
||||
#define TAG "tactility"
|
||||
|
||||
// System services
|
||||
// region System services
|
||||
|
||||
extern const ServiceManifest gui_service;
|
||||
extern const ServiceManifest loader_service;
|
||||
|
||||
// System apps
|
||||
static const ServiceManifest* const system_services[] = {
|
||||
&gui_service,
|
||||
&loader_service // depends on gui service
|
||||
};
|
||||
|
||||
// endregion
|
||||
|
||||
// region System apps
|
||||
|
||||
extern const AppManifest desktop_app;
|
||||
extern const AppManifest system_info_app;
|
||||
|
||||
static const AppManifest* const system_apps[] = {
|
||||
&desktop_app,
|
||||
&system_info_app
|
||||
};
|
||||
|
||||
// endregion
|
||||
|
||||
static void register_system_apps() {
|
||||
TT_LOG_I(TAG, "Registering default apps");
|
||||
tt_app_manifest_registry_add(&desktop_app);
|
||||
tt_app_manifest_registry_add(&system_info_app);
|
||||
int app_count = sizeof(system_apps) / sizeof(AppManifest*);
|
||||
for (int i = 0; i < app_count; ++i) {
|
||||
tt_app_manifest_registry_add(system_apps[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void register_user_apps(const AppManifest* const apps[TT_CONFIG_APPS_LIMIT]) {
|
||||
@ -34,16 +52,13 @@ static void register_user_apps(const AppManifest* const apps[TT_CONFIG_APPS_LIMI
|
||||
}
|
||||
}
|
||||
|
||||
static void register_system_services() {
|
||||
TT_LOG_I(TAG, "Registering system services");
|
||||
tt_service_registry_add(&gui_service);
|
||||
tt_service_registry_add(&loader_service);
|
||||
static void register_and_start_system_services() {
|
||||
TT_LOG_I(TAG, "Registering and starting system services");
|
||||
int app_count = sizeof(system_services) / sizeof(ServiceManifest *);
|
||||
for (int i = 0; i < app_count; ++i) {
|
||||
tt_service_registry_add(system_services[i]);
|
||||
tt_check(tt_service_registry_start(system_services[i]->id));
|
||||
}
|
||||
|
||||
static void start_system_services() {
|
||||
TT_LOG_I(TAG, "Starting system services");
|
||||
tt_service_registry_start(gui_service.id);
|
||||
tt_service_registry_start(loader_service.id);
|
||||
}
|
||||
|
||||
static void register_and_start_user_services(const ServiceManifest* const services[TT_CONFIG_SERVICES_LIMIT]) {
|
||||
@ -52,7 +67,7 @@ static void register_and_start_user_services(const ServiceManifest* const servic
|
||||
const ServiceManifest* manifest = services[i];
|
||||
if (manifest != NULL) {
|
||||
tt_service_registry_add(manifest);
|
||||
tt_service_registry_start(manifest->id);
|
||||
tt_check(tt_service_registry_start(manifest->id));
|
||||
} else {
|
||||
// reached end of list
|
||||
break;
|
||||
@ -68,21 +83,22 @@ TT_UNUSED void tt_init(const Config* config) {
|
||||
|
||||
tt_hardware_init(config->hardware);
|
||||
|
||||
// Register all apps
|
||||
register_system_services();
|
||||
// Note: the order of starting apps and services is critical!
|
||||
// System services are registered first so they can be used by the apps
|
||||
register_and_start_system_services();
|
||||
// Then we register system apps. They are not used/started yet.
|
||||
register_system_apps();
|
||||
// TODO: move this after start_system_services, but desktop must subscribe to app registry events first.
|
||||
register_user_apps(config->apps);
|
||||
|
||||
// Start all services
|
||||
start_system_services();
|
||||
// Then we register and start user services. They are started after system app
|
||||
// registration just in case they want to figure out which system apps are installed.
|
||||
register_and_start_user_services(config->services);
|
||||
// Now we register the user apps, as they might rely on the user services.
|
||||
register_user_apps(config->apps);
|
||||
|
||||
TT_LOG_I(TAG, "tt_init starting desktop app");
|
||||
loader_start_app(desktop_app.id, true, NULL);
|
||||
|
||||
if (config->auto_start_app_id) {
|
||||
TT_LOG_I(TAG, "tt_init aut-starting %s", config->auto_start_app_id);
|
||||
TT_LOG_I(TAG, "tt_init auto-starting %s", config->auto_start_app_id);
|
||||
loader_start_app(config->auto_start_app_id, true, NULL);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user