mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-11 06:09:08 -07:00
Move config file migration to flipper init
This commit is contained in:
@@ -126,10 +126,6 @@ Bt* bt_alloc() {
|
||||
bt_settings_save(&bt->bt_settings);
|
||||
}
|
||||
// Keys storage
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_copy(storage, BT_KEYS_STORAGE_OLD_PATH, BT_KEYS_STORAGE_PATH);
|
||||
storage_common_remove(storage, BT_KEYS_STORAGE_OLD_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
bt->keys_storage = bt_keys_storage_alloc(BT_KEYS_STORAGE_PATH);
|
||||
// Alloc queue
|
||||
bt->message_queue = furi_message_queue_alloc(8, sizeof(BtMessage));
|
||||
|
||||
@@ -4,31 +4,14 @@
|
||||
#include <lib/toolbox/saved_struct.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
#define BT_SETTINGS_OLD_PATH INT_PATH(".bt.settings")
|
||||
#define BT_SETTINGS_PATH CFG_PATH("bt.settings")
|
||||
#define BT_SETTINGS_VERSION (0)
|
||||
#define BT_SETTINGS_MAGIC (0x19)
|
||||
|
||||
bool bt_settings_load(BtSettings* bt_settings) {
|
||||
furi_assert(bt_settings);
|
||||
|
||||
bool ret = saved_struct_load(
|
||||
return saved_struct_load(
|
||||
BT_SETTINGS_PATH, bt_settings, sizeof(BtSettings), BT_SETTINGS_MAGIC, BT_SETTINGS_VERSION);
|
||||
|
||||
if(!ret) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_copy(storage, BT_SETTINGS_OLD_PATH, BT_SETTINGS_PATH);
|
||||
storage_common_remove(storage, BT_SETTINGS_OLD_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
ret = saved_struct_load(
|
||||
BT_SETTINGS_PATH,
|
||||
bt_settings,
|
||||
sizeof(BtSettings),
|
||||
BT_SETTINGS_MAGIC,
|
||||
BT_SETTINGS_VERSION);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool bt_settings_save(BtSettings* bt_settings) {
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BT_SETTINGS_OLD_PATH INT_PATH(".bt.settings")
|
||||
#define BT_SETTINGS_PATH CFG_PATH("bt.settings")
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
} BtSettings;
|
||||
|
||||
@@ -10,25 +10,10 @@ bool DESKTOP_SETTINGS_SAVE(DesktopSettings* x) {
|
||||
}
|
||||
|
||||
bool DESKTOP_SETTINGS_LOAD(DesktopSettings* x) {
|
||||
bool ret = saved_struct_load(
|
||||
return saved_struct_load(
|
||||
DESKTOP_SETTINGS_PATH,
|
||||
x,
|
||||
sizeof(DesktopSettings),
|
||||
DESKTOP_SETTINGS_MAGIC,
|
||||
DESKTOP_SETTINGS_VER);
|
||||
|
||||
if(!ret) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_copy(storage, DESKTOP_SETTINGS_OLD_PATH, DESKTOP_SETTINGS_PATH);
|
||||
storage_common_remove(storage, DESKTOP_SETTINGS_OLD_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
ret = saved_struct_load(
|
||||
DESKTOP_SETTINGS_PATH,
|
||||
x,
|
||||
sizeof(DesktopSettings),
|
||||
DESKTOP_SETTINGS_MAGIC,
|
||||
DESKTOP_SETTINGS_VER);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
#define TAG "DolphinState"
|
||||
|
||||
#define DOLPHIN_STATE_OLD_PATH INT_PATH(".dolphin.state")
|
||||
#define DOLPHIN_STATE_PATH CFG_PATH("dolphin.state")
|
||||
#define DOLPHIN_STATE_HEADER_MAGIC 0xD0
|
||||
#define DOLPHIN_STATE_HEADER_VERSION 0x01
|
||||
|
||||
@@ -61,19 +59,6 @@ bool dolphin_state_load(DolphinState* dolphin_state) {
|
||||
DOLPHIN_STATE_HEADER_MAGIC,
|
||||
DOLPHIN_STATE_HEADER_VERSION);
|
||||
|
||||
if(!success) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_copy(storage, DOLPHIN_STATE_OLD_PATH, DOLPHIN_STATE_PATH);
|
||||
storage_common_remove(storage, DOLPHIN_STATE_OLD_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
success = saved_struct_load(
|
||||
DOLPHIN_STATE_PATH,
|
||||
&dolphin_state->data,
|
||||
sizeof(DolphinStoreData),
|
||||
DOLPHIN_STATE_HEADER_MAGIC,
|
||||
DOLPHIN_STATE_HEADER_VERSION);
|
||||
}
|
||||
|
||||
if(success) {
|
||||
if((dolphin_state->data.butthurt > BUTTHURT_MAX) ||
|
||||
(dolphin_state->data.butthurt < BUTTHURT_MIN)) {
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DOLPHIN_STATE_OLD_PATH INT_PATH(".dolphin.state")
|
||||
#define DOLPHIN_STATE_PATH CFG_PATH("dolphin.state")
|
||||
|
||||
#define DOLPHIN_LEVEL_COUNT 29
|
||||
|
||||
typedef struct DolphinState DolphinState;
|
||||
|
||||
@@ -421,27 +421,12 @@ static bool notification_save_settings(NotificationApp* app) {
|
||||
}
|
||||
|
||||
static bool notification_load_settings(NotificationApp* app) {
|
||||
bool ret = saved_struct_load(
|
||||
return saved_struct_load(
|
||||
NOTIFICATION_SETTINGS_PATH,
|
||||
&app->settings,
|
||||
sizeof(NotificationSettings),
|
||||
NOTIFICATION_SETTINGS_MAGIC,
|
||||
NOTIFICATION_SETTINGS_VERSION);
|
||||
|
||||
if(!ret) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_copy(storage, NOTIFICATION_SETTINGS_OLD_PATH, NOTIFICATION_SETTINGS_PATH);
|
||||
storage_common_remove(storage, NOTIFICATION_SETTINGS_OLD_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
ret = saved_struct_load(
|
||||
NOTIFICATION_SETTINGS_PATH,
|
||||
&app->settings,
|
||||
sizeof(NotificationSettings),
|
||||
NOTIFICATION_SETTINGS_MAGIC,
|
||||
NOTIFICATION_SETTINGS_VERSION);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void input_event_callback(const void* value, void* context) {
|
||||
|
||||
@@ -6,17 +6,6 @@ bool SAVE_POWER_SETTINGS(uint32_t* x) {
|
||||
}
|
||||
|
||||
bool LOAD_POWER_SETTINGS(uint32_t* x) {
|
||||
bool ret = saved_struct_load(
|
||||
return saved_struct_load(
|
||||
POWER_SETTINGS_PATH, x, sizeof(uint32_t), POWER_SETTINGS_MAGIC, POWER_SETTINGS_VER);
|
||||
|
||||
if(!ret) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_copy(storage, POWER_SETTINGS_OLD_PATH, POWER_SETTINGS_PATH);
|
||||
storage_common_remove(storage, POWER_SETTINGS_OLD_PATH);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
ret = saved_struct_load(
|
||||
POWER_SETTINGS_PATH, x, sizeof(uint32_t), POWER_SETTINGS_MAGIC, POWER_SETTINGS_VER);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user