From af6d0731b3d07f1636eb4f32a1959cc33d84ba68 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Wed, 21 Aug 2024 05:19:49 +0200 Subject: [PATCH] Workaround double load on boot of asset packs, settings... --- applications/services/storage/storage.c | 4 ++-- furi/flipper.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/applications/services/storage/storage.c b/applications/services/storage/storage.c index 6d0af00fb..c8e803817 100644 --- a/applications/services/storage/storage.c +++ b/applications/services/storage/storage.c @@ -60,7 +60,7 @@ Storage* storage_app_alloc(void) { #include #include -static int32_t sd_mount_handler(void* context) { +static int32_t sd_mount_callback(void* context) { Storage* app = context; StorageEvent event = {.type = StorageEventTypeCardMount}; @@ -108,7 +108,7 @@ void storage_tick(Storage* app) { #ifndef FURI_RAM_EXEC // Can't use pubsub for migration and can't lockup storage thread, // see more explanation in flipper_mount_callback() - run_parallel(sd_mount_handler, app, 3 * 1024); + run_parallel(sd_mount_callback, app, 3 * 1024); #else StorageEvent event = {.type = StorageEventTypeCardMount}; furi_pubsub_publish(app->pubsub, &event); diff --git a/furi/flipper.c b/furi/flipper.c index eb69e049e..bd138d5f6 100644 --- a/furi/flipper.c +++ b/furi/flipper.c @@ -123,11 +123,18 @@ void flipper_migrate_files() { // service is deadlocked processing pubsub and cannot process file operations // So instead storage runs this function in background thread and then // dispatches the pubsub event to everyone else +bool skip_double_mount = false; void flipper_mount_callback(const void* message, void* context) { UNUSED(context); const StorageEvent* event = message; if(event->type == StorageEventTypeCardMount) { + // Workaround to avoid double load on boot but also have animated boot screen + if(skip_double_mount) { + skip_double_mount = false; + return; + } + // Migrate locations before other services load on SD insert flipper_migrate_files(); @@ -180,6 +187,9 @@ void flipper_init(void) { FURI_LOG_D(TAG, "SD Card not ready, skipping early init"); // Init on SD insert done by storage using flipper_mount_callback() } else { + // Workaround to avoid double load on boot but also have animated boot screen + skip_double_mount = true; + canvas_draw_icon(canvas, 39, 43, &I_dir_10px); canvas_commit(canvas); flipper_migrate_files();