Storage: move factory reset to the place it belongs, add gui version. (#822)
This commit is contained in:
		
							parent
							
								
									7f814b5197
								
							
						
					
					
						commit
						516a437305
					
				| @ -162,7 +162,7 @@ Finally, you will have **`firmware/.obj/f7/full.dfu`** file that can be distribu | |||||||
|   * power-observer - power debug tool |   * power-observer - power debug tool | ||||||
|   * scened-app-example - c++ application example  |   * scened-app-example - c++ application example  | ||||||
|   * storage - storage service, internal + sdcard |   * storage - storage service, internal + sdcard | ||||||
|   * storage-settings - storage settings app |   * storage_settings - storage settings app | ||||||
|   * subghz - subghz application, 433 fobs and etc |   * subghz - subghz application, 433 fobs and etc | ||||||
|   * tests - unit tests and etc |   * tests - unit tests and etc | ||||||
| - assets - assets used by applications and services | - assets - assets used by applications and services | ||||||
|  | |||||||
| @ -18,18 +18,6 @@ void power_cli_dfu(Cli* cli, string_t args, void* context) { | |||||||
|     power_reboot(PowerBootModeDfu); |     power_reboot(PowerBootModeDfu); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void power_cli_factory_reset(Cli* cli, string_t args, void* context) { |  | ||||||
|     printf("All data will be lost. Are you sure (y/n)?\r\n"); |  | ||||||
|     char c = cli_getc(cli); |  | ||||||
|     if(c == 'y' || c == 'Y') { |  | ||||||
|         printf("Data will be wiped after reboot.\r\n"); |  | ||||||
|         furi_hal_bootloader_set_flags(FuriHalBootloaderFlagFactoryReset); |  | ||||||
|         power_reboot(PowerBootModeNormal); |  | ||||||
|     } else { |  | ||||||
|         printf("Safe choice.\r\n"); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void power_cli_info(Cli* cli, string_t args, void* context) { | void power_cli_info(Cli* cli, string_t args, void* context) { | ||||||
|     furi_hal_power_dump_state(); |     furi_hal_power_dump_state(); | ||||||
| } | } | ||||||
| @ -59,8 +47,6 @@ void power_cli_init() { | |||||||
| 
 | 
 | ||||||
|     cli_add_command(cli, "poweroff", CliCommandFlagParallelSafe, power_cli_poweroff, NULL); |     cli_add_command(cli, "poweroff", CliCommandFlagParallelSafe, power_cli_poweroff, NULL); | ||||||
|     cli_add_command(cli, "reboot", CliCommandFlagParallelSafe, power_cli_reboot, NULL); |     cli_add_command(cli, "reboot", CliCommandFlagParallelSafe, power_cli_reboot, NULL); | ||||||
|     cli_add_command( |  | ||||||
|         cli, "factory_reset", CliCommandFlagParallelSafe, power_cli_factory_reset, NULL); |  | ||||||
|     cli_add_command(cli, "dfu", CliCommandFlagParallelSafe, power_cli_dfu, NULL); |     cli_add_command(cli, "dfu", CliCommandFlagParallelSafe, power_cli_dfu, NULL); | ||||||
|     cli_add_command(cli, "power_info", CliCommandFlagParallelSafe, power_cli_info, NULL); |     cli_add_command(cli, "power_info", CliCommandFlagParallelSafe, power_cli_info, NULL); | ||||||
|     cli_add_command(cli, "power_otg", CliCommandFlagParallelSafe, power_cli_otg, NULL); |     cli_add_command(cli, "power_otg", CliCommandFlagParallelSafe, power_cli_otg, NULL); | ||||||
|  | |||||||
| @ -1,23 +1,16 @@ | |||||||
| #include <furi.h> | #include <furi.h> | ||||||
|  | #include <furi-hal.h> | ||||||
|  | 
 | ||||||
| #include <cli/cli.h> | #include <cli/cli.h> | ||||||
| #include <lib/toolbox/args.h> | #include <lib/toolbox/args.h> | ||||||
| #include <lib/toolbox/md5.h> | #include <lib/toolbox/md5.h> | ||||||
| #include <storage/storage.h> | #include <storage/storage.h> | ||||||
| #include <storage/storage-sd-api.h> | #include <storage/storage-sd-api.h> | ||||||
| #include <furi-hal-version.h> | #include <power/power_service/power.h> | ||||||
| 
 | 
 | ||||||
| #define MAX_NAME_LENGTH 255 | #define MAX_NAME_LENGTH 255 | ||||||
| 
 | 
 | ||||||
| void storage_cli(Cli* cli, string_t args, void* context); | static void storage_cli_print_usage() { | ||||||
| 
 |  | ||||||
| // app cli function
 |  | ||||||
| void storage_cli_init() { |  | ||||||
|     Cli* cli = furi_record_open("cli"); |  | ||||||
|     cli_add_command(cli, "storage", CliCommandFlagDefault, storage_cli, NULL); |  | ||||||
|     furi_record_close("cli"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void storage_cli_print_usage() { |  | ||||||
|     printf("Usage:\r\n"); |     printf("Usage:\r\n"); | ||||||
|     printf("storage <cmd> <path> <args>\r\n"); |     printf("storage <cmd> <path> <args>\r\n"); | ||||||
|     printf("The path must start with /int or /ext\r\n"); |     printf("The path must start with /int or /ext\r\n"); | ||||||
| @ -39,11 +32,11 @@ void storage_cli_print_usage() { | |||||||
|     printf("\tstat\t - info about file or dir\r\n"); |     printf("\tstat\t - info about file or dir\r\n"); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void storage_cli_print_error(FS_Error error) { | static void storage_cli_print_error(FS_Error error) { | ||||||
|     printf("Storage error: %s\r\n", storage_error_get_desc(error)); |     printf("Storage error: %s\r\n", storage_error_get_desc(error)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_info(Cli* cli, string_t path) { | static void storage_cli_info(Cli* cli, string_t path) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
| 
 | 
 | ||||||
|     if(string_cmp_str(path, "/int") == 0) { |     if(string_cmp_str(path, "/int") == 0) { | ||||||
| @ -81,7 +74,7 @@ void storage_cli_info(Cli* cli, string_t path) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void storage_cli_format(Cli* cli, string_t path) { | static void storage_cli_format(Cli* cli, string_t path) { | ||||||
|     if(string_cmp_str(path, "/int") == 0) { |     if(string_cmp_str(path, "/int") == 0) { | ||||||
|         storage_cli_print_error(FSE_NOT_IMPLEMENTED); |         storage_cli_print_error(FSE_NOT_IMPLEMENTED); | ||||||
|     } else if(string_cmp_str(path, "/ext") == 0) { |     } else if(string_cmp_str(path, "/ext") == 0) { | ||||||
| @ -107,7 +100,7 @@ void storage_cli_format(Cli* cli, string_t path) { | |||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void storage_cli_list(Cli* cli, string_t path) { | static void storage_cli_list(Cli* cli, string_t path) { | ||||||
|     if(string_cmp_str(path, "/") == 0) { |     if(string_cmp_str(path, "/") == 0) { | ||||||
|         printf("\t[D] int\r\n"); |         printf("\t[D] int\r\n"); | ||||||
|         printf("\t[D] ext\r\n"); |         printf("\t[D] ext\r\n"); | ||||||
| @ -143,7 +136,7 @@ void storage_cli_list(Cli* cli, string_t path) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_read(Cli* cli, string_t path) { | static void storage_cli_read(Cli* cli, string_t path) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     File* file = storage_file_alloc(api); |     File* file = storage_file_alloc(api); | ||||||
| 
 | 
 | ||||||
| @ -173,7 +166,7 @@ void storage_cli_read(Cli* cli, string_t path) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_write(Cli* cli, string_t path) { | static void storage_cli_write(Cli* cli, string_t path) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     File* file = storage_file_alloc(api); |     File* file = storage_file_alloc(api); | ||||||
| 
 | 
 | ||||||
| @ -227,7 +220,7 @@ void storage_cli_write(Cli* cli, string_t path) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_read_chunks(Cli* cli, string_t path, string_t args) { | static void storage_cli_read_chunks(Cli* cli, string_t path, string_t args) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     File* file = storage_file_alloc(api); |     File* file = storage_file_alloc(api); | ||||||
| 
 | 
 | ||||||
| @ -265,7 +258,7 @@ void storage_cli_read_chunks(Cli* cli, string_t path, string_t args) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_write_chunk(Cli* cli, string_t path, string_t args) { | static void storage_cli_write_chunk(Cli* cli, string_t path, string_t args) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     File* file = storage_file_alloc(api); |     File* file = storage_file_alloc(api); | ||||||
| 
 | 
 | ||||||
| @ -301,7 +294,7 @@ void storage_cli_write_chunk(Cli* cli, string_t path, string_t args) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_stat(Cli* cli, string_t path) { | static void storage_cli_stat(Cli* cli, string_t path) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
| 
 | 
 | ||||||
|     if(string_cmp_str(path, "/") == 0) { |     if(string_cmp_str(path, "/") == 0) { | ||||||
| @ -340,7 +333,7 @@ void storage_cli_stat(Cli* cli, string_t path) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_copy(Cli* cli, string_t old_path, string_t args) { | static void storage_cli_copy(Cli* cli, string_t old_path, string_t args) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     string_t new_path; |     string_t new_path; | ||||||
|     string_init(new_path); |     string_init(new_path); | ||||||
| @ -360,7 +353,7 @@ void storage_cli_copy(Cli* cli, string_t old_path, string_t args) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_remove(Cli* cli, string_t path) { | static void storage_cli_remove(Cli* cli, string_t path) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     FS_Error error = storage_common_remove(api, string_get_cstr(path)); |     FS_Error error = storage_common_remove(api, string_get_cstr(path)); | ||||||
| 
 | 
 | ||||||
| @ -371,7 +364,7 @@ void storage_cli_remove(Cli* cli, string_t path) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_rename(Cli* cli, string_t old_path, string_t args) { | static void storage_cli_rename(Cli* cli, string_t old_path, string_t args) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     string_t new_path; |     string_t new_path; | ||||||
|     string_init(new_path); |     string_init(new_path); | ||||||
| @ -391,7 +384,7 @@ void storage_cli_rename(Cli* cli, string_t old_path, string_t args) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_mkdir(Cli* cli, string_t path) { | static void storage_cli_mkdir(Cli* cli, string_t path) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     FS_Error error = storage_common_mkdir(api, string_get_cstr(path)); |     FS_Error error = storage_common_mkdir(api, string_get_cstr(path)); | ||||||
| 
 | 
 | ||||||
| @ -402,7 +395,7 @@ void storage_cli_mkdir(Cli* cli, string_t path) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli_md5(Cli* cli, string_t path) { | static void storage_cli_md5(Cli* cli, string_t path) { | ||||||
|     Storage* api = furi_record_open("storage"); |     Storage* api = furi_record_open("storage"); | ||||||
|     File* file = storage_file_alloc(api); |     File* file = storage_file_alloc(api); | ||||||
| 
 | 
 | ||||||
| @ -439,7 +432,7 @@ void storage_cli_md5(Cli* cli, string_t path) { | |||||||
|     furi_record_close("storage"); |     furi_record_close("storage"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void storage_cli(Cli* cli, string_t args, void* context) { | static void storage_cli(Cli* cli, string_t args, void* context) { | ||||||
|     string_t cmd; |     string_t cmd; | ||||||
|     string_t path; |     string_t path; | ||||||
|     string_init(cmd); |     string_init(cmd); | ||||||
| @ -527,3 +520,23 @@ void storage_cli(Cli* cli, string_t args, void* context) { | |||||||
|     string_clear(path); |     string_clear(path); | ||||||
|     string_clear(cmd); |     string_clear(cmd); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | static void storage_cli_factory_reset(Cli* cli, string_t args, void* context) { | ||||||
|  |     printf("All data will be lost. Are you sure (y/n)?\r\n"); | ||||||
|  |     char c = cli_getc(cli); | ||||||
|  |     if(c == 'y' || c == 'Y') { | ||||||
|  |         printf("Data will be wiped after reboot.\r\n"); | ||||||
|  |         furi_hal_bootloader_set_flags(FuriHalBootloaderFlagFactoryReset); | ||||||
|  |         power_reboot(PowerBootModeNormal); | ||||||
|  |     } else { | ||||||
|  |         printf("Safe choice.\r\n"); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void storage_cli_init() { | ||||||
|  |     Cli* cli = furi_record_open("cli"); | ||||||
|  |     cli_add_command(cli, "storage", CliCommandFlagDefault, storage_cli, NULL); | ||||||
|  |     cli_add_command( | ||||||
|  |         cli, "factory_reset", CliCommandFlagParallelSafe, storage_cli_factory_reset, NULL); | ||||||
|  |     furi_record_close("cli"); | ||||||
|  | } | ||||||
|  | |||||||
| @ -1,23 +1,23 @@ | |||||||
| #include "storage-settings-scene.h" | #include "storage_settings_scene.h" | ||||||
| 
 | 
 | ||||||
| // Generate scene on_enter handlers array
 | // Generate scene on_enter handlers array
 | ||||||
| #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, | #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, | ||||||
| void (*const storage_settings_on_enter_handlers[])(void*) = { | void (*const storage_settings_on_enter_handlers[])(void*) = { | ||||||
| #include "storage-settings-scene-config.h" | #include "storage_settings_scene_config.h" | ||||||
| }; | }; | ||||||
| #undef ADD_SCENE | #undef ADD_SCENE | ||||||
| 
 | 
 | ||||||
| // Generate scene on_event handlers array
 | // Generate scene on_event handlers array
 | ||||||
| #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, | #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, | ||||||
| bool (*const storage_settings_on_event_handlers[])(void* context, SceneManagerEvent event) = { | bool (*const storage_settings_on_event_handlers[])(void* context, SceneManagerEvent event) = { | ||||||
| #include "storage-settings-scene-config.h" | #include "storage_settings_scene_config.h" | ||||||
| }; | }; | ||||||
| #undef ADD_SCENE | #undef ADD_SCENE | ||||||
| 
 | 
 | ||||||
| // Generate scene on_exit handlers array
 | // Generate scene on_exit handlers array
 | ||||||
| #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, | #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, | ||||||
| void (*const storage_settings_on_exit_handlers[])(void* context) = { | void (*const storage_settings_on_exit_handlers[])(void* context) = { | ||||||
| #include "storage-settings-scene-config.h" | #include "storage_settings_scene_config.h" | ||||||
| }; | }; | ||||||
| #undef ADD_SCENE | #undef ADD_SCENE | ||||||
| 
 | 
 | ||||||
| @ -5,7 +5,7 @@ | |||||||
| // Generate scene id and total number
 | // Generate scene id and total number
 | ||||||
| #define ADD_SCENE(prefix, name, id) StorageSettings##id, | #define ADD_SCENE(prefix, name, id) StorageSettings##id, | ||||||
| typedef enum { | typedef enum { | ||||||
| #include "storage-settings-scene-config.h" | #include "storage_settings_scene_config.h" | ||||||
|     StorageSettingsSceneNum, |     StorageSettingsSceneNum, | ||||||
| } StorageSettingsScene; | } StorageSettingsScene; | ||||||
| #undef ADD_SCENE | #undef ADD_SCENE | ||||||
| @ -14,16 +14,16 @@ extern const SceneManagerHandlers storage_settings_scene_handlers; | |||||||
| 
 | 
 | ||||||
| // Generate scene on_enter handlers declaration
 | // Generate scene on_enter handlers declaration
 | ||||||
| #define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); | #define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); | ||||||
| #include "storage-settings-scene-config.h" | #include "storage_settings_scene_config.h" | ||||||
| #undef ADD_SCENE | #undef ADD_SCENE | ||||||
| 
 | 
 | ||||||
| // Generate scene on_event handlers declaration
 | // Generate scene on_event handlers declaration
 | ||||||
| #define ADD_SCENE(prefix, name, id) \ | #define ADD_SCENE(prefix, name, id) \ | ||||||
|     bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); |     bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); | ||||||
| #include "storage-settings-scene-config.h" | #include "storage_settings_scene_config.h" | ||||||
| #undef ADD_SCENE | #undef ADD_SCENE | ||||||
| 
 | 
 | ||||||
| // Generate scene on_exit handlers declaration
 | // Generate scene on_exit handlers declaration
 | ||||||
| #define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); | #define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); | ||||||
| #include "storage-settings-scene-config.h" | #include "storage_settings_scene_config.h" | ||||||
| #undef ADD_SCENE | #undef ADD_SCENE | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| 
 | 
 | ||||||
| #define BENCH_DATA_SIZE 4096 | #define BENCH_DATA_SIZE 4096 | ||||||
| #define BENCH_COUNT 6 | #define BENCH_COUNT 6 | ||||||
| @ -12,7 +12,7 @@ static void | |||||||
|     view_dispatcher_send_custom_event(app->view_dispatcher, result); |     view_dispatcher_send_custom_event(app->view_dispatcher, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static bool storage_settings_bench_write( | static bool storage_settings_scene_bench_write( | ||||||
|     Storage* api, |     Storage* api, | ||||||
|     uint16_t size, |     uint16_t size, | ||||||
|     const uint8_t* data, |     const uint8_t* data, | ||||||
| @ -43,7 +43,7 @@ static bool storage_settings_bench_write( | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static bool | static bool | ||||||
|     storage_settings_bench_read(Storage* api, uint16_t size, uint8_t* data, uint32_t* speed) { |     storage_settings_scene_bench_read(Storage* api, uint16_t size, uint8_t* data, uint32_t* speed) { | ||||||
|     File* file = storage_file_alloc(api); |     File* file = storage_file_alloc(api); | ||||||
|     bool result = true; |     bool result = true; | ||||||
|     *speed = -1; |     *speed = -1; | ||||||
| @ -71,7 +71,7 @@ static bool | |||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void storage_settings_benchmark(StorageSettings* app) { | static void storage_settings_scene_benchmark(StorageSettings* app) { | ||||||
|     DialogEx* dialog_ex = app->dialog_ex; |     DialogEx* dialog_ex = app->dialog_ex; | ||||||
|     uint8_t* bench_data; |     uint8_t* bench_data; | ||||||
|     dialog_ex_set_header(dialog_ex, "Preparing data...", 64, 32, AlignCenter, AlignCenter); |     dialog_ex_set_header(dialog_ex, "Preparing data...", 64, 32, AlignCenter, AlignCenter); | ||||||
| @ -87,7 +87,8 @@ static void storage_settings_benchmark(StorageSettings* app) { | |||||||
| 
 | 
 | ||||||
|     dialog_ex_set_header(dialog_ex, "Benchmarking...", 64, 32, AlignCenter, AlignCenter); |     dialog_ex_set_header(dialog_ex, "Benchmarking...", 64, 32, AlignCenter, AlignCenter); | ||||||
|     for(size_t i = 0; i < BENCH_COUNT; i++) { |     for(size_t i = 0; i < BENCH_COUNT; i++) { | ||||||
|         if(!storage_settings_bench_write(app->fs_api, bench_size[i], bench_data, &bench_w_speed[i])) |         if(!storage_settings_scene_bench_write( | ||||||
|  |                app->fs_api, bench_size[i], bench_data, &bench_w_speed[i])) | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|         if(i > 0) string_cat_printf(app->text_string, "\n"); |         if(i > 0) string_cat_printf(app->text_string, "\n"); | ||||||
| @ -96,7 +97,8 @@ static void storage_settings_benchmark(StorageSettings* app) { | |||||||
|         dialog_ex_set_text( |         dialog_ex_set_text( | ||||||
|             dialog_ex, string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter); |             dialog_ex, string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter); | ||||||
| 
 | 
 | ||||||
|         if(!storage_settings_bench_read(app->fs_api, bench_size[i], bench_data, &bench_r_speed[i])) |         if(!storage_settings_scene_bench_read( | ||||||
|  |                app->fs_api, bench_size[i], bench_data, &bench_r_speed[i])) | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|         string_cat_printf(app->text_string, "R %luK", bench_r_speed[i]); |         string_cat_printf(app->text_string, "R %luK", bench_r_speed[i]); | ||||||
| @ -126,7 +128,7 @@ void storage_settings_scene_benchmark_on_enter(void* context) { | |||||||
|             AlignCenter); |             AlignCenter); | ||||||
|         dialog_ex_set_left_button_text(dialog_ex, "Back"); |         dialog_ex_set_left_button_text(dialog_ex, "Back"); | ||||||
|     } else { |     } else { | ||||||
|         storage_settings_benchmark(app); |         storage_settings_scene_benchmark(app); | ||||||
|         notification_message(app->notification, &sequence_blink_green_100); |         notification_message(app->notification, &sequence_blink_green_100); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -6,3 +6,4 @@ ADD_SCENE(storage_settings, formatting, Formatting) | |||||||
| ADD_SCENE(storage_settings, sd_info, SDInfo) | ADD_SCENE(storage_settings, sd_info, SDInfo) | ||||||
| ADD_SCENE(storage_settings, internal_info, InternalInfo) | ADD_SCENE(storage_settings, internal_info, InternalInfo) | ||||||
| ADD_SCENE(storage_settings, benchmark, Benchmark) | ADD_SCENE(storage_settings, benchmark, Benchmark) | ||||||
|  | ADD_SCENE(storage_settings, factory_reset, FactoryReset) | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
|     storage_settings_scene_unmount_confirm_dialog_callback(DialogExResult result, void* context) { |     storage_settings_scene_unmount_confirm_dialog_callback(DialogExResult result, void* context) { | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
|     storage_settings_scene_unmounted_dialog_callback(DialogExResult result, void* context) { |     storage_settings_scene_unmounted_dialog_callback(DialogExResult result, void* context) { | ||||||
| @ -0,0 +1,90 @@ | |||||||
|  | #include "../storage_settings.h" | ||||||
|  | #include <power/power_service/power.h> | ||||||
|  | #include <furi-hal.h> | ||||||
|  | 
 | ||||||
|  | #define STORAGE_SETTINGS_SCENE_FACTORY_RESET_CONFIRM_COUNT 5 | ||||||
|  | 
 | ||||||
|  | static void | ||||||
|  |     storage_settings_scene_factory_reset_dialog_callback(DialogExResult result, void* context) { | ||||||
|  |     StorageSettings* app = context; | ||||||
|  | 
 | ||||||
|  |     view_dispatcher_send_custom_event(app->view_dispatcher, result); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void storage_settings_scene_factory_reset_on_enter(void* context) { | ||||||
|  |     StorageSettings* app = context; | ||||||
|  |     DialogEx* dialog_ex = app->dialog_ex; | ||||||
|  | 
 | ||||||
|  |     dialog_ex_set_context(dialog_ex, app); | ||||||
|  |     dialog_ex_set_result_callback(dialog_ex, storage_settings_scene_factory_reset_dialog_callback); | ||||||
|  | 
 | ||||||
|  |     dialog_ex_set_left_button_text(dialog_ex, "Back"); | ||||||
|  |     dialog_ex_set_right_button_text(dialog_ex, "Erase"); | ||||||
|  | 
 | ||||||
|  |     dialog_ex_set_header(dialog_ex, "Confirm Factory Reset", 64, 10, AlignCenter, AlignCenter); | ||||||
|  |     dialog_ex_set_text( | ||||||
|  |         dialog_ex, | ||||||
|  |         "Internal storage will be erased\r\nData and setting will be lost", | ||||||
|  |         64, | ||||||
|  |         32, | ||||||
|  |         AlignCenter, | ||||||
|  |         AlignCenter); | ||||||
|  | 
 | ||||||
|  |     view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool storage_settings_scene_factory_reset_on_event(void* context, SceneManagerEvent event) { | ||||||
|  |     StorageSettings* app = context; | ||||||
|  |     bool consumed = false; | ||||||
|  | 
 | ||||||
|  |     uint32_t counter = | ||||||
|  |         scene_manager_get_scene_state(app->scene_manager, StorageSettingsFactoryReset); | ||||||
|  | 
 | ||||||
|  |     if(event.type == SceneManagerEventTypeCustom) { | ||||||
|  |         switch(event.event) { | ||||||
|  |         case DialogExResultLeft: | ||||||
|  |             scene_manager_set_scene_state(app->scene_manager, StorageSettingsFactoryReset, 0); | ||||||
|  |             consumed = scene_manager_previous_scene(app->scene_manager); | ||||||
|  |             break; | ||||||
|  |         case DialogExResultRight: | ||||||
|  |             counter++; | ||||||
|  |             if(counter < STORAGE_SETTINGS_SCENE_FACTORY_RESET_CONFIRM_COUNT) { | ||||||
|  |                 string_printf( | ||||||
|  |                     app->text_string, | ||||||
|  |                     "%ld presses left", | ||||||
|  |                     STORAGE_SETTINGS_SCENE_FACTORY_RESET_CONFIRM_COUNT - counter); | ||||||
|  |                 dialog_ex_set_text( | ||||||
|  |                     app->dialog_ex, | ||||||
|  |                     string_get_cstr(app->text_string), | ||||||
|  |                     64, | ||||||
|  |                     32, | ||||||
|  |                     AlignCenter, | ||||||
|  |                     AlignCenter); | ||||||
|  |                 scene_manager_set_scene_state( | ||||||
|  |                     app->scene_manager, StorageSettingsFactoryReset, counter); | ||||||
|  |             } else { | ||||||
|  |                 furi_hal_bootloader_set_flags(FuriHalBootloaderFlagFactoryReset); | ||||||
|  |                 power_reboot(PowerBootModeNormal); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             consumed = true; | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     return consumed; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void storage_settings_scene_factory_reset_on_exit(void* context) { | ||||||
|  |     StorageSettings* app = context; | ||||||
|  |     DialogEx* dialog_ex = app->dialog_ex; | ||||||
|  | 
 | ||||||
|  |     dialog_ex_set_header(dialog_ex, NULL, 0, 0, AlignCenter, AlignCenter); | ||||||
|  |     dialog_ex_set_text(dialog_ex, NULL, 0, 0, AlignCenter, AlignTop); | ||||||
|  |     dialog_ex_set_icon(dialog_ex, 0, 0, NULL); | ||||||
|  |     dialog_ex_set_left_button_text(dialog_ex, NULL); | ||||||
|  |     dialog_ex_set_right_button_text(dialog_ex, NULL); | ||||||
|  |     dialog_ex_set_result_callback(dialog_ex, NULL); | ||||||
|  |     dialog_ex_set_context(dialog_ex, NULL); | ||||||
|  | 
 | ||||||
|  |     string_reset(app->text_string); | ||||||
|  | } | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
|     storage_settings_scene_format_confirm_dialog_callback(DialogExResult result, void* context) { |     storage_settings_scene_format_confirm_dialog_callback(DialogExResult result, void* context) { | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| 
 | 
 | ||||||
| static const NotificationMessage message_green_165 = { | static const NotificationMessage message_green_165 = { | ||||||
|     .type = NotificationMessageTypeLedGreen, |     .type = NotificationMessageTypeLedGreen, | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| #include <furi-hal-version.h> | #include <furi-hal-version.h> | ||||||
| 
 | 
 | ||||||
| static void | static void | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| 
 | 
 | ||||||
| static void storage_settings_scene_sd_info_dialog_callback(DialogExResult result, void* context) { | static void storage_settings_scene_sd_info_dialog_callback(DialogExResult result, void* context) { | ||||||
|     StorageSettings* app = context; |     StorageSettings* app = context; | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "../storage-settings.h" | #include "../storage_settings.h" | ||||||
| 
 | 
 | ||||||
| enum StorageSettingsStartSubmenuIndex { | enum StorageSettingsStartSubmenuIndex { | ||||||
|     StorageSettingsStartSubmenuIndexInternalInfo, |     StorageSettingsStartSubmenuIndexInternalInfo, | ||||||
| @ -6,6 +6,7 @@ enum StorageSettingsStartSubmenuIndex { | |||||||
|     StorageSettingsStartSubmenuIndexUnmount, |     StorageSettingsStartSubmenuIndexUnmount, | ||||||
|     StorageSettingsStartSubmenuIndexFormat, |     StorageSettingsStartSubmenuIndexFormat, | ||||||
|     StorageSettingsStartSubmenuIndexBenchy, |     StorageSettingsStartSubmenuIndexBenchy, | ||||||
|  |     StorageSettingsStartSubmenuIndexFactoryReset | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static void storage_settings_scene_start_submenu_callback(void* context, uint32_t index) { | static void storage_settings_scene_start_submenu_callback(void* context, uint32_t index) { | ||||||
| @ -48,6 +49,12 @@ void storage_settings_scene_start_on_enter(void* context) { | |||||||
|         StorageSettingsStartSubmenuIndexBenchy, |         StorageSettingsStartSubmenuIndexBenchy, | ||||||
|         storage_settings_scene_start_submenu_callback, |         storage_settings_scene_start_submenu_callback, | ||||||
|         app); |         app); | ||||||
|  |     submenu_add_item( | ||||||
|  |         submenu, | ||||||
|  |         "Factory Reset", | ||||||
|  |         StorageSettingsStartSubmenuIndexFactoryReset, | ||||||
|  |         storage_settings_scene_start_submenu_callback, | ||||||
|  |         app); | ||||||
| 
 | 
 | ||||||
|     submenu_set_selected_item( |     submenu_set_selected_item( | ||||||
|         submenu, scene_manager_get_scene_state(app->scene_manager, StorageSettingsStart)); |         submenu, scene_manager_get_scene_state(app->scene_manager, StorageSettingsStart)); | ||||||
| @ -93,6 +100,14 @@ bool storage_settings_scene_start_on_event(void* context, SceneManagerEvent even | |||||||
|             scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmark); |             scene_manager_next_scene(app->scene_manager, StorageSettingsBenchmark); | ||||||
|             consumed = true; |             consumed = true; | ||||||
|             break; |             break; | ||||||
|  |         case StorageSettingsStartSubmenuIndexFactoryReset: | ||||||
|  |             scene_manager_set_scene_state( | ||||||
|  |                 app->scene_manager, | ||||||
|  |                 StorageSettingsStart, | ||||||
|  |                 StorageSettingsStartSubmenuIndexFactoryReset); | ||||||
|  |             scene_manager_next_scene(app->scene_manager, StorageSettingsFactoryReset); | ||||||
|  |             consumed = true; | ||||||
|  |             break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     return consumed; |     return consumed; | ||||||
| @ -1,4 +1,4 @@ | |||||||
| #include "storage-settings.h" | #include "storage_settings.h" | ||||||
| 
 | 
 | ||||||
| static bool storage_settings_custom_event_callback(void* context, uint32_t event) { | static bool storage_settings_custom_event_callback(void* context, uint32_t event) { | ||||||
|     furi_assert(context); |     furi_assert(context); | ||||||
| @ -13,7 +13,7 @@ | |||||||
| #include <storage/storage.h> | #include <storage/storage.h> | ||||||
| #include <storage/storage-sd-api.h> | #include <storage/storage-sd-api.h> | ||||||
| 
 | 
 | ||||||
| #include "scenes/storage-settings-scene.h" | #include "scenes/storage_settings_scene.h" | ||||||
| 
 | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" { | extern "C" { | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 あく
						あく