[FL-2163] CLI: Separate session from CLI service (#1130)
* CLI: session refactoring * Added forgotten define * Desktop lock state save * Dolphin: use proper type for value returned by dolphin_state_xp_to_levelup Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "../helpers/pin_lock.h"
|
||||
#include "../desktop_i.h"
|
||||
#include <cli/cli_vcp.h>
|
||||
|
||||
static const NotificationSequence sequence_pin_fail = {
|
||||
&message_display_on,
|
||||
@@ -61,26 +62,50 @@ uint32_t desktop_pin_lock_get_fail_timeout() {
|
||||
return pin_timeout;
|
||||
}
|
||||
|
||||
void desktop_pin_lock() {
|
||||
void desktop_pin_lock(DesktopSettings* settings) {
|
||||
furi_assert(settings);
|
||||
|
||||
furi_hal_rtc_set_pin_fails(0);
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
|
||||
furi_hal_usb_disable();
|
||||
Cli* cli = furi_record_open("cli");
|
||||
cli_session_close(cli);
|
||||
furi_record_close("cli");
|
||||
settings->is_locked = 1;
|
||||
SAVE_DESKTOP_SETTINGS(settings);
|
||||
}
|
||||
|
||||
void desktop_pin_unlock() {
|
||||
void desktop_pin_unlock(DesktopSettings* settings) {
|
||||
furi_assert(settings);
|
||||
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
|
||||
furi_hal_usb_enable();
|
||||
Cli* cli = furi_record_open("cli");
|
||||
cli_session_open(cli, &cli_vcp);
|
||||
furi_record_close("cli");
|
||||
settings->is_locked = 0;
|
||||
SAVE_DESKTOP_SETTINGS(settings);
|
||||
}
|
||||
|
||||
void desktop_pin_lock_init(DesktopSettings* settings) {
|
||||
furi_assert(settings);
|
||||
|
||||
if(settings->pin_code.length > 0) {
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
|
||||
furi_hal_usb_disable();
|
||||
if(settings->is_locked == 1) {
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagLock);
|
||||
} else {
|
||||
if(desktop_pin_lock_is_locked()) {
|
||||
settings->is_locked = 1;
|
||||
SAVE_DESKTOP_SETTINGS(settings);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
furi_hal_rtc_set_pin_fails(0);
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagLock);
|
||||
furi_hal_usb_enable();
|
||||
}
|
||||
|
||||
if(desktop_pin_lock_is_locked()) {
|
||||
furi_hal_usb_disable();
|
||||
}
|
||||
}
|
||||
|
||||
bool desktop_pin_lock_verify(const PinCode* pin_set, const PinCode* pin_entered) {
|
||||
|
@@ -8,9 +8,9 @@ void desktop_pin_lock_error_notify();
|
||||
|
||||
uint32_t desktop_pin_lock_get_fail_timeout();
|
||||
|
||||
void desktop_pin_lock();
|
||||
void desktop_pin_lock(DesktopSettings* settings);
|
||||
|
||||
void desktop_pin_unlock();
|
||||
void desktop_pin_unlock(DesktopSettings* settings);
|
||||
|
||||
bool desktop_pin_lock_is_locked();
|
||||
|
||||
|
Reference in New Issue
Block a user