Skip to content

Commit

Permalink
Test Many Changes By Willy-JL
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueMaster committed Apr 20, 2023
1 parent 9a5f939 commit f6e0d0f
Show file tree
Hide file tree
Showing 64 changed files with 225 additions and 115 deletions.
6 changes: 4 additions & 2 deletions ReadMe.md
Expand Up @@ -60,6 +60,10 @@ This software is for experimental purposes only and is not meant for any illegal
- OFW: [Introduce stealth mode and auto-selective lock #2576 (By Astrrra)](https://github.com/flipperdevices/flipperzero-firmware/pull/2576)
- Updated: [Authenticator/TOTP (By akopachov)](https://github.com/akopachov/flipper-zero_authenticator)
- Updated: [WiFi (Marauder) v3.1.3 (Updated By tcpassos)](https://github.com/tcpassos/flipperzero-firmware-with-wifi-marauder-companion)
- Load fap meta anyway on api mismatch, Move setting files to sd card, Move slideshow temp file to external storage, Store main settings in dedicated ext folder, Fix critical boot modes (dfu / recovery), Expose storage_get_data, Fix resetting PIN code with key combo & U2F keys on external storage (By Willy-JL)
- Updated: [Dolphin Trainer (By nymda)](https://github.com/nymda/FlipperAntidepressants) With New Dolphin State File Location
- Removed/Commented: [Dolphin Backup (By nminaylov)-OFW](https://github.com/flipperdevices/flipperzero-firmware/pull/1384) Modified by RogueMaster
- Removed/Commented: [Dolphin Restorer (By nminaylov)](https://github.com/flipperdevices/flipperzero-firmware/pull/1384) Cloned by RogueMaster

<a name="release">

Expand Down Expand Up @@ -305,8 +309,6 @@ $ ./fbt dolphin_ext
- [Deauther PWNDTOOLS V2.6.0 (By HEX0DAYS)](https://github.com/HEX0DAYS/FlipperZero-PWNDTOOLS) `Req: ESP8266` [Original](https://github.com/SpacehuhnTech/esp8266_deauther)
- [Distance Sensor (By privet971)](https://github.com/privet971/FlipperZeroApps/tree/main/usping) `Req: Parallax (3 wires) SKU 28015`
- [Distance Sensor (By Sanqui)](https://github.com/Sanqui/flipperzero-firmware/tree/hc_sr04) `Req: HC-SR04` Ported/Modified by xMasterX
- [Dolphin Backup (By nminaylov)-OFW](https://github.com/flipperdevices/flipperzero-firmware/pull/1384) Modified by RogueMaster
- [Dolphin Restorer (By nminaylov)](https://github.com/flipperdevices/flipperzero-firmware/pull/1384) Cloned by RogueMaster
- [Dolphin Trainer (By nymda)](https://github.com/nymda/FlipperAntidepressants) (Change Flipper level, experience and butthurt) [Level Changer (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/96b67d9d53b5a70e85f8bdd81dcbc602f90d46cd)
- [DSTIKE Deauther (By SequoiaSan)](https://github.com/SequoiaSan/FlipperZero-Wifi-ESP8266-Deauther-Module/tree/FlipperZero-Module-v2/FlipperZeroModule/FlipperZero-ESP8266-Deauth-App) `Req: ESP8266`
- [DTMF Dolphin (By litui)](https://github.com/litui/dtmf_dolphin)
Expand Down
4 changes: 2 additions & 2 deletions applications/external/dolphintrainer/dolphintrainer.c
Expand Up @@ -108,7 +108,7 @@ int32_t dolphin_trainer_app(void* p) {

bool running = true;
bool success = saved_struct_load(
"/int/.dolphin.state", &stateLocal->data, sizeof(DolphinStoreData), 0xD0, 0x01);
DOLPHIN_STATE_PATH, &stateLocal->data, sizeof(DolphinStoreData), 0xD0, 0x01);
if(!success) {
running = false;
}
Expand All @@ -118,7 +118,7 @@ int32_t dolphin_trainer_app(void* p) {
if(event.type == InputTypePress) {
if(event.key == InputKeyOk && btnIndex == 3) {
bool result = saved_struct_save(
"/int/.dolphin.state", &stateLocal->data, sizeof(DolphinStoreData), 0xD0, 0x01);
DOLPHIN_STATE_PATH, &stateLocal->data, sizeof(DolphinStoreData), 0xD0, 0x01);
if(result) {
furi_delay_ms(100);
furi_hal_power_reset();
Expand Down
7 changes: 7 additions & 0 deletions applications/main/archive/helpers/archive_favorites.c
Expand Up @@ -140,6 +140,13 @@ bool archive_favorites_read(void* context) {

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) {
while(1) {
if(!archive_favorites_read_line(file, buffer)) {
Expand Down
5 changes: 3 additions & 2 deletions applications/main/archive/helpers/archive_favorites.h
Expand Up @@ -2,8 +2,9 @@

#include <storage/storage.h>

#define ARCHIVE_FAV_PATH ANY_PATH("favorites.txt")
#define ARCHIVE_FAV_TEMP_PATH ANY_PATH("favorites.tmp")
#define ARCHIVE_FAV_OLD_PATH EXT_PATH("favorites.txt")
#define ARCHIVE_FAV_PATH CFG_PATH("favorites.txt")
#define ARCHIVE_FAV_TEMP_PATH CFG_PATH("favorites.tmp")

uint16_t archive_favorites_count(void* context);
bool archive_favorites_read(void* context);
Expand Down
2 changes: 1 addition & 1 deletion applications/main/fap_loader/fap_loader_app.c
Expand Up @@ -37,7 +37,7 @@ bool fap_loader_load_name_and_icon(

bool load_success = false;

if(preload_res == FlipperApplicationPreloadStatusSuccess) {
if(preload_res == FlipperApplicationPreloadStatusSuccess || preload_res == FlipperApplicationPreloadStatusApiMismatch) {
const FlipperApplicationManifest* manifest = flipper_application_get_manifest(app);
if(manifest->has_icon) {
memcpy(*icon_ptr, manifest->icon, FAP_MANIFEST_MAX_ICON_SIZE);
Expand Down
6 changes: 6 additions & 0 deletions applications/main/u2f/u2f_app.c
Expand Up @@ -2,6 +2,7 @@
#include "u2f_data.h"
#include <furi.h>
#include <furi_hal.h>
#include <storage/storage.h>

static bool u2f_app_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
Expand All @@ -27,6 +28,11 @@ U2fApp* u2f_app_alloc() {
app->gui = furi_record_open(RECORD_GUI);
app->notifications = furi_record_open(RECORD_NOTIFICATION);

Storage* storage = furi_record_open(RECORD_STORAGE);
storage_common_copy(storage, U2F_CNT_OLD_FILE, U2F_CNT_FILE);
storage_common_copy(storage, U2F_KEY_OLD_FILE, U2F_KEY_FILE);
furi_record_close(RECORD_STORAGE);

app->view_dispatcher = view_dispatcher_alloc();
app->scene_manager = scene_manager_alloc(&u2f_scene_handlers, app);
view_dispatcher_enable_queue(app->view_dispatcher);
Expand Down
6 changes: 0 additions & 6 deletions applications/main/u2f/u2f_data.c
Expand Up @@ -7,12 +7,6 @@

#define TAG "U2F"

#define U2F_DATA_FOLDER ANY_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_DATA_FILE_ENCRYPTION_KEY_SLOT_FACTORY 2
#define U2F_DATA_FILE_ENCRYPTION_KEY_SLOT_UNIQUE 11

Expand Down
8 changes: 8 additions & 0 deletions applications/main/u2f/u2f_data.h
Expand Up @@ -6,6 +6,14 @@ extern "C" {

#include <furi.h>

#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_OLD_FILE U2F_DATA_FOLDER "key.u2f"
#define U2F_CNT_OLD_FILE U2F_DATA_FOLDER "cnt.u2f"
#define U2F_KEY_FILE INT_PATH(".key.u2f")
#define U2F_CNT_FILE INT_PATH(".cnt.u2f")

bool u2f_data_check(bool cert_only);

bool u2f_data_cert_check();
Expand Down
6 changes: 5 additions & 1 deletion applications/services/bt/bt_service/bt.c
Expand Up @@ -120,6 +120,10 @@ 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));
Expand Down Expand Up @@ -376,7 +380,7 @@ int32_t bt_srv(void* p) {
UNUSED(p);
Bt* bt = bt_alloc();

if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
if(!furi_hal_is_normal_boot()) {
FURI_LOG_W(TAG, "Skipping start in special boot mode");
ble_glue_wait_for_c2_start(FURI_HAL_BT_C2_START_TIMEOUT);
furi_record_create(RECORD_BT, bt);
Expand Down
5 changes: 2 additions & 3 deletions applications/services/bt/bt_service/bt_i.h
Expand Up @@ -18,9 +18,8 @@
#include <bt/bt_settings.h>
#include <bt/bt_service/bt_keys_storage.h>

#include "bt_keys_filename.h"

#define BT_KEYS_STORAGE_PATH INT_PATH(BT_KEYS_STORAGE_FILE_NAME)
#define BT_KEYS_STORAGE_OLD_PATH INT_PATH(".bt.keys")
#define BT_KEYS_STORAGE_PATH CFG_PATH("bt.keys")

#define BT_API_UNLOCK_EVENT (1UL << 0)

Expand Down
3 changes: 0 additions & 3 deletions applications/services/bt/bt_service/bt_keys_filename.h

This file was deleted.

16 changes: 14 additions & 2 deletions applications/services/bt/bt_settings.c
Expand Up @@ -4,15 +4,27 @@
#include <lib/toolbox/saved_struct.h>
#include <storage/storage.h>

#define BT_SETTINGS_PATH INT_PATH(BT_SETTINGS_FILE_NAME)
#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);

return saved_struct_load(
bool ret = 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) {
Expand Down
2 changes: 0 additions & 2 deletions applications/services/bt/bt_settings.h
@@ -1,7 +1,5 @@
#pragma once

#include "bt_settings_filename.h"

#include <stdint.h>
#include <stdbool.h>

Expand Down
3 changes: 0 additions & 3 deletions applications/services/bt/bt_settings_filename.h

This file was deleted.

2 changes: 1 addition & 1 deletion applications/services/cli/cli.c
Expand Up @@ -460,7 +460,7 @@ int32_t cli_srv(void* p) {
furi_thread_set_stdout_callback(NULL);
}

if(furi_hal_rtc_get_boot_mode() == FuriHalRtcBootModeNormal) {
if(furi_hal_is_normal_boot()) {
cli_session_open(cli, &cli_vcp);
} else {
FURI_LOG_W(TAG, "Skipping start in special boot mode");
Expand Down
11 changes: 10 additions & 1 deletion applications/services/desktop/desktop.c
Expand Up @@ -550,9 +550,18 @@ static bool desktop_check_file_flag(const char* flag_path) {
int32_t desktop_srv(void* p) {
UNUSED(p);

if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
if(!furi_hal_is_normal_boot()) {
FURI_LOG_W("Desktop", "Desktop load skipped. Device is in special startup mode.");
} else {

if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagResetPin)) {
Storage* storage = furi_record_open(RECORD_STORAGE);
storage_common_remove(storage, DESKTOP_SETTINGS_PATH);
storage_common_remove(storage, DESKTOP_SETTINGS_OLD_PATH);
furi_record_close(RECORD_STORAGE);
furi_hal_rtc_reset_flag(FuriHalRtcFlagResetPin);
}

Desktop* desktop = desktop_alloc();

bool loaded = DESKTOP_SETTINGS_LOAD(&desktop->settings);
Expand Down
22 changes: 22 additions & 0 deletions applications/services/desktop/desktop_settings.c
@@ -0,0 +1,22 @@
desktop_#include "desktop_settings.h"

bool DESKTOP_SETTINGS_SAVE(DesktopSettings* x) {
return saved_struct_save(
DESKTOP_SETTINGS_PATH, x, sizeof(DesktopSettings), DESKTOP_SETTINGS_MAGIC, DESKTOP_SETTINGS_VER);
}

bool DESKTOP_SETTINGS_LOAD(DesktopSettings* x) {
bool ret = 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;
}
25 changes: 6 additions & 19 deletions applications/services/desktop/desktop_settings.h
@@ -1,7 +1,5 @@
#pragma once

#include "desktop_settings_filename.h"

#include <furi_hal.h>
#include <stdint.h>
#include <stdbool.h>
Expand All @@ -10,28 +8,13 @@

#define DESKTOP_SETTINGS_VER (8)

#define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
#define DESKTOP_SETTINGS_OLD_PATH INT_PATH(".desktop.settings")
#define DESKTOP_SETTINGS_PATH CFG_PATH("desktop.settings")
#define DESKTOP_SETTINGS_MAGIC (0x17)
#define PIN_MAX_LENGTH 12

#define DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG "run_pin_setup"

#define DESKTOP_SETTINGS_SAVE(x) \
saved_struct_save( \
DESKTOP_SETTINGS_PATH, \
(x), \
sizeof(DesktopSettings), \
DESKTOP_SETTINGS_MAGIC, \
DESKTOP_SETTINGS_VER)

#define DESKTOP_SETTINGS_LOAD(x) \
saved_struct_load( \
DESKTOP_SETTINGS_PATH, \
(x), \
sizeof(DesktopSettings), \
DESKTOP_SETTINGS_MAGIC, \
DESKTOP_SETTINGS_VER)

#define MAX_PIN_SIZE 10
#define MIN_PIN_SIZE 4
#define MAX_APP_LENGTH 128
Expand Down Expand Up @@ -77,3 +60,7 @@ typedef struct {
bool rpc_icon;
bool auto_lock_with_pin;
} DesktopSettings;

bool DESKTOP_SETTINGS_SAVE(DesktopSettings* x);

bool DESKTOP_SETTINGS_LOAD(DesktopSettings* x);
3 changes: 0 additions & 3 deletions applications/services/desktop/desktop_settings_filename.h

This file was deleted.

3 changes: 0 additions & 3 deletions applications/services/desktop/helpers/slideshow_filename.h

This file was deleted.

Expand Up @@ -5,7 +5,7 @@
#include "desktop_events.h"
#include "../helpers/slideshow_filename.h"

#define SLIDESHOW_FS_PATH INT_PATH(SLIDESHOW_FILE_NAME)
#define SLIDESHOW_FS_PATH EXT_PATH(".slideshow")

typedef struct DesktopSlideshowView DesktopSlideshowView;

Expand Down
2 changes: 1 addition & 1 deletion applications/services/dolphin/dolphin.c
Expand Up @@ -168,7 +168,7 @@ static void dolphin_update_clear_limits_timer_period(Dolphin* dolphin) {
int32_t dolphin_srv(void* p) {
UNUSED(p);

if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
if(!furi_hal_is_normal_boot()) {
FURI_LOG_W(TAG, "Skipping start in special boot mode");
return 0;
}
Expand Down
16 changes: 14 additions & 2 deletions applications/services/dolphin/helpers/dolphin_state.c
@@ -1,6 +1,5 @@
#include "dolphin_state.h"
#include "dolphin/helpers/dolphin_deed.h"
#include "dolphin_state_filename.h"

#include <stdint.h>
#include <storage/storage.h>
Expand All @@ -11,7 +10,7 @@

#define TAG "DolphinState"

#define DOLPHIN_STATE_PATH INT_PATH(DOLPHIN_STATE_FILE_NAME)
#define DOLPHIN_STATE_OLD_PATH INT_PATH(".dolphin.state")
#define DOLPHIN_STATE_HEADER_MAGIC 0xD0
#define DOLPHIN_STATE_HEADER_VERSION 0x01

Expand Down Expand Up @@ -93,6 +92,19 @@ 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)) {
Expand Down
2 changes: 2 additions & 0 deletions applications/services/dolphin/helpers/dolphin_state.h
Expand Up @@ -5,6 +5,8 @@
#include <stdint.h>
#include <time.h>

#define DOLPHIN_STATE_PATH CFG_PATH("dolphin.state")

#ifdef __cplusplus
extern "C" {
#endif
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion applications/services/namechangersrv/namechangersrv.c
Expand Up @@ -5,7 +5,7 @@

int32_t namechanger_on_system_start(void* p) {
UNUSED(p);
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
if(!furi_hal_is_normal_boot()) {
FURI_LOG_W(TAG, "NameChangerSRV load skipped. Device is in special startup mode.");
} else {
Storage* storage = furi_record_open(RECORD_STORAGE);
Expand Down
2 changes: 1 addition & 1 deletion applications/services/power/power_service/power.c
Expand Up @@ -513,7 +513,7 @@ static void power_check_battery_level_change(Power* power) {
int32_t power_srv(void* p) {
UNUSED(p);

if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
if(!furi_hal_is_normal_boot()) {
FURI_LOG_W(TAG, "Skipping start in special boot mode");
return 0;
}
Expand Down

0 comments on commit f6e0d0f

Please sign in to comment.