mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-31 02:23:04 -07:00
Storage: remove LFS (#3577)
* Storage: drop internal storage * Storage: rollback some unnecessary changes * Storage: rollback some unnecessary changes part 2 * Storage: cleanup various defines and int handling. Ble: allow short connection interval if internal flash is not used. * Storage: do not return storage if it is not ready * Save PIN code to RTC, update settings * Simplify the code, clean up includes * Rearrange some code * apps: storage_move_to_sd: conditionally enable with --extra-define=STORAGE_INT_ON_LFS * Load Desktop settings automatically * Redirect /any to /ext * Abolish storage_move_to_sd app * Remove as many mentions of ANY_PATH as possible * Fix desktop settings wrongly not loading * Improve desktop settings handling and strings * Load BLE settings and keys automatically * Improve BLE configuration procedure * Do not load bluetooth keys twice if they were already loaded * Load dolphin state automatically * Fix merge artifact * Load notification settings automatically * Update desktop settings strings * Load expansion settings automatically * Do not use thread signals to reload desktop settings * Load region data automatically, separate to its own hook * Improve ble behaviour with no keys * Fix Dolphin state not resetting correctly * Add a status check * Make Desktop save its own settings * Check result when taking and releasing mutex * Improve default thread signal handling in FuriEventLoop * Make bt service in charge of saving settings, add settings api * Fix a deadlock due to timer thread not receiving time * Lock core2 when reinitialising bt * Update clang-format * Revert "Update clang-format" This reverts commit d61295ac063c6ec879375ceeab54d6ff2c90a9a1. * Format sources with clang-format * Revert old stack size for desktop settings * Allocate big struct dynamically * Simplify PIN comparison * Save pointer to storage in Desktop object * Fix region provisioning for hardware regions * Remove stale TODO + siimplify code * Clean up region.c * Use sizeof instead of macro define * Limit PIN length to 10 for consistency * Emit a warning upon usage of /any * Add delay after finding flipper * Remove unnecessary delay * Remove all mentions of STORAGE_INT_ON_LFS * Remove littlefs and internal storage * Remove all possible LittleFS mentions * Fix browser tab in Archive * Ble: fix connection interval explanation * Bump API Symbols * BLE: Update comments interval connection comments * Storage: clear FuriHalRtcFlagStorageFormatInternal if set --------- Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com> Co-authored-by: hedger <hedger@nanode.su> Co-authored-by: Georgii Surkov <37121527+gsurkov@users.noreply.github.com>
This commit is contained in:
@@ -15,8 +15,6 @@ static bool bt_settings_back_event_callback(void* context) {
|
||||
BtSettingsApp* bt_settings_app_alloc(void) {
|
||||
BtSettingsApp* app = malloc(sizeof(BtSettingsApp));
|
||||
|
||||
// Load settings
|
||||
bt_settings_load(&app->settings);
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->bt = furi_record_open(RECORD_BT);
|
||||
|
||||
@@ -48,6 +46,8 @@ BtSettingsApp* bt_settings_app_alloc(void) {
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, BtSettingsAppViewPopup, popup_get_view(app->popup));
|
||||
|
||||
bt_get_settings(app->bt, &app->settings);
|
||||
|
||||
// Set first scene
|
||||
scene_manager_next_scene(app->scene_manager, BtSettingsAppSceneStart);
|
||||
return app;
|
||||
@@ -55,6 +55,7 @@ BtSettingsApp* bt_settings_app_alloc(void) {
|
||||
|
||||
void bt_settings_app_free(BtSettingsApp* app) {
|
||||
furi_assert(app);
|
||||
bt_set_settings(app->bt, &app->settings);
|
||||
// Gui modules
|
||||
view_dispatcher_remove_view(app->view_dispatcher, BtSettingsAppViewVarItemList);
|
||||
variable_item_list_free(app->var_item_list);
|
||||
@@ -79,7 +80,6 @@ extern int32_t bt_settings_app(void* p) {
|
||||
UNUSED(p);
|
||||
BtSettingsApp* app = bt_settings_app_alloc();
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
bt_settings_save(&app->settings);
|
||||
bt_settings_app_free(app);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include <bt/bt_service/bt.h>
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <assets_icons.h>
|
||||
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/modules/popup.h>
|
||||
|
||||
#include <bt/bt_settings.h>
|
||||
#include <bt/bt_service/bt.h>
|
||||
#include <bt/bt_service/bt_settings_api_i.h>
|
||||
|
||||
#include <assets_icons.h>
|
||||
|
||||
#include "scenes/bt_settings_scene.h"
|
||||
|
||||
enum BtSettingsCustomEvent {
|
||||
|
||||
@@ -70,18 +70,17 @@ bool bt_settings_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == BtSettingOn) {
|
||||
furi_hal_bt_start_advertising();
|
||||
app->settings.enabled = true;
|
||||
consumed = true;
|
||||
} else if(event.event == BtSettingOff) {
|
||||
app->settings.enabled = false;
|
||||
furi_hal_bt_stop_advertising();
|
||||
consumed = true;
|
||||
} else if(event.event == BtSettingsCustomEventForgetDevices) {
|
||||
scene_manager_next_scene(app->scene_manager, BtSettingsAppSceneForgetDevConfirm);
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
#include <gui/modules/popup.h>
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
#include <desktop/desktop.h>
|
||||
#include <desktop/views/desktop_view_pin_input.h>
|
||||
|
||||
#include "desktop_settings_app.h"
|
||||
#include "scenes/desktop_settings_scene.h"
|
||||
#include <desktop/views/desktop_view_pin_input.h>
|
||||
|
||||
static bool desktop_settings_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
@@ -90,18 +92,20 @@ void desktop_settings_app_free(DesktopSettingsApp* app) {
|
||||
}
|
||||
|
||||
extern int32_t desktop_settings_app(void* p) {
|
||||
DesktopSettingsApp* app = desktop_settings_app_alloc();
|
||||
DESKTOP_SETTINGS_LOAD(&app->settings);
|
||||
UNUSED(p);
|
||||
|
||||
if(p && (strcmp(p, DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG) == 0)) {
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinSetupHowto);
|
||||
} else {
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneStart);
|
||||
}
|
||||
DesktopSettingsApp* app = desktop_settings_app_alloc();
|
||||
Desktop* desktop = furi_record_open(RECORD_DESKTOP);
|
||||
|
||||
desktop_api_get_settings(desktop, &app->settings);
|
||||
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppSceneStart);
|
||||
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
desktop_api_set_settings(desktop, &app->settings);
|
||||
furi_record_close(RECORD_DESKTOP);
|
||||
|
||||
desktop_settings_app_free(app);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct {
|
||||
DesktopSettingsViewPinSetupHowto* pin_setup_howto_view;
|
||||
DesktopSettingsViewPinSetupHowto2* pin_setup_howto2_view;
|
||||
|
||||
PinCode pincode_buffer;
|
||||
DesktopPinCode pincode_buffer;
|
||||
bool pincode_buffer_filled;
|
||||
|
||||
uint32_t pin_menu_idx;
|
||||
|
||||
@@ -212,13 +212,17 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
||||
strncpy(
|
||||
curr_favorite_app->name_or_path,
|
||||
furi_string_get_cstr(temp_path),
|
||||
MAX_APP_LENGTH);
|
||||
sizeof(curr_favorite_app->name_or_path));
|
||||
consumed = true;
|
||||
}
|
||||
} else {
|
||||
size_t app_index = event.event - 2;
|
||||
const char* name = favorite_fap_get_app_name(app_index);
|
||||
if(name) strncpy(curr_favorite_app->name_or_path, name, MAX_APP_LENGTH);
|
||||
if(name)
|
||||
strncpy(
|
||||
curr_favorite_app->name_or_path,
|
||||
name,
|
||||
sizeof(curr_favorite_app->name_or_path));
|
||||
consumed = true;
|
||||
}
|
||||
if(consumed) {
|
||||
@@ -226,7 +230,7 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
|
||||
};
|
||||
consumed = true;
|
||||
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
desktop_settings_save(&app->settings);
|
||||
}
|
||||
|
||||
furi_string_free(temp_path);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <core/check.h>
|
||||
#include <gui/scene_manager.h>
|
||||
#include <desktop/helpers/pin.h>
|
||||
#include <desktop/helpers/pin_code.h>
|
||||
#include "../desktop_settings_app.h"
|
||||
#include <desktop/desktop_settings.h>
|
||||
#include <desktop/views/desktop_view_pin_input.h>
|
||||
@@ -12,13 +12,14 @@
|
||||
#define SCENE_EVENT_PINS_EQUAL (1U)
|
||||
#define SCENE_EVENT_PINS_DIFFERENT (2U)
|
||||
|
||||
static void pin_auth_done_callback(const PinCode* pin_code, void* context) {
|
||||
static void pin_auth_done_callback(const DesktopPinCode* pin_code, void* context) {
|
||||
furi_assert(pin_code);
|
||||
furi_assert(context);
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
DesktopSettingsApp* app = context;
|
||||
app->pincode_buffer = *pin_code;
|
||||
if(desktop_pin_compare(&app->settings.pin_code, pin_code)) {
|
||||
|
||||
if(desktop_pin_code_check(pin_code)) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL);
|
||||
} else {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT);
|
||||
@@ -31,10 +32,9 @@ static void pin_auth_back_callback(void* context) {
|
||||
}
|
||||
|
||||
void desktop_settings_scene_pin_auth_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
furi_assert(desktop_pin_code_is_set());
|
||||
|
||||
DESKTOP_SETTINGS_LOAD(&app->settings);
|
||||
furi_assert(app->settings.pin_code.length > 0);
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
desktop_view_pin_input_set_context(app->pin_input_view, app);
|
||||
desktop_view_pin_input_set_back_callback(app->pin_input_view, pin_auth_back_callback);
|
||||
|
||||
@@ -17,9 +17,8 @@ static void pin_disable_back_callback(void* context) {
|
||||
void desktop_settings_scene_pin_disable_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
DesktopSettingsApp* app = context;
|
||||
app->settings.pin_code.length = 0;
|
||||
memset(app->settings.pin_code.data, '0', sizeof(app->settings.pin_code.data));
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
|
||||
desktop_pin_code_reset();
|
||||
|
||||
popup_set_context(app->popup, app);
|
||||
popup_set_callback(app->popup, pin_disable_back_callback);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <desktop/views/desktop_view_pin_input.h>
|
||||
#include "desktop_settings_scene.h"
|
||||
#include "desktop_settings_scene_i.h"
|
||||
#include <desktop/helpers/pin.h>
|
||||
#include <desktop/helpers/pin_code.h>
|
||||
#include "../desktop_settings_app.h"
|
||||
|
||||
#define SCENE_EVENT_EXIT (0U)
|
||||
@@ -17,7 +17,7 @@ static void pin_error_back_callback(void* context) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_EXIT);
|
||||
}
|
||||
|
||||
static void pin_error_done_callback(const PinCode* pin_code, void* context) {
|
||||
static void pin_error_done_callback(const DesktopPinCode* pin_code, void* context) {
|
||||
UNUSED(pin_code);
|
||||
furi_assert(context);
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
@@ -19,7 +19,7 @@ void desktop_settings_scene_pin_menu_on_enter(void* context) {
|
||||
Submenu* submenu = app->submenu;
|
||||
submenu_reset(submenu);
|
||||
|
||||
if(!app->settings.pin_code.length) {
|
||||
if(!desktop_pin_code_is_set()) {
|
||||
submenu_add_item(
|
||||
submenu,
|
||||
"Set PIN",
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include <desktop/views/desktop_view_pin_input.h>
|
||||
#include "desktop_settings_scene.h"
|
||||
#include "desktop_settings_scene_i.h"
|
||||
#include <desktop/helpers/pin.h>
|
||||
#include <desktop/helpers/pin_code.h>
|
||||
|
||||
#define SCENE_EVENT_EXIT (0U)
|
||||
#define SCENE_EVENT_1ST_PIN_ENTERED (1U)
|
||||
#define SCENE_EVENT_PINS_EQUAL (2U)
|
||||
#define SCENE_EVENT_PINS_DIFFERENT (3U)
|
||||
|
||||
static void pin_setup_done_callback(const PinCode* pin_code, void* context) {
|
||||
static void pin_setup_done_callback(const DesktopPinCode* pin_code, void* context) {
|
||||
furi_assert(pin_code);
|
||||
furi_assert(context);
|
||||
DesktopSettingsApp* app = context;
|
||||
@@ -25,7 +25,7 @@ static void pin_setup_done_callback(const PinCode* pin_code, void* context) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_1ST_PIN_ENTERED);
|
||||
} else {
|
||||
app->pincode_buffer_filled = false;
|
||||
if(desktop_pin_compare(&app->pincode_buffer, pin_code)) {
|
||||
if(desktop_pin_code_is_equal(&app->pincode_buffer, pin_code)) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL);
|
||||
} else {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT);
|
||||
|
||||
+4
-4
@@ -11,7 +11,7 @@
|
||||
|
||||
#define SCENE_EVENT_DONE (0U)
|
||||
|
||||
static void pin_setup_done_callback(const PinCode* pin_code, void* context) {
|
||||
static void pin_setup_done_callback(const DesktopPinCode* pin_code, void* context) {
|
||||
furi_assert(pin_code);
|
||||
furi_assert(context);
|
||||
DesktopSettingsApp* app = context;
|
||||
@@ -22,8 +22,8 @@ static void pin_setup_done_callback(const PinCode* pin_code, void* context) {
|
||||
void desktop_settings_scene_pin_setup_done_on_enter(void* context) {
|
||||
DesktopSettingsApp* app = context;
|
||||
|
||||
app->settings.pin_code = app->pincode_buffer;
|
||||
DESKTOP_SETTINGS_SAVE(&app->settings);
|
||||
desktop_pin_code_set(&app->pincode_buffer);
|
||||
|
||||
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
|
||||
notification_message(notification, &sequence_single_vibro);
|
||||
notification_message(notification, &sequence_blink_green_10);
|
||||
@@ -32,7 +32,7 @@ void desktop_settings_scene_pin_setup_done_on_enter(void* context) {
|
||||
desktop_view_pin_input_set_context(app->pin_input_view, app);
|
||||
desktop_view_pin_input_set_back_callback(app->pin_input_view, NULL);
|
||||
desktop_view_pin_input_set_done_callback(app->pin_input_view, pin_setup_done_callback);
|
||||
desktop_view_pin_input_set_pin(app->pin_input_view, &app->settings.pin_code);
|
||||
desktop_view_pin_input_set_pin(app->pin_input_view, &app->pincode_buffer);
|
||||
desktop_view_pin_input_set_label_button(app->pin_input_view, "Done");
|
||||
desktop_view_pin_input_set_label_primary(app->pin_input_view, 29, 8, "PIN Activated!");
|
||||
desktop_view_pin_input_set_label_secondary(
|
||||
|
||||
@@ -27,9 +27,7 @@ static uint32_t expansion_settings_app_exit(void* context) {
|
||||
static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
|
||||
ExpansionSettingsApp* app = malloc(sizeof(ExpansionSettingsApp));
|
||||
|
||||
if(!expansion_settings_load(&app->settings)) {
|
||||
expansion_settings_save(&app->settings);
|
||||
}
|
||||
expansion_settings_load(&app->settings);
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->expansion = furi_record_open(RECORD_EXPANSION);
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ void storage_settings_scene_internal_info_on_enter(void* context) {
|
||||
} else {
|
||||
furi_string_printf(
|
||||
app->text_string,
|
||||
"Name: %s\nType: LittleFS\nTotal: %lu KiB\nFree: %lu KiB",
|
||||
"Name: %s\nType: Virtual\nTotal: %lu KiB\nFree: %lu KiB",
|
||||
furi_hal_version_get_name_ptr() ? furi_hal_version_get_name_ptr() : "Unknown",
|
||||
(uint32_t)(total_space / 1024),
|
||||
(uint32_t)(free_space / 1024));
|
||||
|
||||
Reference in New Issue
Block a user