[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:
		
							parent
							
								
									c60562a02c
								
							
						
					
					
						commit
						2034b6ac4a
					
				| @ -14,7 +14,7 @@ | |||||||
| #include "desktop/views/desktop_view_pin_input.h" | #include "desktop/views/desktop_view_pin_input.h" | ||||||
| #include "desktop/views/desktop_view_pin_timeout.h" | #include "desktop/views/desktop_view_pin_timeout.h" | ||||||
| #include "desktop_i.h" | #include "desktop_i.h" | ||||||
| #include "desktop_helpers.h" | #include "helpers/pin_lock.h" | ||||||
| 
 | 
 | ||||||
| static void desktop_auto_lock_arm(Desktop*); | static void desktop_auto_lock_arm(Desktop*); | ||||||
| static void desktop_auto_lock_inhibit(Desktop*); | static void desktop_auto_lock_inhibit(Desktop*); | ||||||
| @ -117,7 +117,6 @@ static void desktop_auto_lock_inhibit(Desktop* desktop) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void desktop_lock(Desktop* desktop) { | void desktop_lock(Desktop* desktop) { | ||||||
|     furi_hal_rtc_set_pin_fails(0); |  | ||||||
|     desktop_auto_lock_inhibit(desktop); |     desktop_auto_lock_inhibit(desktop); | ||||||
|     scene_manager_set_scene_state( |     scene_manager_set_scene_state( | ||||||
|         desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER); |         desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER); | ||||||
| @ -126,8 +125,10 @@ void desktop_lock(Desktop* desktop) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void desktop_unlock(Desktop* desktop) { | void desktop_unlock(Desktop* desktop) { | ||||||
|     furi_hal_rtc_set_pin_fails(0); |     view_port_enabled_set(desktop->lock_viewport, false); | ||||||
|     desktop_helpers_unlock_system(desktop); |     Gui* gui = furi_record_open("gui"); | ||||||
|  |     gui_set_lockdown(gui, false); | ||||||
|  |     furi_record_close("gui"); | ||||||
|     desktop_view_locked_unlock(desktop->locked_view); |     desktop_view_locked_unlock(desktop->locked_view); | ||||||
|     scene_manager_search_and_switch_to_previous_scene(desktop->scene_manager, DesktopSceneMain); |     scene_manager_search_and_switch_to_previous_scene(desktop->scene_manager, DesktopSceneMain); | ||||||
|     desktop_auto_lock_arm(desktop); |     desktop_auto_lock_arm(desktop); | ||||||
| @ -301,18 +302,15 @@ int32_t desktop_srv(void* p) { | |||||||
| 
 | 
 | ||||||
|     bool loaded = LOAD_DESKTOP_SETTINGS(&desktop->settings); |     bool loaded = LOAD_DESKTOP_SETTINGS(&desktop->settings); | ||||||
|     if(!loaded) { |     if(!loaded) { | ||||||
|         furi_hal_rtc_reset_flag(FuriHalRtcFlagLock); |  | ||||||
|         memset(&desktop->settings, 0, sizeof(desktop->settings)); |         memset(&desktop->settings, 0, sizeof(desktop->settings)); | ||||||
|         SAVE_DESKTOP_SETTINGS(&desktop->settings); |         SAVE_DESKTOP_SETTINGS(&desktop->settings); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain); |     scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain); | ||||||
| 
 | 
 | ||||||
|     if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock) && !desktop->settings.pin_code.length) { |     desktop_pin_lock_init(&desktop->settings); | ||||||
|         furi_hal_rtc_reset_flag(FuriHalRtcFlagLock); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) { |     if(!desktop_pin_lock_is_locked()) { | ||||||
|         if(!loader_is_locked(desktop->loader)) { |         if(!loader_is_locked(desktop->loader)) { | ||||||
|             desktop_auto_lock_arm(desktop); |             desktop_auto_lock_arm(desktop); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -1,82 +0,0 @@ | |||||||
| #include <notification/notification.h> |  | ||||||
| #include <notification/notification_messages.h> |  | ||||||
| #include <stddef.h> |  | ||||||
| #include <furi.h> |  | ||||||
| #include <furi_hal.h> |  | ||||||
| #include <gui/gui.h> |  | ||||||
| 
 |  | ||||||
| #include "desktop_helpers.h" |  | ||||||
| #include "desktop_i.h" |  | ||||||
| 
 |  | ||||||
| static const NotificationSequence sequence_pin_fail = { |  | ||||||
|     &message_display_on, |  | ||||||
| 
 |  | ||||||
|     &message_red_255, |  | ||||||
|     &message_vibro_on, |  | ||||||
|     &message_delay_100, |  | ||||||
|     &message_vibro_off, |  | ||||||
|     &message_red_0, |  | ||||||
| 
 |  | ||||||
|     &message_delay_250, |  | ||||||
| 
 |  | ||||||
|     &message_red_255, |  | ||||||
|     &message_vibro_on, |  | ||||||
|     &message_delay_100, |  | ||||||
|     &message_vibro_off, |  | ||||||
|     &message_red_0, |  | ||||||
|     NULL, |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| static const uint8_t desktop_helpers_fails_timeout[] = { |  | ||||||
|     0, |  | ||||||
|     0, |  | ||||||
|     0, |  | ||||||
|     0, |  | ||||||
|     30, |  | ||||||
|     60, |  | ||||||
|     90, |  | ||||||
|     120, |  | ||||||
|     150, |  | ||||||
|     180, |  | ||||||
|     /* +60 for every next fail */ |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| void desktop_helpers_emit_error_notification() { |  | ||||||
|     NotificationApp* notification = furi_record_open("notification"); |  | ||||||
|     notification_message(notification, &sequence_pin_fail); |  | ||||||
|     furi_record_close("notification"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void desktop_helpers_lock_system(Desktop* desktop, bool hard_lock) { |  | ||||||
|     view_port_enabled_set(desktop->lock_viewport, true); |  | ||||||
|     if(hard_lock) { |  | ||||||
|         furi_hal_rtc_set_flag(FuriHalRtcFlagLock); |  | ||||||
|         furi_hal_usb_disable(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     Gui* gui = furi_record_open("gui"); |  | ||||||
|     gui_set_lockdown(gui, true); |  | ||||||
|     furi_record_close("gui"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void desktop_helpers_unlock_system(Desktop* desktop) { |  | ||||||
|     furi_hal_rtc_reset_flag(FuriHalRtcFlagLock); |  | ||||||
|     furi_hal_usb_enable(); |  | ||||||
|     view_port_enabled_set(desktop->lock_viewport, false); |  | ||||||
| 
 |  | ||||||
|     Gui* gui = furi_record_open("gui"); |  | ||||||
|     gui_set_lockdown(gui, false); |  | ||||||
|     furi_record_close("gui"); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| uint32_t desktop_helpers_get_pin_fail_timeout(uint32_t pin_fails) { |  | ||||||
|     uint32_t pin_timeout = 0; |  | ||||||
|     uint32_t max_index = COUNT_OF(desktop_helpers_fails_timeout) - 1; |  | ||||||
|     if(pin_fails <= max_index) { |  | ||||||
|         pin_timeout = desktop_helpers_fails_timeout[pin_fails]; |  | ||||||
|     } else { |  | ||||||
|         pin_timeout = desktop_helpers_fails_timeout[max_index] + (pin_fails - max_index) * 60; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return pin_timeout; |  | ||||||
| } |  | ||||||
| @ -1,9 +0,0 @@ | |||||||
| #pragma once |  | ||||||
| #include <stdbool.h> |  | ||||||
| #include <stdint.h> |  | ||||||
| #include "desktop.h" |  | ||||||
| 
 |  | ||||||
| void desktop_helpers_emit_error_notification(); |  | ||||||
| void desktop_helpers_lock_system(Desktop* desktop, bool hard_lock); |  | ||||||
| void desktop_helpers_unlock_system(Desktop* desktop); |  | ||||||
| uint32_t desktop_helpers_get_pin_fail_timeout(uint32_t pin_fails); |  | ||||||
| @ -41,15 +41,3 @@ typedef struct { | |||||||
|     PinCode pin_code; |     PinCode pin_code; | ||||||
|     uint32_t auto_lock_delay_ms; |     uint32_t auto_lock_delay_ms; | ||||||
| } DesktopSettings; | } DesktopSettings; | ||||||
| 
 |  | ||||||
| static inline bool pins_are_equal(const PinCode* pin_code1, const PinCode* pin_code2) { |  | ||||||
|     furi_assert(pin_code1); |  | ||||||
|     furi_assert(pin_code2); |  | ||||||
|     bool result = false; |  | ||||||
| 
 |  | ||||||
|     if(pin_code1->length == pin_code2->length) { |  | ||||||
|         result = !memcmp(pin_code1->data, pin_code2->data, pin_code1->length); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     return result; |  | ||||||
| } |  | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <furi/check.h> | #include <furi/check.h> | ||||||
| #include <gui/scene_manager.h> | #include <gui/scene_manager.h> | ||||||
| 
 | #include "../../helpers/pin_lock.h" | ||||||
| #include "../desktop_settings_app.h" | #include "../desktop_settings_app.h" | ||||||
| #include "desktop/desktop_settings/desktop_settings.h" | #include "desktop/desktop_settings/desktop_settings.h" | ||||||
| #include "desktop/views/desktop_view_pin_input.h" | #include "desktop/views/desktop_view_pin_input.h" | ||||||
| @ -18,7 +18,7 @@ static void pin_auth_done_callback(const PinCode* pin_code, void* context) { | |||||||
|     DesktopSettingsApp* app = context; |     DesktopSettingsApp* app = context; | ||||||
| 
 | 
 | ||||||
|     app->pincode_buffer = *pin_code; |     app->pincode_buffer = *pin_code; | ||||||
|     if(pins_are_equal(&app->settings.pin_code, pin_code)) { |     if(desktop_pins_are_equal(&app->settings.pin_code, pin_code)) { | ||||||
|         view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL); |         view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL); | ||||||
|     } else { |     } else { | ||||||
|         view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT); |         view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT); | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ | |||||||
| #include "desktop/views/desktop_view_pin_input.h" | #include "desktop/views/desktop_view_pin_input.h" | ||||||
| #include "desktop_settings_scene.h" | #include "desktop_settings_scene.h" | ||||||
| #include "desktop_settings_scene_i.h" | #include "desktop_settings_scene_i.h" | ||||||
| #include "../../desktop_helpers.h" | #include "../../helpers/pin_lock.h" | ||||||
| #include "../desktop_settings_app.h" | #include "../desktop_settings_app.h" | ||||||
| 
 | 
 | ||||||
| #define SCENE_EVENT_EXIT (0U) | #define SCENE_EVENT_EXIT (0U) | ||||||
| @ -25,7 +25,7 @@ static void pin_error_done_callback(const PinCode* pin_code, void* context) { | |||||||
| 
 | 
 | ||||||
| void desktop_settings_scene_pin_error_on_enter(void* context) { | void desktop_settings_scene_pin_error_on_enter(void* context) { | ||||||
|     DesktopSettingsApp* app = context; |     DesktopSettingsApp* app = context; | ||||||
|     desktop_helpers_emit_error_notification(); |     desktop_pin_lock_error_notify(); | ||||||
| 
 | 
 | ||||||
|     desktop_view_pin_input_set_context(app->pin_input_view, app); |     desktop_view_pin_input_set_context(app->pin_input_view, app); | ||||||
|     desktop_view_pin_input_set_back_callback(app->pin_input_view, pin_error_back_callback); |     desktop_view_pin_input_set_back_callback(app->pin_input_view, pin_error_back_callback); | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
| #include "desktop/views/desktop_view_pin_input.h" | #include "desktop/views/desktop_view_pin_input.h" | ||||||
| #include "desktop_settings_scene.h" | #include "desktop_settings_scene.h" | ||||||
| #include "desktop_settings_scene_i.h" | #include "desktop_settings_scene_i.h" | ||||||
|  | #include "../../helpers/pin_lock.h" | ||||||
| 
 | 
 | ||||||
| #define SCENE_EVENT_EXIT (0U) | #define SCENE_EVENT_EXIT (0U) | ||||||
| #define SCENE_EVENT_1ST_PIN_ENTERED (1U) | #define SCENE_EVENT_1ST_PIN_ENTERED (1U) | ||||||
| @ -24,7 +25,7 @@ static void pin_setup_done_callback(const PinCode* pin_code, void* context) { | |||||||
|         view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_1ST_PIN_ENTERED); |         view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_1ST_PIN_ENTERED); | ||||||
|     } else { |     } else { | ||||||
|         app->pincode_buffer_filled = false; |         app->pincode_buffer_filled = false; | ||||||
|         if(pins_are_equal(&app->pincode_buffer, pin_code)) { |         if(desktop_pins_are_equal(&app->pincode_buffer, pin_code)) { | ||||||
|             view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL); |             view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_EQUAL); | ||||||
|         } else { |         } else { | ||||||
|             view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT); |             view_dispatcher_send_custom_event(app->view_dispatcher, SCENE_EVENT_PINS_DIFFERENT); | ||||||
|  | |||||||
							
								
								
									
										112
									
								
								applications/desktop/helpers/pin_lock.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								applications/desktop/helpers/pin_lock.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,112 @@ | |||||||
|  | 
 | ||||||
|  | #include <notification/notification.h> | ||||||
|  | #include <notification/notification_messages.h> | ||||||
|  | #include <stddef.h> | ||||||
|  | #include <furi.h> | ||||||
|  | #include <furi_hal.h> | ||||||
|  | #include <gui/gui.h> | ||||||
|  | 
 | ||||||
|  | #include "../helpers/pin_lock.h" | ||||||
|  | #include "../desktop_i.h" | ||||||
|  | 
 | ||||||
|  | static const NotificationSequence sequence_pin_fail = { | ||||||
|  |     &message_display_on, | ||||||
|  | 
 | ||||||
|  |     &message_red_255, | ||||||
|  |     &message_vibro_on, | ||||||
|  |     &message_delay_100, | ||||||
|  |     &message_vibro_off, | ||||||
|  |     &message_red_0, | ||||||
|  | 
 | ||||||
|  |     &message_delay_250, | ||||||
|  | 
 | ||||||
|  |     &message_red_255, | ||||||
|  |     &message_vibro_on, | ||||||
|  |     &message_delay_100, | ||||||
|  |     &message_vibro_off, | ||||||
|  |     &message_red_0, | ||||||
|  |     NULL, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | static const uint8_t desktop_helpers_fails_timeout[] = { | ||||||
|  |     0, | ||||||
|  |     0, | ||||||
|  |     0, | ||||||
|  |     0, | ||||||
|  |     30, | ||||||
|  |     60, | ||||||
|  |     90, | ||||||
|  |     120, | ||||||
|  |     150, | ||||||
|  |     180, | ||||||
|  |     /* +60 for every next fail */ | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | void desktop_pin_lock_error_notify() { | ||||||
|  |     NotificationApp* notification = furi_record_open("notification"); | ||||||
|  |     notification_message(notification, &sequence_pin_fail); | ||||||
|  |     furi_record_close("notification"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | uint32_t desktop_pin_lock_get_fail_timeout() { | ||||||
|  |     uint32_t pin_fails = furi_hal_rtc_get_pin_fails(); | ||||||
|  |     uint32_t pin_timeout = 0; | ||||||
|  |     uint32_t max_index = COUNT_OF(desktop_helpers_fails_timeout) - 1; | ||||||
|  |     if(pin_fails <= max_index) { | ||||||
|  |         pin_timeout = desktop_helpers_fails_timeout[pin_fails]; | ||||||
|  |     } else { | ||||||
|  |         pin_timeout = desktop_helpers_fails_timeout[max_index] + (pin_fails - max_index) * 60; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return pin_timeout; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void desktop_pin_lock() { | ||||||
|  |     furi_hal_rtc_set_pin_fails(0); | ||||||
|  |     furi_hal_rtc_set_flag(FuriHalRtcFlagLock); | ||||||
|  |     furi_hal_usb_disable(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void desktop_pin_unlock() { | ||||||
|  |     furi_hal_rtc_reset_flag(FuriHalRtcFlagLock); | ||||||
|  |     furi_hal_usb_enable(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void desktop_pin_lock_init(DesktopSettings* settings) { | ||||||
|  |     if(settings->pin_code.length > 0) { | ||||||
|  |         furi_hal_rtc_set_flag(FuriHalRtcFlagLock); | ||||||
|  |         furi_hal_usb_disable(); | ||||||
|  |     } else { | ||||||
|  |         furi_hal_rtc_reset_flag(FuriHalRtcFlagLock); | ||||||
|  |         furi_hal_usb_enable(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool desktop_pin_lock_verify(const PinCode* pin_set, const PinCode* pin_entered) { | ||||||
|  |     bool result = false; | ||||||
|  |     if(desktop_pins_are_equal(pin_set, pin_entered)) { | ||||||
|  |         furi_hal_rtc_set_pin_fails(0); | ||||||
|  |         result = true; | ||||||
|  |     } else { | ||||||
|  |         uint32_t pin_fails = furi_hal_rtc_get_pin_fails(); | ||||||
|  |         furi_hal_rtc_set_pin_fails(pin_fails + 1); | ||||||
|  |         result = false; | ||||||
|  |     } | ||||||
|  |     return result; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool desktop_pin_lock_is_locked() { | ||||||
|  |     return furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool desktop_pins_are_equal(const PinCode* pin_code1, const PinCode* pin_code2) { | ||||||
|  |     furi_assert(pin_code1); | ||||||
|  |     furi_assert(pin_code2); | ||||||
|  |     bool result = false; | ||||||
|  | 
 | ||||||
|  |     if(pin_code1->length == pin_code2->length) { | ||||||
|  |         result = !memcmp(pin_code1->data, pin_code2->data, pin_code1->length); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return result; | ||||||
|  | } | ||||||
							
								
								
									
										21
									
								
								applications/desktop/helpers/pin_lock.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								applications/desktop/helpers/pin_lock.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | |||||||
|  | #pragma once | ||||||
|  | #include <stdbool.h> | ||||||
|  | #include <stdint.h> | ||||||
|  | #include "../desktop.h" | ||||||
|  | #include "../desktop_settings/desktop_settings.h" | ||||||
|  | 
 | ||||||
|  | void desktop_pin_lock_error_notify(); | ||||||
|  | 
 | ||||||
|  | uint32_t desktop_pin_lock_get_fail_timeout(); | ||||||
|  | 
 | ||||||
|  | void desktop_pin_lock(); | ||||||
|  | 
 | ||||||
|  | void desktop_pin_unlock(); | ||||||
|  | 
 | ||||||
|  | bool desktop_pin_lock_is_locked(); | ||||||
|  | 
 | ||||||
|  | void desktop_pin_lock_init(DesktopSettings* settings); | ||||||
|  | 
 | ||||||
|  | bool desktop_pin_lock_verify(const PinCode* pin_set, const PinCode* pin_entered); | ||||||
|  | 
 | ||||||
|  | bool desktop_pins_are_equal(const PinCode* pin_code1, const PinCode* pin_code2); | ||||||
| @ -10,6 +10,7 @@ | |||||||
| #include "../views/desktop_view_lock_menu.h" | #include "../views/desktop_view_lock_menu.h" | ||||||
| #include "desktop_scene_i.h" | #include "desktop_scene_i.h" | ||||||
| #include "desktop_scene.h" | #include "desktop_scene.h" | ||||||
|  | #include "../helpers/pin_lock.h" | ||||||
| 
 | 
 | ||||||
| #define TAG "DesktopSceneLock" | #define TAG "DesktopSceneLock" | ||||||
| 
 | 
 | ||||||
| @ -53,7 +54,7 @@ bool desktop_scene_lock_menu_on_event(void* context, SceneManagerEvent event) { | |||||||
|             break; |             break; | ||||||
|         case DesktopLockMenuEventPinLock: |         case DesktopLockMenuEventPinLock: | ||||||
|             if(desktop->settings.pin_code.length > 0) { |             if(desktop->settings.pin_code.length > 0) { | ||||||
|                 furi_hal_rtc_set_flag(FuriHalRtcFlagLock); |                 desktop_pin_lock(); | ||||||
|                 desktop_lock(desktop); |                 desktop_lock(desktop); | ||||||
|             } else { |             } else { | ||||||
|                 LoaderStatus status = |                 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"); |                     FURI_LOG_E(TAG, "Unable to start desktop settings"); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 |  | ||||||
|             consumed = true; |             consumed = true; | ||||||
|             break; |             break; | ||||||
|         case DesktopLockMenuEventExit: |         case DesktopLockMenuEventExit: | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ | |||||||
| 
 | 
 | ||||||
| #include "../desktop.h" | #include "../desktop.h" | ||||||
| #include "../desktop_i.h" | #include "../desktop_i.h" | ||||||
| #include "../desktop_helpers.h" | #include "../helpers/pin_lock.h" | ||||||
| #include "../animations/animation_manager.h" | #include "../animations/animation_manager.h" | ||||||
| #include "../views/desktop_events.h" | #include "../views/desktop_events.h" | ||||||
| #include "../views/desktop_view_pin_input.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; |     bool switch_to_timeout_scene = false; | ||||||
|     uint32_t state = scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLocked); |     uint32_t state = scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLocked); | ||||||
|     if(state == SCENE_LOCKED_FIRST_ENTER) { |     if(state == SCENE_LOCKED_FIRST_ENTER) { | ||||||
|         bool pin_locked = furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock); |         bool pin_locked = desktop_pin_lock_is_locked(); | ||||||
|         desktop_helpers_lock_system(desktop, pin_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) { |         if(pin_locked) { | ||||||
|             LOAD_DESKTOP_SETTINGS(&desktop->settings); |             LOAD_DESKTOP_SETTINGS(&desktop->settings); | ||||||
|             desktop_view_locked_lock(desktop->locked_view, true); |             desktop_view_locked_lock(desktop->locked_view, true); | ||||||
|             uint32_t pin_fails = furi_hal_rtc_get_pin_fails(); |             uint32_t pin_timeout = desktop_pin_lock_get_fail_timeout(); | ||||||
|             uint32_t pin_timeout = desktop_helpers_get_pin_fail_timeout(pin_fails); |             if(pin_timeout > 0) { | ||||||
|             if(pin_timeout) { |  | ||||||
|                 scene_manager_set_scene_state( |                 scene_manager_set_scene_state( | ||||||
|                     desktop->scene_manager, DesktopScenePinTimeout, pin_timeout); |                     desktop->scene_manager, DesktopScenePinTimeout, pin_timeout); | ||||||
|                 switch_to_timeout_scene = true; |                 switch_to_timeout_scene = true; | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ | |||||||
| #include "../animations/animation_manager.h" | #include "../animations/animation_manager.h" | ||||||
| #include "../views/desktop_events.h" | #include "../views/desktop_events.h" | ||||||
| #include "../views/desktop_view_pin_input.h" | #include "../views/desktop_view_pin_input.h" | ||||||
| #include "../desktop_helpers.h" | #include "../helpers/pin_lock.h" | ||||||
| #include "desktop_scene.h" | #include "desktop_scene.h" | ||||||
| #include "desktop_scene_i.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) { | static void desktop_scene_pin_input_done_callback(const PinCode* pin_code, void* context) { | ||||||
|     Desktop* desktop = (Desktop*)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); |         view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopPinInputEventUnlocked); | ||||||
|     } else { |     } else { | ||||||
|         view_dispatcher_send_custom_event( |         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) { | bool desktop_scene_pin_input_on_event(void* context, SceneManagerEvent event) { | ||||||
|     Desktop* desktop = (Desktop*)context; |     Desktop* desktop = (Desktop*)context; | ||||||
|     bool consumed = false; |     bool consumed = false; | ||||||
|     uint32_t pin_fails = 0; |     uint32_t pin_timeout = 0; | ||||||
| 
 | 
 | ||||||
|     if(event.type == SceneManagerEventTypeCustom) { |     if(event.type == SceneManagerEventTypeCustom) { | ||||||
|         switch(event.event) { |         switch(event.event) { | ||||||
|         case DesktopPinInputEventUnlockFailed: |         case DesktopPinInputEventUnlockFailed: | ||||||
|             pin_fails = furi_hal_rtc_get_pin_fails(); |             pin_timeout = desktop_pin_lock_get_fail_timeout(); | ||||||
|             pin_fails++; |  | ||||||
|             furi_hal_rtc_set_pin_fails(pin_fails); |  | ||||||
|             uint32_t pin_timeout = desktop_helpers_get_pin_fail_timeout(pin_fails); |  | ||||||
|             if(pin_timeout > 0) { |             if(pin_timeout > 0) { | ||||||
|                 desktop_helpers_emit_error_notification(); |                 desktop_pin_lock_error_notify(); | ||||||
|                 scene_manager_set_scene_state( |                 scene_manager_set_scene_state( | ||||||
|                     desktop->scene_manager, DesktopScenePinTimeout, pin_timeout); |                     desktop->scene_manager, DesktopScenePinTimeout, pin_timeout); | ||||||
|                 scene_manager_next_scene(desktop->scene_manager, DesktopScenePinTimeout); |                 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; |             consumed = true; | ||||||
|             break; |             break; | ||||||
|         case DesktopPinInputEventUnlocked: |         case DesktopPinInputEventUnlocked: | ||||||
|  |             desktop_pin_unlock(); | ||||||
|             desktop_unlock(desktop); |             desktop_unlock(desktop); | ||||||
|             consumed = true; |             consumed = true; | ||||||
|             break; |             break; | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| V:0 | V:0 | ||||||
| T:1650389893 | T:1651076680 | ||||||
| D:badusb | D:badusb | ||||||
| D:dolphin | D:dolphin | ||||||
| D:infrared | D:infrared | ||||||
| @ -222,7 +222,7 @@ F:33b8fde22f34ef556b64b77164bc19b0:578:dolphin/L3_Lab_research_128x54/frame_8.bm | |||||||
| F:f267f0654781049ca323b11bb4375519:581:dolphin/L3_Lab_research_128x54/frame_9.bm | F:f267f0654781049ca323b11bb4375519:581:dolphin/L3_Lab_research_128x54/frame_9.bm | ||||||
| F:41106c0cbc5144f151b2b2d3daaa0527:727:dolphin/L3_Lab_research_128x54/meta.txt | F:41106c0cbc5144f151b2b2d3daaa0527:727:dolphin/L3_Lab_research_128x54/meta.txt | ||||||
| D:infrared/assets | D:infrared/assets | ||||||
| F:5b16e1a59daf3ef1d0fc95b3b5596d67:74300:infrared/assets/tv.ir | F:d895fda2f48c6cc4c55e8a398ff52e43:74300:infrared/assets/tv.ir | ||||||
| D:nfc/assets | D:nfc/assets | ||||||
| F:c6826a621d081d68309e4be424d3d974:4715:nfc/assets/aid.nfc | F:c6826a621d081d68309e4be424d3d974:4715:nfc/assets/aid.nfc | ||||||
| F:86efbebdf41bb6bf15cc51ef88f069d5:2565:nfc/assets/country_code.nfc | F:86efbebdf41bb6bf15cc51ef88f069d5:2565:nfc/assets/country_code.nfc | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| Filetype: IR signals file | Filetype: IR library file | ||||||
| Version: 1 | Version: 1 | ||||||
| #  | #  | ||||||
| name: POWER | name: POWER | ||||||
|  | |||||||
| @ -135,6 +135,8 @@ class Manifest: | |||||||
| 
 | 
 | ||||||
|     def create(self, directory_path, ignore_files=["Manifest"]): |     def create(self, directory_path, ignore_files=["Manifest"]): | ||||||
|         for root, dirs, files in os.walk(directory_path): |         for root, dirs, files in os.walk(directory_path): | ||||||
|  |             dirs.sort() | ||||||
|  |             files.sort() | ||||||
|             relative_root = root.replace(directory_path, "", 1) |             relative_root = root.replace(directory_path, "", 1) | ||||||
|             if relative_root.startswith("/"): |             if relative_root.startswith("/"): | ||||||
|                 relative_root = relative_root[1:] |                 relative_root = relative_root[1:] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nikolay Minaylov
						Nikolay Minaylov