mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Migrate files for int on ext, no more .config
This commit is contained in:
@@ -17,7 +17,7 @@ typedef struct InfraredApp InfraredApp;
|
||||
#include <storage/storage.h>
|
||||
#include <furi_hal_infrared.h>
|
||||
|
||||
#define INFRARED_SETTINGS_PATH EXT_PATH("infrared/.infrared.settings")
|
||||
#define INFRARED_SETTINGS_PATH INT_PATH(".infrared.settings")
|
||||
#define INFRARED_SETTINGS_VERSION (1)
|
||||
#define INFRARED_SETTINGS_MAGIC (0x1F)
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ extern "C" {
|
||||
#define U2F_DATA_FOLDER EXT_PATH("u2f/")
|
||||
#define U2F_CERT_FILE U2F_DATA_FOLDER "assets/cert.der"
|
||||
#define U2F_CERT_KEY_FILE U2F_DATA_FOLDER "assets/cert_key.u2f"
|
||||
#define U2F_KEY_FILE U2F_DATA_FOLDER "key.u2f"
|
||||
#define U2F_CNT_FILE U2F_DATA_FOLDER "cnt.u2f"
|
||||
#define U2F_KEY_FILE INT_PATH(".key.u2f")
|
||||
|
||||
bool u2f_data_check(bool cert_only);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#define OLD_DESKTOP_KEYBINDS_VER (1)
|
||||
#define OLD_DESKTOP_KEYBINDS_MAGIC (0x14)
|
||||
#define OLD_DESKTOP_KEYBINDS_PATH INT_PATH(".desktop.keybinds") // Moved from .config by migrate
|
||||
#define OLD_DESKTOP_KEYBINDS_PATH DESKTOP_KEYBINDS_PATH_MIGRATE
|
||||
#define OLD_MAX_KEYBIND_LENGTH (64)
|
||||
|
||||
typedef struct {
|
||||
@@ -22,33 +22,35 @@ typedef struct {
|
||||
typedef OldKeybind OldKeybinds[DesktopKeybindTypeMAX][DesktopKeybindKeyMAX];
|
||||
|
||||
void desktop_keybinds_migrate(Desktop* desktop) {
|
||||
OldKeybinds old;
|
||||
const bool success = saved_struct_load(
|
||||
OLD_DESKTOP_KEYBINDS_PATH,
|
||||
&old,
|
||||
sizeof(old),
|
||||
OLD_DESKTOP_KEYBINDS_MAGIC,
|
||||
OLD_DESKTOP_KEYBINDS_VER);
|
||||
if(!storage_common_exists(desktop->storage, DESKTOP_KEYBINDS_PATH)) {
|
||||
OldKeybinds old;
|
||||
const bool success = saved_struct_load(
|
||||
OLD_DESKTOP_KEYBINDS_PATH,
|
||||
&old,
|
||||
sizeof(old),
|
||||
OLD_DESKTOP_KEYBINDS_MAGIC,
|
||||
OLD_DESKTOP_KEYBINDS_VER);
|
||||
|
||||
if(success) {
|
||||
DesktopKeybinds new;
|
||||
for(DesktopKeybindType type = 0; type < DesktopKeybindTypeMAX; type++) {
|
||||
for(DesktopKeybindKey key = 0; key < DesktopKeybindKeyMAX; key++) {
|
||||
FuriString* keybind = furi_string_alloc_set(old[type][key].data);
|
||||
if(furi_string_equal(keybind, EXT_PATH("apps/Misc/nightstand.fap"))) {
|
||||
furi_string_set(keybind, "Clock");
|
||||
} else if(furi_string_equal(keybind, "RFID")) {
|
||||
furi_string_set(keybind, "125 kHz RFID");
|
||||
} else if(furi_string_equal(keybind, "SubGHz")) {
|
||||
furi_string_set(keybind, "Sub-GHz");
|
||||
} else if(furi_string_equal(keybind, "Xtreme")) {
|
||||
furi_string_set(keybind, "Momentum");
|
||||
if(success) {
|
||||
DesktopKeybinds new;
|
||||
for(DesktopKeybindType type = 0; type < DesktopKeybindTypeMAX; type++) {
|
||||
for(DesktopKeybindKey key = 0; key < DesktopKeybindKeyMAX; key++) {
|
||||
FuriString* keybind = furi_string_alloc_set(old[type][key].data);
|
||||
if(furi_string_equal(keybind, EXT_PATH("apps/Misc/nightstand.fap"))) {
|
||||
furi_string_set(keybind, "Clock");
|
||||
} else if(furi_string_equal(keybind, "RFID")) {
|
||||
furi_string_set(keybind, "125 kHz RFID");
|
||||
} else if(furi_string_equal(keybind, "SubGHz")) {
|
||||
furi_string_set(keybind, "Sub-GHz");
|
||||
} else if(furi_string_equal(keybind, "Xtreme")) {
|
||||
furi_string_set(keybind, "Momentum");
|
||||
}
|
||||
new[type][key] = keybind;
|
||||
}
|
||||
new[type][key] = keybind;
|
||||
}
|
||||
desktop_keybinds_save(desktop, &new);
|
||||
desktop_keybinds_free(&new);
|
||||
}
|
||||
desktop_keybinds_save(desktop, &new);
|
||||
desktop_keybinds_free(&new);
|
||||
}
|
||||
|
||||
storage_common_remove(desktop->storage, OLD_DESKTOP_KEYBINDS_PATH);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define DESKTOP_KEYBINDS_PATH INT_PATH(".desktop_keybinds.txt")
|
||||
|
||||
// Moved from .config by migrate, then converted to Flipper Format by Desktop
|
||||
#define DESKTOP_KEYBINDS_PATH_MIGRATE INT_PATH(".desktop.keybinds")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "power_settings.h"
|
||||
#include "power_settings_filename.h"
|
||||
|
||||
bool SAVE_POWER_SETTINGS(uint32_t* x) {
|
||||
return saved_struct_save(
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#define POWER_SETTINGS_VER (1)
|
||||
|
||||
#define POWER_SETTINGS_PATH INT_PATH(".power.settings")
|
||||
#define POWER_SETTINGS_MAGIC (0x21)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
3
applications/services/power/power_settings_filename.h
Normal file
3
applications/services/power/power_settings_filename.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define POWER_SETTINGS_PATH INT_PATH(".power.settings")
|
||||
@@ -33,21 +33,24 @@ static void flipper_print_version(const char* target, const Version* version) {
|
||||
}
|
||||
|
||||
#ifndef FURI_RAM_EXEC
|
||||
#include <applications/main/archive/helpers/archive_favorites.h>
|
||||
#include <applications/main/infrared/infrared_app.h>
|
||||
#include <applications/main/u2f/u2f_data.h>
|
||||
#include <furi_hal.h>
|
||||
#include <assets_icons.h>
|
||||
#include <bt/bt_service/bt_i.h>
|
||||
#include <bt/bt_settings.h>
|
||||
#include <desktop/desktop_settings.h>
|
||||
#include <dolphin/helpers/dolphin_state.h>
|
||||
#include <expansion/expansion_settings_filename.h>
|
||||
#include <loader/loader_menu.h>
|
||||
#include <momentum/asset_packs.h>
|
||||
#include <momentum/namespoof.h>
|
||||
#include <momentum/settings_i.h>
|
||||
#include <notification/notification_app.h>
|
||||
#include <power/power_settings.h>
|
||||
|
||||
#include <applications/main/archive/helpers/archive_favorites.h>
|
||||
#include <bt/bt_service/bt_keys_filename.h>
|
||||
#include <bt/bt_settings_filename.h>
|
||||
#include <desktop/desktop_keybinds_filename.h>
|
||||
#include <desktop/desktop_settings_filename.h>
|
||||
#include <dolphin/helpers/dolphin_state_filename.h>
|
||||
#include <expansion/expansion_settings_filename.h>
|
||||
#include <loader/loader_menu.h>
|
||||
#include <notification/notification_settings_filename.h>
|
||||
#include <power/power_settings_filename.h>
|
||||
#include <applications/main/infrared/infrared_app.h>
|
||||
#include <applications/main/u2f/u2f_data.h>
|
||||
|
||||
void flipper_migrate_files() {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
@@ -58,43 +61,52 @@ void flipper_migrate_files() {
|
||||
|
||||
// Migrate files
|
||||
FURI_LOG_I(TAG, "Migrate: Rename old paths");
|
||||
// If multiple have same destination, first match that exists is kept and others deleted
|
||||
const struct {
|
||||
const char* src;
|
||||
const char* dst;
|
||||
bool delete;
|
||||
} renames[] = {
|
||||
// Renames on ext
|
||||
{EXT_PATH(".config/favorites.txt"), ARCHIVE_FAV_PATH, true}, // Adapt to OFW/UL
|
||||
{EXT_PATH(".config/.desktop.keybinds"), DESKTOP_KEYBINDS_PATH, true}, // Old naming
|
||||
{EXT_PATH(".config/xtreme_menu.txt"), MAINMENU_APPS_PATH, false}, // Keep both
|
||||
{EXT_PATH(".config/xtreme_settings.txt"), MOMENTUM_SETTINGS_PATH, false}, // Keep both
|
||||
// Int -> Ext
|
||||
{INT_PATH(".bt.settings"), BT_SETTINGS_PATH, true},
|
||||
{INT_PATH(".dolphin.state"), DOLPHIN_STATE_PATH, true},
|
||||
{INT_PATH(".power.settings"), POWER_SETTINGS_PATH, true},
|
||||
{INT_PATH(".bt.keys"), BT_KEYS_STORAGE_PATH, true},
|
||||
{INT_PATH(".expansion.settings"), EXPANSION_SETTINGS_PATH, true},
|
||||
{INT_PATH(".notification.settings"), NOTIFICATION_SETTINGS_PATH, true},
|
||||
{INT_PATH(".infrared.settings"), INFRARED_SETTINGS_PATH, true},
|
||||
// Ext -> Int
|
||||
{EXT_PATH(".config/desktop.settings"), DESKTOP_SETTINGS_PATH, true},
|
||||
// Renames on Ext
|
||||
{EXT_PATH(".config/favorites.txt"), ARCHIVE_FAV_PATH}, // Adapt to OFW/UL
|
||||
// Ext -> "Int"
|
||||
{EXT_PATH(".config/bt.keys"), BT_KEYS_STORAGE_PATH},
|
||||
{EXT_PATH(".config/bt.settings"), BT_SETTINGS_PATH},
|
||||
{EXT_PATH(".config/desktop.keybinds"), DESKTOP_KEYBINDS_PATH_MIGRATE},
|
||||
{EXT_PATH(".config/.desktop.keybinds"), DESKTOP_KEYBINDS_PATH_MIGRATE}, // Old naming
|
||||
{EXT_PATH(".config/desktop.settings"), DESKTOP_SETTINGS_PATH},
|
||||
{EXT_PATH(".config/dolphin.state"), DOLPHIN_STATE_PATH},
|
||||
{EXT_PATH(".config/expansion.settings"), EXPANSION_SETTINGS_PATH},
|
||||
{EXT_PATH(".config/mainmenu_apps.txt"), MAINMENU_APPS_PATH},
|
||||
{EXT_PATH(".config/xtreme_menu.txt"), MAINMENU_APPS_PATH},
|
||||
{EXT_PATH(".config/momentum_settings.txt"), MOMENTUM_SETTINGS_PATH},
|
||||
{EXT_PATH(".config/xtreme_settings.txt"), MOMENTUM_SETTINGS_PATH},
|
||||
{EXT_PATH(".config/notification.settings"), NOTIFICATION_SETTINGS_PATH},
|
||||
{EXT_PATH(".config/power.settings"), POWER_SETTINGS_PATH},
|
||||
{EXT_PATH("infrared/.infrared.settings"), INFRARED_SETTINGS_PATH}, // Adapt to OFW
|
||||
};
|
||||
for(size_t i = 0; i < COUNT_OF(renames); ++i) {
|
||||
// Use copy+remove to not overwrite dst but still delete src
|
||||
storage_common_copy(storage, renames[i].src, renames[i].dst);
|
||||
if(renames[i].delete) {
|
||||
storage_common_remove(storage, renames[i].src);
|
||||
}
|
||||
storage_common_remove(storage, renames[i].src);
|
||||
}
|
||||
|
||||
// Special care for U2F
|
||||
// Int -> Ext for U2F
|
||||
FURI_LOG_I(TAG, "Migrate: U2F");
|
||||
FileInfo file_info;
|
||||
if(storage_common_stat(storage, INT_PATH(".cnt.u2f"), &file_info) == FSE_OK &&
|
||||
file_info.size > 200) { // Is on Int and has content
|
||||
storage_common_rename(storage, INT_PATH(".cnt.u2f"), U2F_CNT_FILE); // Int -> Ext
|
||||
if(storage_common_exists(storage, INT_PATH(".cnt.u2f"))) {
|
||||
const char* cnt_dst = storage_common_exists(storage, U2F_CNT_FILE) ? U2F_CNT_FILE ".old" :
|
||||
U2F_CNT_FILE;
|
||||
storage_common_rename(storage, INT_PATH(".cnt.u2f"), cnt_dst);
|
||||
}
|
||||
if(storage_common_exists(storage, INT_PATH(".key.u2f"))) {
|
||||
const char* key_dst = storage_common_exists(storage, U2F_KEY_FILE) ? U2F_KEY_FILE ".old" :
|
||||
U2F_KEY_FILE;
|
||||
storage_common_rename(storage, INT_PATH(".key.u2f"), key_dst);
|
||||
}
|
||||
|
||||
// Remove obsolete .config folder after migration
|
||||
if(!storage_simply_remove(storage, EXT_PATH(".config"))) {
|
||||
FURI_LOG_W(TAG, "Can't remove /ext/.config/, probably not empty");
|
||||
}
|
||||
storage_common_copy(storage, U2F_DATA_FOLDER "key.u2f", U2F_KEY_FILE); // Ext -> Int
|
||||
|
||||
// Asset packs migrate, merges together
|
||||
FURI_LOG_I(TAG, "Migrate: Asset Packs");
|
||||
|
||||
Reference in New Issue
Block a user