mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
RC fixes (#4192)
* cli_shell: fix FL-3983 * fix formatting and submodules * loader: fix FL-3986 * fix submodules --------- Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
@@ -694,6 +694,7 @@ static void loader_do_unlock(Loader* loader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void loader_do_emit_queue_empty_event(Loader* loader) {
|
static void loader_do_emit_queue_empty_event(Loader* loader) {
|
||||||
|
if(loader_do_is_locked(loader)) return;
|
||||||
FURI_LOG_I(TAG, "Launch queue empty");
|
FURI_LOG_I(TAG, "Launch queue empty");
|
||||||
LoaderEvent event;
|
LoaderEvent event;
|
||||||
event.type = LoaderEventTypeNoMoreAppsInQueue;
|
event.type = LoaderEventTypeNoMoreAppsInQueue;
|
||||||
|
|||||||
@@ -31,10 +31,18 @@ CliShellKeyComboSet* component_key_combo_sets[] = {
|
|||||||
static_assert(CliShellComponentMAX == COUNT_OF(component_key_combo_sets));
|
static_assert(CliShellComponentMAX == COUNT_OF(component_key_combo_sets));
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CliShellStorageEventMount,
|
CliShellStorageEventMount = (1 << 0),
|
||||||
CliShellStorageEventUnmount,
|
CliShellStorageEventUnmount = (1 << 1),
|
||||||
} CliShellStorageEvent;
|
} CliShellStorageEvent;
|
||||||
|
|
||||||
|
#define CliShellStorageEventAll (CliShellStorageEventMount | CliShellStorageEventUnmount)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Storage* storage;
|
||||||
|
FuriPubSubSubscription* subscription;
|
||||||
|
FuriEventFlag* event_flag;
|
||||||
|
} CliShellStorage;
|
||||||
|
|
||||||
struct CliShell {
|
struct CliShell {
|
||||||
// Set and freed by external thread
|
// Set and freed by external thread
|
||||||
CliShellMotd motd;
|
CliShellMotd motd;
|
||||||
@@ -49,11 +57,7 @@ struct CliShell {
|
|||||||
FuriEventLoop* event_loop;
|
FuriEventLoop* event_loop;
|
||||||
CliAnsiParser* ansi_parser;
|
CliAnsiParser* ansi_parser;
|
||||||
FuriEventLoopTimer* ansi_parsing_timer;
|
FuriEventLoopTimer* ansi_parsing_timer;
|
||||||
|
CliShellStorage storage;
|
||||||
Storage* storage;
|
|
||||||
FuriPubSubSubscription* storage_subscription;
|
|
||||||
FuriMessageQueue* storage_event_queue;
|
|
||||||
|
|
||||||
void* components[CliShellComponentMAX];
|
void* components[CliShellComponentMAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -256,31 +260,32 @@ const char* cli_shell_get_prompt(CliShell* cli_shell) {
|
|||||||
// Event handlers
|
// Event handlers
|
||||||
// ==============
|
// ==============
|
||||||
|
|
||||||
|
static void cli_shell_signal_storage_event(CliShell* cli_shell, CliShellStorageEvent event) {
|
||||||
|
furi_check(!(furi_event_flag_set(cli_shell->storage.event_flag, event) & FuriFlagError));
|
||||||
|
}
|
||||||
|
|
||||||
static void cli_shell_storage_event(const void* message, void* context) {
|
static void cli_shell_storage_event(const void* message, void* context) {
|
||||||
CliShell* cli_shell = context;
|
CliShell* cli_shell = context;
|
||||||
const StorageEvent* event = message;
|
const StorageEvent* event = message;
|
||||||
|
|
||||||
if(event->type == StorageEventTypeCardMount) {
|
if(event->type == StorageEventTypeCardMount) {
|
||||||
CliShellStorageEvent cli_event = CliShellStorageEventMount;
|
cli_shell_signal_storage_event(cli_shell, CliShellStorageEventMount);
|
||||||
furi_check(
|
|
||||||
furi_message_queue_put(cli_shell->storage_event_queue, &cli_event, 0) == FuriStatusOk);
|
|
||||||
} else if(event->type == StorageEventTypeCardUnmount) {
|
} else if(event->type == StorageEventTypeCardUnmount) {
|
||||||
CliShellStorageEvent cli_event = CliShellStorageEventUnmount;
|
cli_shell_signal_storage_event(cli_shell, CliShellStorageEventUnmount);
|
||||||
furi_check(
|
|
||||||
furi_message_queue_put(cli_shell->storage_event_queue, &cli_event, 0) == FuriStatusOk);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cli_shell_storage_internal_event(FuriEventLoopObject* object, void* context) {
|
static void cli_shell_storage_internal_event(FuriEventLoopObject* object, void* context) {
|
||||||
CliShell* cli_shell = context;
|
CliShell* cli_shell = context;
|
||||||
FuriMessageQueue* queue = object;
|
FuriEventFlag* event_flag = object;
|
||||||
CliShellStorageEvent event;
|
CliShellStorageEvent event =
|
||||||
furi_check(furi_message_queue_get(queue, &event, 0) == FuriStatusOk);
|
furi_event_flag_wait(event_flag, FuriFlagWaitAll, FuriFlagWaitAny, 0);
|
||||||
|
furi_check(!(event & FuriFlagError));
|
||||||
|
|
||||||
if(event == CliShellStorageEventMount) {
|
if(event & CliShellStorageEventUnmount) {
|
||||||
cli_registry_reload_external_commands(cli_shell->registry, cli_shell->ext_config);
|
|
||||||
} else if(event == CliShellStorageEventUnmount) {
|
|
||||||
cli_registry_remove_external_commands(cli_shell->registry);
|
cli_registry_remove_external_commands(cli_shell->registry);
|
||||||
|
} else if(event & CliShellStorageEventMount) {
|
||||||
|
cli_registry_reload_external_commands(cli_shell->registry, cli_shell->ext_config);
|
||||||
} else {
|
} else {
|
||||||
furi_crash();
|
furi_crash();
|
||||||
}
|
}
|
||||||
@@ -377,25 +382,26 @@ static void cli_shell_init(CliShell* shell) {
|
|||||||
shell->ansi_parsing_timer = furi_event_loop_timer_alloc(
|
shell->ansi_parsing_timer = furi_event_loop_timer_alloc(
|
||||||
shell->event_loop, cli_shell_timer_expired, FuriEventLoopTimerTypeOnce, shell);
|
shell->event_loop, cli_shell_timer_expired, FuriEventLoopTimerTypeOnce, shell);
|
||||||
|
|
||||||
shell->storage_event_queue = furi_message_queue_alloc(1, sizeof(CliShellStorageEvent));
|
shell->storage.event_flag = furi_event_flag_alloc();
|
||||||
furi_event_loop_subscribe_message_queue(
|
furi_event_loop_subscribe_event_flag(
|
||||||
shell->event_loop,
|
shell->event_loop,
|
||||||
shell->storage_event_queue,
|
shell->storage.event_flag,
|
||||||
FuriEventLoopEventIn,
|
FuriEventLoopEventIn,
|
||||||
cli_shell_storage_internal_event,
|
cli_shell_storage_internal_event,
|
||||||
shell);
|
shell);
|
||||||
shell->storage = furi_record_open(RECORD_STORAGE);
|
shell->storage.storage = furi_record_open(RECORD_STORAGE);
|
||||||
shell->storage_subscription =
|
shell->storage.subscription = furi_pubsub_subscribe(
|
||||||
furi_pubsub_subscribe(storage_get_pubsub(shell->storage), cli_shell_storage_event, shell);
|
storage_get_pubsub(shell->storage.storage), cli_shell_storage_event, shell);
|
||||||
|
|
||||||
cli_shell_install_pipe(shell);
|
cli_shell_install_pipe(shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cli_shell_deinit(CliShell* shell) {
|
static void cli_shell_deinit(CliShell* shell) {
|
||||||
furi_pubsub_unsubscribe(storage_get_pubsub(shell->storage), shell->storage_subscription);
|
furi_pubsub_unsubscribe(
|
||||||
|
storage_get_pubsub(shell->storage.storage), shell->storage.subscription);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
furi_event_loop_unsubscribe(shell->event_loop, shell->storage_event_queue);
|
furi_event_loop_unsubscribe(shell->event_loop, shell->storage.event_flag);
|
||||||
furi_message_queue_free(shell->storage_event_queue);
|
furi_event_flag_free(shell->storage.event_flag);
|
||||||
|
|
||||||
cli_shell_completions_free(shell->components[CliShellComponentCompletions]);
|
cli_shell_completions_free(shell->components[CliShellComponentCompletions]);
|
||||||
cli_shell_line_free(shell->components[CliShellComponentLine]);
|
cli_shell_line_free(shell->components[CliShellComponentLine]);
|
||||||
|
|||||||
Reference in New Issue
Block a user