mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 22:28:36 -07:00
Store main settings in dedicated ext folder
This commit is contained in:
@@ -140,6 +140,13 @@ bool archive_favorites_read(void* context) {
|
|||||||
|
|
||||||
bool result = storage_file_open(file, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
|
bool result = storage_file_open(file, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
|
||||||
|
|
||||||
|
if(!result) {
|
||||||
|
storage_file_close(file);
|
||||||
|
storage_common_copy(storage, ARCHIVE_FAV_OLD_PATH, ARCHIVE_FAV_PATH);
|
||||||
|
storage_common_remove(storage, ARCHIVE_FAV_OLD_PATH);
|
||||||
|
result = storage_file_open(file, ARCHIVE_FAV_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
|
||||||
|
}
|
||||||
|
|
||||||
if(result) {
|
if(result) {
|
||||||
while(1) {
|
while(1) {
|
||||||
if(!archive_favorites_read_line(file, buffer)) {
|
if(!archive_favorites_read_line(file, buffer)) {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
|
|
||||||
#define ARCHIVE_FAV_PATH ANY_PATH("favorites.txt")
|
#define ARCHIVE_FAV_OLD_PATH EXT_PATH("favorites.txt")
|
||||||
#define ARCHIVE_FAV_TEMP_PATH ANY_PATH("favorites.tmp")
|
#define ARCHIVE_FAV_PATH CFG_PATH("favorites.txt")
|
||||||
|
#define ARCHIVE_FAV_TEMP_PATH CFG_PATH("favorites.tmp")
|
||||||
|
|
||||||
uint16_t archive_favorites_count(void* context);
|
uint16_t archive_favorites_count(void* context);
|
||||||
bool archive_favorites_read(void* context);
|
bool archive_favorites_read(void* context);
|
||||||
|
|||||||
@@ -18,10 +18,8 @@
|
|||||||
#include <bt/bt_settings.h>
|
#include <bt/bt_settings.h>
|
||||||
#include <bt/bt_service/bt_keys_storage.h>
|
#include <bt/bt_service/bt_keys_storage.h>
|
||||||
|
|
||||||
#include "bt_keys_filename.h"
|
#define BT_KEYS_STORAGE_OLD_PATH INT_PATH(".bt.keys")
|
||||||
|
#define BT_KEYS_STORAGE_PATH CFG_PATH("bt.keys")
|
||||||
#define BT_KEYS_STORAGE_OLD_PATH INT_PATH(BT_KEYS_STORAGE_FILE_NAME)
|
|
||||||
#define BT_KEYS_STORAGE_PATH EXT_PATH(BT_KEYS_STORAGE_FILE_NAME)
|
|
||||||
|
|
||||||
#define BT_API_UNLOCK_EVENT (1UL << 0)
|
#define BT_API_UNLOCK_EVENT (1UL << 0)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define BT_KEYS_STORAGE_FILE_NAME ".bt.keys"
|
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
#include <lib/toolbox/saved_struct.h>
|
#include <lib/toolbox/saved_struct.h>
|
||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
|
|
||||||
#define BT_SETTINGS_OLD_PATH INT_PATH(BT_SETTINGS_FILE_NAME)
|
#define BT_SETTINGS_OLD_PATH INT_PATH(".bt.settings")
|
||||||
#define BT_SETTINGS_PATH EXT_PATH(BT_SETTINGS_FILE_NAME)
|
#define BT_SETTINGS_PATH CFG_PATH("bt.settings")
|
||||||
#define BT_SETTINGS_VERSION (0)
|
#define BT_SETTINGS_VERSION (0)
|
||||||
#define BT_SETTINGS_MAGIC (0x19)
|
#define BT_SETTINGS_MAGIC (0x19)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "bt_settings_filename.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -19,4 +17,4 @@ bool bt_settings_save(BtSettings* bt_settings);
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define BT_SETTINGS_FILE_NAME ".bt.settings"
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "desktop_settings_filename.h"
|
|
||||||
|
|
||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -11,8 +9,8 @@
|
|||||||
|
|
||||||
#define DESKTOP_SETTINGS_VER (7)
|
#define DESKTOP_SETTINGS_VER (7)
|
||||||
|
|
||||||
#define DESKTOP_SETTINGS_OLD_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
|
#define DESKTOP_SETTINGS_OLD_PATH INT_PATH(".desktop.settings")
|
||||||
#define DESKTOP_SETTINGS_PATH EXT_PATH(DESKTOP_SETTINGS_FILE_NAME)
|
#define DESKTOP_SETTINGS_PATH CFG_PATH("desktop.settings")
|
||||||
#define DESKTOP_SETTINGS_MAGIC (0x17)
|
#define DESKTOP_SETTINGS_MAGIC (0x17)
|
||||||
#define PIN_MAX_LENGTH 12
|
#define PIN_MAX_LENGTH 12
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define DESKTOP_SETTINGS_FILE_NAME ".desktop.settings"
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "dolphin_state.h"
|
#include "dolphin_state.h"
|
||||||
#include "dolphin/helpers/dolphin_deed.h"
|
#include "dolphin/helpers/dolphin_deed.h"
|
||||||
#include "dolphin_state_filename.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
@@ -11,8 +10,8 @@
|
|||||||
|
|
||||||
#define TAG "DolphinState"
|
#define TAG "DolphinState"
|
||||||
|
|
||||||
#define DOLPHIN_STATE_OLD_PATH INT_PATH(DOLPHIN_STATE_FILE_NAME)
|
#define DOLPHIN_STATE_OLD_PATH INT_PATH(".dolphin.state")
|
||||||
#define DOLPHIN_STATE_PATH EXT_PATH(DOLPHIN_STATE_FILE_NAME)
|
#define DOLPHIN_STATE_PATH CFG_PATH("dolphin.state")
|
||||||
#define DOLPHIN_STATE_HEADER_MAGIC 0xD0
|
#define DOLPHIN_STATE_HEADER_MAGIC 0xD0
|
||||||
#define DOLPHIN_STATE_HEADER_VERSION 0x01
|
#define DOLPHIN_STATE_HEADER_VERSION 0x01
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define DOLPHIN_STATE_FILE_NAME ".dolphin.state"
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
#include <toolbox/saved_struct.h>
|
#include <toolbox/saved_struct.h>
|
||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
#include "power_settings_filename.h"
|
|
||||||
|
|
||||||
#define POWER_SETTINGS_VER (1)
|
#define POWER_SETTINGS_VER (1)
|
||||||
|
|
||||||
#define POWER_SETTINGS_OLD_PATH INT_PATH(POWER_SETTINGS_FILE_NAME)
|
#define POWER_SETTINGS_OLD_PATH INT_PATH(".power.settings")
|
||||||
#define POWER_SETTINGS_PATH EXT_PATH(POWER_SETTINGS_FILE_NAME)
|
#define POWER_SETTINGS_PATH CFG_PATH("power.settings")
|
||||||
#define POWER_SETTINGS_MAGIC (0x21)
|
#define POWER_SETTINGS_MAGIC (0x21)
|
||||||
|
|
||||||
bool SAVE_POWER_SETTINGS(uint32_t* x);
|
bool SAVE_POWER_SETTINGS(uint32_t* x);
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define POWER_SETTINGS_FILE_NAME ".power.settings"
|
|
||||||
@@ -21,8 +21,7 @@
|
|||||||
#include <storage/storage.h>
|
#include <storage/storage.h>
|
||||||
|
|
||||||
#define RGB_BACKLIGHT_SETTINGS_VERSION 5
|
#define RGB_BACKLIGHT_SETTINGS_VERSION 5
|
||||||
#define RGB_BACKLIGHT_SETTINGS_FILE_NAME ".rgb_backlight.settings"
|
#define RGB_BACKLIGHT_SETTINGS_PATH CFG_PATH("rgb_backlight.settings")
|
||||||
#define RGB_BACKLIGHT_SETTINGS_PATH EXT_PATH(RGB_BACKLIGHT_SETTINGS_FILE_NAME)
|
|
||||||
|
|
||||||
#define COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightColor))
|
#define COLOR_COUNT (sizeof(colors) / sizeof(RGBBacklightColor))
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ extern "C" {
|
|||||||
#define STORAGE_ANY_PATH_PREFIX "/any"
|
#define STORAGE_ANY_PATH_PREFIX "/any"
|
||||||
#define STORAGE_APP_DATA_PATH_PREFIX "/data"
|
#define STORAGE_APP_DATA_PATH_PREFIX "/data"
|
||||||
#define STORAGE_APP_ASSETS_PATH_PREFIX "/assets"
|
#define STORAGE_APP_ASSETS_PATH_PREFIX "/assets"
|
||||||
|
#define STORAGE_CFG_PATH_PREFIX STORAGE_EXT_PATH_PREFIX "/.config"
|
||||||
|
|
||||||
#define INT_PATH(path) STORAGE_INT_PATH_PREFIX "/" path
|
#define INT_PATH(path) STORAGE_INT_PATH_PREFIX "/" path
|
||||||
#define EXT_PATH(path) STORAGE_EXT_PATH_PREFIX "/" path
|
#define EXT_PATH(path) STORAGE_EXT_PATH_PREFIX "/" path
|
||||||
#define ANY_PATH(path) STORAGE_ANY_PATH_PREFIX "/" path
|
#define ANY_PATH(path) STORAGE_ANY_PATH_PREFIX "/" path
|
||||||
#define APP_DATA_PATH(path) STORAGE_APP_DATA_PATH_PREFIX "/" path
|
#define APP_DATA_PATH(path) STORAGE_APP_DATA_PATH_PREFIX "/" path
|
||||||
#define APP_ASSETS_PATH(path) STORAGE_APP_ASSETS_PATH_PREFIX "/" path
|
#define APP_ASSETS_PATH(path) STORAGE_APP_ASSETS_PATH_PREFIX "/" path
|
||||||
|
#define CFG_PATH(path) STORAGE_CFG_PATH_PREFIX "/" path
|
||||||
|
|
||||||
#define RECORD_STORAGE "storage"
|
#define RECORD_STORAGE "storage"
|
||||||
|
|
||||||
|
|||||||
@@ -500,6 +500,14 @@ void storage_process_alias(
|
|||||||
furi_string_get_cstr(apps_assets_path_with_appsid));
|
furi_string_get_cstr(apps_assets_path_with_appsid));
|
||||||
|
|
||||||
furi_string_free(apps_assets_path_with_appsid);
|
furi_string_free(apps_assets_path_with_appsid);
|
||||||
|
} else if(furi_string_start_with(path, STORAGE_CFG_PATH_PREFIX)) {
|
||||||
|
// Create config folder if it doesn't exist
|
||||||
|
FuriString* config_path = furi_string_alloc_set(STORAGE_CFG_PATH_PREFIX);
|
||||||
|
if(create_folders &&
|
||||||
|
storage_process_common_stat(app, config_path, NULL) != FSE_OK) {
|
||||||
|
storage_process_common_mkdir(app, config_path);
|
||||||
|
}
|
||||||
|
furi_string_free(config_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,13 +27,23 @@ void XTREME_SETTINGS_LOAD() {
|
|||||||
sizeof(XtremeSettings),
|
sizeof(XtremeSettings),
|
||||||
XTREME_SETTINGS_MAGIC,
|
XTREME_SETTINGS_MAGIC,
|
||||||
XTREME_SETTINGS_VERSION);
|
XTREME_SETTINGS_VERSION);
|
||||||
|
if(!loaded) {
|
||||||
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
|
storage_common_copy(storage, XTREME_SETTINGS_OLD_PATH, XTREME_SETTINGS_PATH);
|
||||||
|
storage_common_copy(storage, XTREME_SETTINGS_OLD_INT_PATH, XTREME_SETTINGS_PATH);
|
||||||
|
storage_common_remove(storage, XTREME_SETTINGS_OLD_PATH);
|
||||||
|
storage_common_remove(storage, XTREME_SETTINGS_OLD_INT_PATH);
|
||||||
|
furi_record_close(RECORD_STORAGE);
|
||||||
|
loaded = saved_struct_load(
|
||||||
|
XTREME_SETTINGS_PATH,
|
||||||
|
xtreme_settings,
|
||||||
|
sizeof(XtremeSettings),
|
||||||
|
XTREME_SETTINGS_MAGIC,
|
||||||
|
XTREME_SETTINGS_VERSION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!loaded) {
|
if(!loaded) {
|
||||||
if(!skip) {
|
|
||||||
storage_simply_remove(furi_record_open(RECORD_STORAGE), XTREME_SETTINGS_PATH_OLD);
|
|
||||||
furi_record_close(RECORD_STORAGE);
|
|
||||||
}
|
|
||||||
memset(xtreme_settings, 0, sizeof(XtremeSettings));
|
memset(xtreme_settings, 0, sizeof(XtremeSettings));
|
||||||
strlcpy(xtreme_settings->asset_pack, "", MAX_PACK_NAME_LEN); // SFW
|
strlcpy(xtreme_settings->asset_pack, "", MAX_PACK_NAME_LEN); // SFW
|
||||||
xtreme_settings->anim_speed = 100; // 100%
|
xtreme_settings->anim_speed = 100; // 100%
|
||||||
@@ -55,9 +65,6 @@ void XTREME_SETTINGS_LOAD() {
|
|||||||
xtreme_settings->bad_bt_remember = false; // OFF
|
xtreme_settings->bad_bt_remember = false; // OFF
|
||||||
xtreme_settings->butthurt_timer = 43200; // 12 H
|
xtreme_settings->butthurt_timer = 43200; // 12 H
|
||||||
xtreme_settings->rgb_backlight = false; // OFF
|
xtreme_settings->rgb_backlight = false; // OFF
|
||||||
if(!skip) {
|
|
||||||
XTREME_SETTINGS_SAVE();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "settings_filename.h"
|
|
||||||
|
|
||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -16,11 +14,12 @@ extern "C" {
|
|||||||
#define MAX_PACK_NAME_LEN 32
|
#define MAX_PACK_NAME_LEN 32
|
||||||
|
|
||||||
#define XTREME_SETTINGS_VERSION (10)
|
#define XTREME_SETTINGS_VERSION (10)
|
||||||
#define XTREME_SETTINGS_PATH_OLD INT_PATH(XTREME_SETTINGS_FILE_NAME)
|
|
||||||
#define XTREME_SETTINGS_PATH EXT_PATH(XTREME_SETTINGS_FILE_NAME)
|
|
||||||
#define XTREME_SETTINGS_MAGIC (0x69)
|
#define XTREME_SETTINGS_MAGIC (0x69)
|
||||||
|
#define XTREME_SETTINGS_OLD_INT_PATH INT_PATH(".xtreme.settings")
|
||||||
|
#define XTREME_SETTINGS_OLD_PATH EXT_PATH(".xtreme.settings")
|
||||||
|
#define XTREME_SETTINGS_PATH CFG_PATH("xtreme.settings")
|
||||||
|
|
||||||
#define XTREME_APPS_PATH EXT_PATH(XTREME_APPS_FILE_NAME)
|
#define XTREME_APPS_PATH CFG_PATH("xtreme_apps.txt")
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char asset_pack[MAX_PACK_NAME_LEN];
|
char asset_pack[MAX_PACK_NAME_LEN];
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define XTREME_SETTINGS_FILE_NAME ".xtreme.settings"
|
|
||||||
#define XTREME_APPS_FILE_NAME ".xtreme_apps.txt"
|
|
||||||
@@ -12,7 +12,8 @@
|
|||||||
#include <update_util/resources/manifest.h>
|
#include <update_util/resources/manifest.h>
|
||||||
#include <toolbox/tar/tar_archive.h>
|
#include <toolbox/tar/tar_archive.h>
|
||||||
#include <toolbox/crc32_calc.h>
|
#include <toolbox/crc32_calc.h>
|
||||||
#include <xtreme/settings.h>
|
|
||||||
|
#define XFWFIRSTBOOT_FLAG_PATH CFG_PATH("xfwfirstboot.flag")
|
||||||
|
|
||||||
#define TAG "UpdWorkerBackup"
|
#define TAG "UpdWorkerBackup"
|
||||||
|
|
||||||
@@ -198,7 +199,12 @@ static bool update_task_post_update(UpdateTask* update_task) {
|
|||||||
update_task_set_progress(update_task, UpdateTaskStageSplashscreenInstall, 0);
|
update_task_set_progress(update_task, UpdateTaskStageSplashscreenInstall, 0);
|
||||||
FuriString* tmp_path;
|
FuriString* tmp_path;
|
||||||
tmp_path = furi_string_alloc_set(update_task->update_path);
|
tmp_path = furi_string_alloc_set(update_task->update_path);
|
||||||
if(storage_common_stat(update_task->storage, XTREME_SETTINGS_PATH, NULL) == FSE_NOT_EXIST) {
|
if(storage_common_stat(update_task->storage, XFWFIRSTBOOT_FLAG_PATH, NULL) == FSE_NOT_EXIST) {
|
||||||
|
File* file = storage_file_alloc(update_task->storage);
|
||||||
|
if(storage_file_open(file, XFWFIRSTBOOT_FLAG_PATH, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||||
|
storage_file_close(file);
|
||||||
|
}
|
||||||
|
storage_file_free(file);
|
||||||
path_append(tmp_path, "xfwfirstboot.bin");
|
path_append(tmp_path, "xfwfirstboot.bin");
|
||||||
if(storage_common_stat(update_task->storage, furi_string_get_cstr(tmp_path), NULL) != FSE_OK) {
|
if(storage_common_stat(update_task->storage, furi_string_get_cstr(tmp_path), NULL) != FSE_OK) {
|
||||||
furi_string_set(tmp_path, update_task->update_path);
|
furi_string_set(tmp_path, update_task->update_path);
|
||||||
|
|||||||
@@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
#include <toolbox/tar/tar_archive.h>
|
#include <toolbox/tar/tar_archive.h>
|
||||||
|
|
||||||
#include <bt/bt_settings_filename.h>
|
|
||||||
#include <bt/bt_service/bt_keys_filename.h>
|
|
||||||
#include <dolphin/helpers/dolphin_state_filename.h>
|
|
||||||
#include <desktop/helpers/slideshow_filename.h>
|
#include <desktop/helpers/slideshow_filename.h>
|
||||||
#include <desktop/desktop_settings_filename.h>
|
|
||||||
#include <notification/notification_settings_filename.h>
|
#include <notification/notification_settings_filename.h>
|
||||||
|
|
||||||
#define LFS_BACKUP_DEFAULT_LOCATION EXT_PATH(LFS_BACKUP_DEFAULT_FILENAME)
|
#define LFS_BACKUP_DEFAULT_LOCATION EXT_PATH(LFS_BACKUP_DEFAULT_FILENAME)
|
||||||
@@ -18,12 +14,8 @@ static void backup_name_converter(FuriString* filename) {
|
|||||||
|
|
||||||
/* Filenames are already prefixed with '.' */
|
/* Filenames are already prefixed with '.' */
|
||||||
const char* const names[] = {
|
const char* const names[] = {
|
||||||
BT_SETTINGS_FILE_NAME,
|
|
||||||
BT_KEYS_STORAGE_FILE_NAME,
|
|
||||||
DESKTOP_SETTINGS_FILE_NAME,
|
|
||||||
NOTIFICATION_SETTINGS_FILE_NAME,
|
NOTIFICATION_SETTINGS_FILE_NAME,
|
||||||
SLIDESHOW_FILE_NAME,
|
SLIDESHOW_FILE_NAME,
|
||||||
DOLPHIN_STATE_FILE_NAME,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for(size_t i = 0; i < COUNT_OF(names); i++) {
|
for(size_t i = 0; i < COUNT_OF(names); i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user