Revert "Merge remote-tracking branch 'OFW/portasynthinca3/3332-autolock-fixes' into dev"

This reverts commit ba4c4e528a, reversing
changes made to 16e4b9219a.
This commit is contained in:
MX
2024-09-26 21:58:50 +03:00
parent b03d9f313b
commit e407c623e0
7 changed files with 4 additions and 102 deletions

View File

@@ -19,8 +19,6 @@ static void desktop_auto_lock_arm(Desktop*);
static void desktop_auto_lock_inhibit(Desktop*);
static void desktop_start_auto_lock_timer(Desktop*);
static void desktop_apply_settings(Desktop*);
static void desktop_auto_lock_add_inhibitor(Desktop* desktop);
static void desktop_auto_lock_remove_inhibitor(Desktop* desktop);
static void desktop_loader_callback(const void* message, void* context) {
furi_assert(context);
@@ -132,22 +130,16 @@ static bool desktop_custom_event_callback(void* context, uint32_t event) {
animation_manager_unload_and_stall_animation(desktop->animation_manager);
}
desktop_auto_lock_add_inhibitor(desktop);
desktop_auto_lock_inhibit(desktop);
desktop->app_running = true;
furi_semaphore_release(desktop->animation_semaphore);
} else if(event == DesktopGlobalAfterAppFinished) {
animation_manager_load_and_continue_animation(desktop->animation_manager);
desktop_auto_lock_remove_inhibitor(desktop);
desktop_auto_lock_arm(desktop);
desktop->app_running = false;
} else if(event == DesktopGlobalAddExternalInhibitor) {
desktop_auto_lock_add_inhibitor(desktop);
} else if(event == DesktopGlobalRemoveExternalInhibitor) {
desktop_auto_lock_remove_inhibitor(desktop);
} else if(event == DesktopGlobalAutoLock) {
if(!desktop->app_running && !desktop->locked) {
desktop_lock(desktop);
@@ -213,24 +205,6 @@ static void desktop_auto_lock_arm(Desktop* desktop) {
}
}
static void desktop_auto_lock_add_inhibitor(Desktop* desktop) {
furi_check(furi_semaphore_release(desktop->auto_lock_inhibitors) == FuriStatusOk);
FURI_LOG_D(
TAG,
"%lu autolock inhibitors (+1)",
furi_semaphore_get_count(desktop->auto_lock_inhibitors));
desktop_auto_lock_inhibit(desktop);
}
static void desktop_auto_lock_remove_inhibitor(Desktop* desktop) {
furi_check(furi_semaphore_acquire(desktop->auto_lock_inhibitors, 0) == FuriStatusOk);
uint32_t inhibitors = furi_semaphore_get_count(desktop->auto_lock_inhibitors);
FURI_LOG_D(TAG, "%lu autolock inhibitors (-1)", inhibitors);
if(inhibitors == 0) {
desktop_auto_lock_arm(desktop);
}
}
static void desktop_auto_lock_inhibit(Desktop* desktop) {
desktop_stop_auto_lock_timer(desktop);
if(desktop->input_events_subscription) {
@@ -397,7 +371,6 @@ static Desktop* desktop_alloc(void) {
desktop->notification = furi_record_open(RECORD_NOTIFICATION);
desktop->input_events_pubsub = furi_record_open(RECORD_INPUT_EVENTS);
desktop->auto_lock_inhibitors = furi_semaphore_alloc(UINT32_MAX, 0);
desktop->auto_lock_timer =
furi_timer_alloc(desktop_auto_lock_timer_callback, FuriTimerTypeOnce, desktop);
@@ -530,18 +503,6 @@ void desktop_api_set_settings(Desktop* instance, const DesktopSettings* settings
view_dispatcher_send_custom_event(instance->view_dispatcher, DesktopGlobalSaveSettings);
}
void desktop_api_add_external_inhibitor(Desktop* instance) {
furi_assert(instance);
view_dispatcher_send_custom_event(
instance->view_dispatcher, DesktopGlobalAddExternalInhibitor);
}
void desktop_api_remove_external_inhibitor(Desktop* instance) {
furi_assert(instance);
view_dispatcher_send_custom_event(
instance->view_dispatcher, DesktopGlobalRemoveExternalInhibitor);
}
/*
* Application thread
*/
@@ -562,7 +523,7 @@ int32_t desktop_srv(void* p) {
scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
if(desktop_pin_code_is_set()) {
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) {
desktop_lock(desktop);
}

View File

@@ -21,17 +21,3 @@ FuriPubSub* desktop_api_get_status_pubsub(Desktop* instance);
void desktop_api_get_settings(Desktop* instance, DesktopSettings* settings);
void desktop_api_set_settings(Desktop* instance, const DesktopSettings* settings);
/**
* @brief Adds 1 to the count of active external autolock inhibitors
*
* Autolocking will not get triggered while there's at least 1 inhibitor
*/
void desktop_api_add_external_inhibitor(Desktop* instance);
/**
* @brief Removes 1 from the count of active external autolock inhibitors
*
* Autolocking will not get triggered while there's at least 1 inhibitor
*/
void desktop_api_remove_external_inhibitor(Desktop* instance);

View File

@@ -73,7 +73,6 @@ struct Desktop {
FuriPubSub* input_events_pubsub;
FuriPubSubSubscription* input_events_subscription;
FuriSemaphore* auto_lock_inhibitors;
FuriTimer* auto_lock_timer;
FuriTimer* update_clock_timer;

View File

@@ -62,6 +62,4 @@ typedef enum {
DesktopGlobalApiUnlock,
DesktopGlobalSaveSettings,
DesktopGlobalReloadSettings,
DesktopGlobalAddExternalInhibitor,
DesktopGlobalRemoveExternalInhibitor,
} DesktopEvent;