Add lock on boot setting

This commit is contained in:
Willy-JL
2023-05-27 02:54:41 +01:00
parent 20063b84a6
commit 7e5b9f68c5
4 changed files with 24 additions and 1 deletions

View File

@@ -10,6 +10,14 @@ void xtreme_app_scene_interface_lockscreen_var_item_list_callback(void* context,
view_dispatcher_send_custom_event(app->view_dispatcher, index); view_dispatcher_send_custom_event(app->view_dispatcher, index);
} }
static void xtreme_app_scene_interface_lockscreen_lock_on_boot_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, value ? "ON" : "OFF");
XTREME_SETTINGS()->lock_on_boot = value;
app->save_settings = true;
}
static void xtreme_app_scene_interface_lockscreen_bad_pins_format_changed(VariableItem* item) { static void xtreme_app_scene_interface_lockscreen_bad_pins_format_changed(VariableItem* item) {
XtremeApp* app = variable_item_get_context(item); XtremeApp* app = variable_item_get_context(item);
bool value = variable_item_get_current_value_index(item); bool value = variable_item_get_current_value_index(item);
@@ -64,6 +72,15 @@ void xtreme_app_scene_interface_lockscreen_on_enter(void* context) {
VariableItemList* var_item_list = app->var_item_list; VariableItemList* var_item_list = app->var_item_list;
VariableItem* item; VariableItem* item;
item = variable_item_list_add(
var_item_list,
"Lock on Boot",
2,
xtreme_app_scene_interface_lockscreen_lock_on_boot_changed,
app);
variable_item_set_current_value_index(item, xtreme_settings->lock_on_boot);
variable_item_set_current_value_text(item, xtreme_settings->lock_on_boot ? "ON" : "OFF");
item = variable_item_list_add( item = variable_item_list_add(
var_item_list, var_item_list,
"Format on 10 bad PINs", "Format on 10 bad PINs",

View File

@@ -9,6 +9,7 @@
#include <cli/cli.h> #include <cli/cli.h>
#include <cli/cli_vcp.h> #include <cli/cli_vcp.h>
#include <locale/locale.h> #include <locale/locale.h>
#include <xtreme.h>
#include "animations/animation_manager.h" #include "animations/animation_manager.h"
#include "desktop/scenes/desktop_scene.h" #include "desktop/scenes/desktop_scene.h"
@@ -463,7 +464,7 @@ int32_t desktop_srv(void* p) {
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain); scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) { if(XTREME_SETTINGS()->lock_on_boot || furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) {
desktop_lock(desktop, true); desktop_lock(desktop, true);
} else { } else {
if(!loader_is_locked(desktop->loader)) { if(!loader_is_locked(desktop->loader)) {

View File

@@ -12,6 +12,7 @@ XtremeSettings xtreme_settings = {
.unlock_anims = false, // OFF .unlock_anims = false, // OFF
.fallback_anim = true, // ON .fallback_anim = true, // ON
.wii_menu = true, // ON .wii_menu = true, // ON
.lock_on_boot = false, // OFF
.bad_pins_format = false, // OFF .bad_pins_format = false, // OFF
.lockscreen_time = true, // ON .lockscreen_time = true, // ON
.lockscreen_seconds = false, // OFF .lockscreen_seconds = false, // OFF
@@ -57,6 +58,8 @@ void XTREME_SETTINGS_LOAD() {
flipper_format_rewind(file); flipper_format_rewind(file);
flipper_format_read_bool(file, "bad_pins_format", &x->bad_pins_format, 1); flipper_format_read_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
flipper_format_rewind(file); flipper_format_rewind(file);
flipper_format_read_bool(file, "lock_on_boot", &x->lock_on_boot, 1);
flipper_format_rewind(file);
flipper_format_read_bool(file, "lockscreen_time", &x->lockscreen_time, 1); flipper_format_read_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
flipper_format_rewind(file); flipper_format_rewind(file);
flipper_format_read_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1); flipper_format_read_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);
@@ -107,6 +110,7 @@ void XTREME_SETTINGS_SAVE() {
flipper_format_write_bool(file, "fallback_anim", &x->fallback_anim, 1); flipper_format_write_bool(file, "fallback_anim", &x->fallback_anim, 1);
flipper_format_write_bool(file, "wii_menu", &x->wii_menu, 1); flipper_format_write_bool(file, "wii_menu", &x->wii_menu, 1);
flipper_format_write_bool(file, "bad_pins_format", &x->bad_pins_format, 1); flipper_format_write_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
flipper_format_write_bool(file, "lock_on_boot", &x->lock_on_boot, 1);
flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1); flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1); flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);
flipper_format_write_bool(file, "lockscreen_date", &x->lockscreen_date, 1); flipper_format_write_bool(file, "lockscreen_date", &x->lockscreen_date, 1);

View File

@@ -20,6 +20,7 @@ typedef struct {
bool unlock_anims; bool unlock_anims;
bool fallback_anim; bool fallback_anim;
bool wii_menu; bool wii_menu;
bool lock_on_boot;
bool bad_pins_format; bool bad_pins_format;
bool lockscreen_time; bool lockscreen_time;
bool lockscreen_seconds; bool lockscreen_seconds;