From 54312574703dd90641f22c9812a1e6a9831921a0 Mon Sep 17 00:00:00 2001 From: Sergei Gavrilov Date: Thu, 4 Apr 2024 22:42:58 +1000 Subject: [PATCH] [FL-3765][FL-3737] Desktop: ensure that animation is unloaded before app start (#3569) * Desktop: ensure that animation is unloaded before app start * Desktop: unload animation only if it is loaded --- applications/services/desktop/desktop.c | 8 +++++++- applications/services/desktop/desktop_i.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 74979d128..49aa04e35 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -34,10 +34,12 @@ static void desktop_loader_callback(const void* message, void* context) { if(event->type == LoaderEventTypeApplicationStarted) { view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalBeforeAppStarted); + furi_check(furi_semaphore_acquire(desktop->animation_semaphore, 3000) == FuriStatusOk); } else if(event->type == LoaderEventTypeApplicationStopped) { view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopGlobalAfterAppFinished); } } + static void desktop_lock_icon_draw_callback(Canvas* canvas, void* context) { UNUSED(context); furi_assert(canvas); @@ -120,8 +122,11 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) { switch(event) { case DesktopGlobalBeforeAppStarted: - animation_manager_unload_and_stall_animation(desktop->animation_manager); + if(animation_manager_is_animation_loaded(desktop->animation_manager)) { + animation_manager_unload_and_stall_animation(desktop->animation_manager); + } desktop_auto_lock_inhibit(desktop); + furi_semaphore_release(desktop->animation_semaphore); return true; case DesktopGlobalAfterAppFinished: animation_manager_load_and_continue_animation(desktop->animation_manager); @@ -270,6 +275,7 @@ void desktop_set_stealth_mode_state(Desktop* desktop, bool enabled) { Desktop* desktop_alloc(void) { Desktop* desktop = malloc(sizeof(Desktop)); + desktop->animation_semaphore = furi_semaphore_alloc(1, 0); desktop->animation_manager = animation_manager_alloc(); desktop->gui = furi_record_open(RECORD_GUI); desktop->scene_thread = furi_thread_alloc(); diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index f6eeef6b1..c0b29f922 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -80,6 +80,8 @@ struct Desktop { bool time_format_12 : 1; // 1 - 12 hour, 0 - 24H bool in_transition : 1; + + FuriSemaphore* animation_semaphore; }; Desktop* desktop_alloc(void);