[FL-2494, FL-2497] PIN Lock refactoring, IR library fix (#1167)

* PIN Lock refactoring
* Change tv.ir file type to prevent opening from archive
* Manifest update
* Assets: enforce sorting in fs traversal

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Nikolay Minaylov
2022-04-27 19:30:37 +03:00
committed by GitHub
parent c60562a02c
commit 2034b6ac4a
15 changed files with 168 additions and 136 deletions

View File

@@ -10,6 +10,7 @@
#include "../views/desktop_view_lock_menu.h"
#include "desktop_scene_i.h"
#include "desktop_scene.h"
#include "../helpers/pin_lock.h"
#define TAG "DesktopSceneLock"
@@ -53,7 +54,7 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
break;
case DesktopLockMenuEventPinLock:
if(desktop->settings.pin_code.length > 0) {
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
desktop_pin_lock();
desktop_lock(desktop);
} else {
LoaderStatus status =
@@ -64,7 +65,6 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) {
FURI_LOG_E(TAG, "Unable to start desktop settings");
}
}
consumed = true;
break;
case DesktopLockMenuEventExit:

View File

@@ -7,7 +7,7 @@
#include "../desktop.h"
#include "../desktop_i.h"
#include "../desktop_helpers.h"
#include "../helpers/pin_lock.h"
#include "../animations/animation_manager.h"
#include "../views/desktop_events.h"
#include "../views/desktop_view_pin_input.h"
@@ -45,14 +45,17 @@ void desktop_scene_locked_on_enter(void* context) {
bool switch_to_timeout_scene = false;
uint32_t state = scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLocked);
if(state == SCENE_LOCKED_FIRST_ENTER) {
bool pin_locked = furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock);
desktop_helpers_lock_system(desktop, pin_locked);
bool pin_locked = desktop_pin_lock_is_locked();
view_port_enabled_set(desktop->lock_viewport, true);
Gui* gui = furi_record_open("gui");
gui_set_lockdown(gui, true);
furi_record_close("gui");
if(pin_locked) {
LOAD_DESKTOP_SETTINGS(&desktop->settings);
desktop_view_locked_lock(desktop->locked_view, true);
uint32_t pin_fails = furi_hal_rtc_get_pin_fails();
uint32_t pin_timeout = desktop_helpers_get_pin_fail_timeout(pin_fails);
if(pin_timeout) {
uint32_t pin_timeout = desktop_pin_lock_get_fail_timeout();
if(pin_timeout > 0) {
scene_manager_set_scene_state(
desktop->scene_manager, DesktopScenePinTimeout, pin_timeout);
switch_to_timeout_scene = true;

View File

@@ -12,7 +12,7 @@
#include "../animations/animation_manager.h"
#include "../views/desktop_events.h"
#include "../views/desktop_view_pin_input.h"
#include "../desktop_helpers.h"
#include "../helpers/pin_lock.h"
#include "desktop_scene.h"
#include "desktop_scene_i.h"
@@ -54,7 +54,7 @@ static void desktop_scene_pin_input_back_callback(void* context) {
static void desktop_scene_pin_input_done_callback(const PinCode* pin_code, void* context) {
Desktop* desktop = (Desktop*)context;
if(pins_are_equal(&desktop->settings.pin_code, pin_code)) {
if(desktop_pin_lock_verify(&desktop->settings.pin_code, pin_code)) {
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopPinInputEventUnlocked);
} else {
view_dispatcher_send_custom_event(
@@ -97,17 +97,14 @@ void desktop_scene_pin_input_on_enter(void* context) {
bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) {
Desktop* desktop = (Desktop*)context;
bool consumed = false;
uint32_t pin_fails = 0;
uint32_t pin_timeout = 0;
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case DesktopPinInputEventUnlockFailed:
pin_fails = furi_hal_rtc_get_pin_fails();
pin_fails++;
furi_hal_rtc_set_pin_fails(pin_fails);
uint32_t pin_timeout = desktop_helpers_get_pin_fail_timeout(pin_fails);
pin_timeout = desktop_pin_lock_get_fail_timeout();
if(pin_timeout > 0) {
desktop_helpers_emit_error_notification();
desktop_pin_lock_error_notify();
scene_manager_set_scene_state(
desktop->scene_manager, DesktopScenePinTimeout, pin_timeout);
scene_manager_next_scene(desktop->scene_manager, DesktopScenePinTimeout);
@@ -129,6 +126,7 @@ bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) {
consumed = true;
break;
case DesktopPinInputEventUnlocked:
desktop_pin_unlock();
desktop_unlock(desktop);
consumed = true;
break;