Skip to content

Commit

Permalink
Disable storage settings if development files detected
Browse files Browse the repository at this point in the history
  • Loading branch information
Master92 committed Nov 30, 2023
1 parent 52ce3fc commit 62ad82e
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/ui/page_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ static page_options_t page_storage;
static lv_timer_t *page_storage_format_sd_timer = NULL;
static lv_timer_t *page_storage_repair_sd_timer = NULL;

static void disable_controls() {
page_storage.disable_controls = true;

for (int i = 0; i < ITEM_LIST_TOTAL - 1; i++) {
lv_obj_clear_flag(pp_storage.p_arr.panel[i], FLAG_SELECTABLE);
}
btn_group_enable(&page_storage.logging, !page_storage.disable_controls);
lv_obj_add_state(page_storage.format_sd, STATE_DISABLED);
lv_obj_add_state(page_storage.repair_sd, STATE_DISABLED);
}

static void enable_controls() {
page_storage.disable_controls = false;

for (int i = 0; i < ITEM_LIST_TOTAL - 1; i++) {
lv_obj_add_flag(pp_storage.p_arr.panel[i], FLAG_SELECTABLE);
}
btn_group_enable(&page_storage.logging, !page_storage.disable_controls);
lv_obj_clear_state(page_storage.format_sd, STATE_DISABLED);
lv_obj_clear_state(page_storage.repair_sd, STATE_DISABLED);
}

/**
* Cancel operation.
*/
Expand Down Expand Up @@ -371,14 +393,14 @@ static lv_obj_t *page_storage_create(lv_obj_t *parent, panel_arr_t *arr) {

if (g_setting.storage.selftest) {
lv_label_set_text(page_storage.note, "Self-Test is enabled, All storage options are disabled.");
page_storage.disable_controls = true;
disable_controls();
} else {
if (file_exists(DEVELOP_SCRIPT) || file_exists(APP_BIN_FILE)) {
char text[256];
snprintf(text, sizeof(text), "Detected files being accessed by SD Card, All storage options are disabled.\n"
"Remove the following files from the SD Card and try again:\n" DEVELOP_SCRIPT "\n" APP_BIN_FILE);
lv_label_set_text(page_storage.note, text);
page_storage.disable_controls = true;
disable_controls();
}
}

Expand Down Expand Up @@ -503,10 +525,10 @@ page_pack_t pp_storage = {
static void *page_storage_repair_thread(void *arg) {
if (!page_storage.disable_controls) {
page_storage.is_auto_sd_repair_active = true;
page_storage.disable_controls = true;
disable_controls();
lv_label_set_text(page_storage.note, "SD Card integrity check is active, controls are disabled until process has completed.");
page_storage_repair_sd();
page_storage.disable_controls = false;
enable_controls();
lv_label_set_text(page_storage.note, "");
page_storage.is_auto_sd_repair_active = false;
}
Expand Down

0 comments on commit 62ad82e

Please sign in to comment.