Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autolock with pin code #338

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions applications/services/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
return true;
case DesktopGlobalAutoLock:
if(!loader_is_locked(desktop->loader)) {
if(desktop->settings.auto_lock_with_pin && desktop->settings.pin_code.length > 0) {
desktop_pin_lock(&desktop->settings);
}
desktop_lock(desktop);
}
return true;
Expand Down
3 changes: 2 additions & 1 deletion applications/services/desktop/desktop_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <toolbox/saved_struct.h>
#include <storage/storage.h>

#define DESKTOP_SETTINGS_VER (6)
#define DESKTOP_SETTINGS_VER (7)

#define DESKTOP_SETTINGS_PATH INT_PATH(DESKTOP_SETTINGS_FILE_NAME)
#define DESKTOP_SETTINGS_MAGIC (0x17)
Expand Down Expand Up @@ -63,4 +63,5 @@ typedef struct {
uint32_t auto_lock_delay_ms;
uint8_t displayBatteryPercentage;
uint8_t dummy_mode;
bool auto_lock_with_pin;
} DesktopSettings;
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ static void desktop_settings_scene_start_auto_lock_delay_changed(VariableItem* i
app->settings.auto_lock_delay_ms = auto_lock_delay_value[index];
}

static void desktop_settings_scene_start_auto_lock_pin_changed(VariableItem* item) {
DesktopSettingsApp* app = variable_item_get_context(item);
uint8_t value = variable_item_get_current_value_index(item);

variable_item_set_current_value_text(item, value ? "ON" : "OFF");
app->settings.auto_lock_with_pin = value;
}

void desktop_settings_scene_start_on_enter(void* context) {
DesktopSettingsApp* app = context;
VariableItemList* variable_item_list = app->variable_item_list;
Expand Down Expand Up @@ -87,6 +95,16 @@ void desktop_settings_scene_start_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, auto_lock_delay_text[value_index]);

item = variable_item_list_add(
variable_item_list,
"Auto Lock Pin",
2,
desktop_settings_scene_start_auto_lock_pin_changed,
app);

variable_item_set_current_value_index(item, app->settings.auto_lock_with_pin);
variable_item_set_current_value_text(item, app->settings.auto_lock_with_pin ? "ON" : "OFF");

item = variable_item_list_add(
variable_item_list,
"Battery View",
Expand Down