From: Youngjae Cho Date: Tue, 14 Dec 2021 09:20:25 +0000 (+0900) Subject: power: apply wait callback mechanism to all state transitions X-Git-Tag: accepted/tizen/unified/20220117.135018~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f09cb8d649c8e666683b147109b84ccf6639a0e;p=platform%2Fcore%2Fsystem%2Fdeviced.git power: apply wait callback mechanism to all state transitions Generalize sleep-wait mechanism. It now always waits on changing state if some other processes has registered change-state-wait on the state. On transition to a next state, remove all change-state-waits that waiting for other than the next state. If a timeout expires or all change-state-waits are confirmed, invoke wait-done callback. Change-Id: I573ca68c3a6c210cad479e068ee088d6a31ba54f Signed-off-by: Youngjae Cho --- diff --git a/plugins/iot-headless/power/power-dbus.c b/plugins/iot-headless/power/power-dbus.c index 0a0ac50..fc907c1 100644 --- a/plugins/iot-headless/power/power-dbus.c +++ b/plugins/iot-headless/power/power-dbus.c @@ -31,7 +31,7 @@ #include "shared/device-notifier.h" #include "power-state-manager.h" -#include "sleep-wait.h" +#include "power-state-wait.h" #ifndef PROCESS_CHECK_TIMEOUT #define PROCESS_CHECK_TIMEOUT 600000 /* milisecond, 10 minute */ @@ -231,12 +231,13 @@ out: return g_variant_new("(i)", ret); } -static GVariant *dbus_power_add_sleep_wait(GDBusConnection *conn, +static GVariant *dbus_power_add_change_state_wait(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; pid_t pid; + guint64 state; pid = gdbus_connection_get_sender_pid(conn, sender); if (pid == -1 || kill(pid, 0) == -1) { @@ -245,17 +246,20 @@ static GVariant *dbus_power_add_sleep_wait(GDBusConnection *conn, goto out; } - ret = add_sleep_wait(pid); + g_variant_get(param, "(t)", &state); + + ret = add_change_state_wait(pid, state); out: return g_variant_new("(i)", ret); } -static GVariant *dbus_power_remove_sleep_wait(GDBusConnection *conn, +static GVariant *dbus_power_remove_change_state_wait(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { pid_t pid; + guint64 state; pid = gdbus_connection_get_sender_pid(conn, sender); if (pid == -1 || kill(pid, 0) == -1) { @@ -263,19 +267,21 @@ static GVariant *dbus_power_remove_sleep_wait(GDBusConnection *conn, goto out; } - remove_sleep_wait(pid); + g_variant_get(param, "(t)", &state); + + remove_change_state_wait(pid, state); out: return gdbus_new_g_variant_tuple(); } -static GVariant *dbus_power_confirm_sleep_wait(GDBusConnection *conn, +static GVariant *dbus_power_confirm_change_state_wait(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { int ret = 0; pid_t pid; - int sleep_id; + guint64 sleep_id; pid = gdbus_connection_get_sender_pid(conn, sender); if (pid == -1 || kill(pid, 0) == -1) { @@ -284,20 +290,20 @@ static GVariant *dbus_power_confirm_sleep_wait(GDBusConnection *conn, goto out; } - g_variant_get(param, "(i)", &sleep_id); + g_variant_get(param, "(t)", &sleep_id); - ret = confirm_sleep_wait(pid, sleep_id); + ret = confirm_change_state_wait(pid, sleep_id); out: return g_variant_new("(i)", ret); } static const dbus_method_s dbus_methods[] = { - { "LockCpu", "i", "i", dbus_power_lock_cpu }, - { "UnlockCpu", NULL, "i", dbus_power_unlock_cpu }, - { "AddSleepWait", NULL, "i", dbus_power_add_sleep_wait }, - { "RemoveSleepWait", NULL, NULL, dbus_power_remove_sleep_wait }, - { "ConfirmSleepWait", "i", "i", dbus_power_confirm_sleep_wait }, + { "LockCpu", "i", "i", dbus_power_lock_cpu }, + { "UnlockCpu", NULL, "i", dbus_power_unlock_cpu }, + { "AddChangeStateWait", "t", "i", dbus_power_add_change_state_wait }, + { "RemoveChangeStateWait", "t", NULL, dbus_power_remove_change_state_wait }, + { "ConfirmChangeStateWait", "t", "i", dbus_power_confirm_change_state_wait }, /* Add methods here */ }; diff --git a/plugins/iot-headless/power/power-state-manager.c b/plugins/iot-headless/power/power-state-manager.c index 751266d..959ed9c 100644 --- a/plugins/iot-headless/power/power-state-manager.c +++ b/plugins/iot-headless/power/power-state-manager.c @@ -3,13 +3,14 @@ #include #include #include +#include #include "shared/devices.h" #include "shared/device-notifier.h" #include "shared/log.h" #include "power-state-manager.h" #include "power-dbus.h" -#include "sleep-wait.h" +#include "power-state-wait.h" /* Temporal wakelock of powerkey input */ #define KEY_PRESSED_TEMPORAL_LOCK "templock" @@ -20,13 +21,14 @@ static guint keypress_temporal_timer_id; -static const char *psm_name[PSM_MAX] = { +char *psm_name[PSM_MAX] = { [PSM_NORMAL] = "PSM_NORMAL", [PSM_SLEEP] = "PSM_SLEEP", [PSM_POWEROFF] = "PSM_POWEROFF", + [PSM_REBOOT] = "PSM_REBOOT", }; -static unsigned int state_transition_counter = 0; +static guint64 state_transition_counter = 0; static enum psm_state current; static gboolean temporal_lock_expired_cb(void *data) @@ -73,82 +75,113 @@ static int release_temporal_lock(void * data) return 0; } -static int psm_sleep_wait_done_cb(void *data) +static void psm_wake_unlock(void) { /* for PSM_NORMAL, PSM_POWEROFF, do not wake unlock */ if (current != PSM_SLEEP) { _E("Ignore sleep wait done, current=%s", psm_name[current]); - return 0; + return; } - _D("Sleep-wait done"); device_notify(DEVICE_NOTIFIER_REQUEST_WAKE_UNLOCK, NULL); +} - return 0; +static void psm_trigger_poweroff(void) +{ + const struct device_ops *power_device; + + power_device = find_device("power"); + if (check_default(power_device)) + return; + + if (power_device->execute) { + device_notify(DEVICE_NOTIFIER_REQUEST_DISABLE_AUTOSLEEP, NULL); + power_device->execute("poweroff"); + } +} + +static void broadcast_transition_info(const struct trans_info *ti) +{ + // mapping deviced state to capi signame + static const char *capi_signame[PSM_MAX] = { + [PSM_NORMAL] = SIGNAME_CHANGE_STATE_TO_NORMAL, + [PSM_SLEEP] = SIGNAME_CHANGE_STATE_TO_SLEEP, + [PSM_POWEROFF] = SIGNAME_CHANGE_STATE_TO_POWEROFF, + [PSM_REBOOT] = SIGNAME_CHANGE_STATE_TO_REBOOT, + }; + + // mapping deviced state to capi state + static const guint64 capi_state[PSM_MAX] = { + [PSM_NORMAL] = POWER_STATE_NORMAL, + [PSM_SLEEP] = POWER_STATE_SLEEP, + [PSM_POWEROFF] = POWER_STATE_POWEROFF, + [PSM_REBOOT] = POWER_STATE_REBOOT, + }; + + gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, capi_signame[ti->next], + g_variant_new("(ttti)", capi_state[ti->curr], capi_state[ti->next], state_transition_counter, ti->reason)); +} + +static void psm_transition_normal_to_normal(const struct trans_info *ti) +{ + broadcast_transition_info(ti); + update_change_state_wait(state_transition_counter, ti, NULL); } static void psm_transition_normal_to_sleep(const struct trans_info *ti) { - int n_waiting; + int waiting; current = PSM_SLEEP; - gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, - "ChangeState", g_variant_new("(iti)", EVENT_TYPE_SLEEP, state_transition_counter, ti->reason)); - n_waiting = start_sleep_wait(state_transition_counter); - if (n_waiting > 0) { - /* There are sleep-waits. Defer wake unlock until all sleep-waits - * receive confirmation. Wake unlock will be done by - * psm_sleep_wait_done_cb() on receiving last confirmation.*/ + + broadcast_transition_info(ti); + waiting = update_change_state_wait(state_transition_counter, ti, psm_wake_unlock); + if (waiting > 0) { _D("Defer wake unlock"); return; } - device_notify(DEVICE_NOTIFIER_REQUEST_WAKE_UNLOCK, NULL); + psm_wake_unlock(); } static void psm_transition_sleep_to_normal(const struct trans_info *ti) { current = PSM_NORMAL; - stop_sleep_wait(); + + broadcast_transition_info(ti); device_notify(DEVICE_NOTIFIER_REQUEST_WAKE_LOCK, NULL); - gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, - "ChangeState", g_variant_new("(iti)", EVENT_TYPE_WAKEUP, state_transition_counter, ti->reason)); + update_change_state_wait(state_transition_counter, ti, NULL); } static void psm_transition_sleep_to_sleep(const struct trans_info *ti) { - int n_waiting; + int waiting; + broadcast_transition_info(ti); device_notify(DEVICE_NOTIFIER_REQUEST_WAKE_LOCK, NULL); - gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER, - "ChangeState", g_variant_new("(iti)", EVENT_TYPE_SLEEP, state_transition_counter, ti->reason)); - n_waiting = start_sleep_wait(state_transition_counter); - if (n_waiting > 0) { - /* There are sleep-waits. Defer wake unlock until all sleep-waits - * receive confirmation. Wake unlock will be done by - * psm_sleep_wait_done_cb() on receiving last confirmation.*/ + waiting = update_change_state_wait(state_transition_counter, ti, psm_wake_unlock); + if (waiting > 0) { _D("Defer wake unlock"); return; } - device_notify(DEVICE_NOTIFIER_REQUEST_WAKE_UNLOCK, NULL); + psm_wake_unlock(); } static void psm_transition_normal_to_poweroff(const struct trans_info *ti) { - const struct device_ops *power_device; + int waiting; current = PSM_POWEROFF; - power_device = find_device("power"); - if (check_default(power_device)) + broadcast_transition_info(ti); + waiting = update_change_state_wait(state_transition_counter, ti, psm_trigger_poweroff); + if (waiting > 0) { + _D("Defer poweroff"); return; - - if (power_device->execute) { - device_notify(DEVICE_NOTIFIER_REQUEST_DISABLE_AUTOSLEEP, NULL); - _D("Powerkey long pressed"); - power_device->execute("poweroff"); } + + psm_trigger_poweroff(); } static int psm_transition_state_cb(void *data) @@ -179,7 +212,9 @@ static int psm_transition_state_cb(void *data) /* transition */ ++state_transition_counter; if (current == PSM_NORMAL) { - if (next == PSM_SLEEP) + if (next == PSM_NORMAL) + psm_transition_normal_to_normal(ti); + else if (next == PSM_SLEEP) psm_transition_normal_to_sleep(ti); else if (next == PSM_POWEROFF) psm_transition_normal_to_poweroff(ti); @@ -203,7 +238,6 @@ void power_state_manager_init(void *data) register_notifier(DEVICE_NOTIFIER_KEY_PRESS, acquire_temporal_lock); register_notifier(DEVICE_NOTIFIER_KEY_RELEASE, release_temporal_lock); register_notifier(DEVICE_NOTIFIER_INPUT_TRANSITION_STATE, psm_transition_state_cb); - register_notifier(DEVICE_NOTIFIER_POWER_SLEEP_WAIT_DONE, psm_sleep_wait_done_cb); power_plugin_dbus_init(NULL); } diff --git a/plugins/iot-headless/power/power-state-manager.h b/plugins/iot-headless/power/power-state-manager.h index 0497d59..9da0859 100644 --- a/plugins/iot-headless/power/power-state-manager.h +++ b/plugins/iot-headless/power/power-state-manager.h @@ -7,8 +7,10 @@ enum psm_state { PSM_NORMAL, PSM_SLEEP, PSM_POWEROFF, + PSM_REBOOT, PSM_MAX, }; +extern char *psm_name[PSM_MAX]; struct trans_info { int reason; diff --git a/plugins/iot-headless/power/power-state-wait.c b/plugins/iot-headless/power/power-state-wait.c new file mode 100644 index 0000000..a1c5e88 --- /dev/null +++ b/plugins/iot-headless/power/power-state-wait.c @@ -0,0 +1,218 @@ +#include +#include +#include +#include + +#include "shared/log.h" +#include "shared/device-notifier.h" +#include "shared/common.h" + +#include "power-state-wait.h" +#include "power-state-manager.h" + +#define MAX_WAIT_SECOND 5 /* second */ + +struct proc_info { + pid_t pid; + char comm[128]; + guint64 state_bitmap; + int killed; +}; + +struct change_state_wait { + struct proc_info *pi; + guint64 id; + enum psm_state state; +}; + +static GList *proc_list; +static GList *waiting_list; +static int max_wait_timer; +static void (*__change_state_wait_done) (void); +static enum psm_state waiting_state; + +static void change_state_wait_done(void) +{ + _D("%s wait done", psm_name[waiting_state]); + + if (max_wait_timer) { + g_source_remove(max_wait_timer); + max_wait_timer = 0; + } + + if (__change_state_wait_done) { + __change_state_wait_done(); + } +} + +static gboolean max_wait_expired_cb(void *data) +{ + struct change_state_wait *csw; + struct proc_info *pi; + GList *elem, *elem_next; + + max_wait_timer = 0; + + SYS_G_LIST_FOREACH_SAFE(waiting_list, elem, elem_next, csw) { + if (kill(csw->pi->pid, 0) != 0) + csw->pi->killed = 1; + else + _E("pid=%d(%s) hasn't confirmed id=%ld(%s)", csw->pi->pid, csw->pi->comm, csw->id, psm_name[csw->state]); + waiting_list = g_list_remove_link(waiting_list, elem); + g_list_free(elem); + free(csw); + } + + SYS_G_LIST_FOREACH_SAFE(proc_list, elem, elem_next, pi) { + if (pi->killed) { + _D("Clean up not existing pid=%d(%s)", pi->pid, pi->comm); + proc_list = g_list_remove_link(proc_list, elem); + g_list_free(elem); + free(pi); + } + } + + change_state_wait_done(); + + return G_SOURCE_REMOVE; +} + +int add_change_state_wait(pid_t pid, guint64 state) +{ + struct proc_info *pi; + GList *elem; + + _D("pid=%d added csw for %#lx", pid, state); + + SYS_G_LIST_FOREACH(proc_list, elem, pi) { + if (pi->pid == pid) { + pi->state_bitmap |= state; + return 0; + } + } + + pi = calloc(1, sizeof(struct proc_info)); + if (!pi) + return -ENOMEM; + + pi->pid = pid; + pi->state_bitmap = state; + get_command(pid, pi->comm, sizeof(pi->comm)); + SYS_G_LIST_APPEND(proc_list, pi); + + return 0; +} + +void remove_change_state_wait(pid_t pid, guint64 state) +{ + struct proc_info *pi; + GList *elem, *elem_next; + + _D("pid=%d removed csw for %#lx", pid, state); + + SYS_G_LIST_FOREACH_SAFE(proc_list, elem, elem_next, pi) { + if (pi->pid == pid) { + pi->state_bitmap &= ~state; + if (pi->state_bitmap == 0) { + proc_list = g_list_remove_link(proc_list, elem); + g_list_free(elem); + free(pi); + } + } + } +} + +int confirm_change_state_wait(pid_t pid, guint64 id) +{ + struct change_state_wait *csw; + GList *elem, *elem_next; + + SYS_G_LIST_FOREACH_SAFE(waiting_list, elem, elem_next, csw) { + if (csw->pi->pid == pid && csw->id == id) { + _D("pid=%d(%s) confirmed id=%lu(%s)", csw->pi->pid, csw->pi->comm, csw->id, psm_name[csw->state]); + waiting_list = g_list_remove_link(waiting_list, elem); + g_list_free(elem); + free(csw); + + if (SYS_G_LIST_LENGTH(waiting_list) == 0) { + change_state_wait_done(); + return 0; + } + } + } + + return 0; +} + +static int check_proc_requested_wait_for_state(struct proc_info *pi, enum psm_state state) +{ + if (!pi) + return 0; + + if (state == PSM_NORMAL) + return (pi->state_bitmap & POWER_STATE_NORMAL); + if (state == PSM_SLEEP) + return (pi->state_bitmap & POWER_STATE_SLEEP); + if (state == PSM_POWEROFF) + return (pi->state_bitmap & POWER_STATE_POWEROFF); + if (state == PSM_REBOOT) + return (pi->state_bitmap & POWER_STATE_REBOOT); + + return 0; +} + +int update_change_state_wait(guint64 id, const struct trans_info *ti, change_state_wait_done_cb callback) +{ + struct proc_info *pi; + struct change_state_wait *csw; + GList *elem, *elem_next; + int n_waiting; + + // initialize timer + if (max_wait_timer) { + g_source_remove(max_wait_timer); + max_wait_timer = 0; + } + + // we are waiting for confirm of transition to the next state + waiting_state = ti->next; + _D("%s wait is triggered, id=%ld", psm_name[waiting_state], id); + + // cancel all ongoing csw that is not a waiting for the next state + SYS_G_LIST_FOREACH_SAFE(waiting_list, elem, elem_next, csw) { + if (csw->state != waiting_state) { + waiting_list = g_list_remove_link(waiting_list, elem); + g_list_free(elem); + _D("Cancel waiting: pid=%d(%s) for id=%ld(%s)", csw->pi->pid, csw->pi->comm, csw->id, psm_name[csw->state]); + free(csw); + } + } + + // add wait list + SYS_G_LIST_FOREACH(proc_list, elem, pi) { + if (check_proc_requested_wait_for_state(pi, waiting_state)) { + csw = calloc(1, sizeof(struct change_state_wait)); + if (!csw) + continue; + + csw->pi = pi; + csw->id = id; + csw->state = waiting_state; + SYS_G_LIST_APPEND(waiting_list, csw); + } + } + + n_waiting = SYS_G_LIST_LENGTH(waiting_list); + if (n_waiting == 0) { + _D("There were no csw requests for %s, skip waiting", psm_name[waiting_state]); + __change_state_wait_done = NULL; + return 0; + } + + __change_state_wait_done = callback; + + _D("Expected number of wait confirm=%d", n_waiting); + max_wait_timer = g_timeout_add_seconds(MAX_WAIT_SECOND, max_wait_expired_cb, NULL); + + return n_waiting; +} diff --git a/plugins/iot-headless/power/power-state-wait.h b/plugins/iot-headless/power/power-state-wait.h new file mode 100644 index 0000000..45544cd --- /dev/null +++ b/plugins/iot-headless/power/power-state-wait.h @@ -0,0 +1,14 @@ +#ifndef __POWER_STATE_WAIT_H__ +#define __POWER_STATE_WAIT_H__ + +#include +#include "power-state-manager.h" + +typedef void (*change_state_wait_done_cb) (void); + +int add_change_state_wait(pid_t pid, guint64 state); +void remove_change_state_wait(pid_t pid, guint64 state); +int confirm_change_state_wait(pid_t pid, guint64 id); +int update_change_state_wait(guint64 id, const struct trans_info *ti, change_state_wait_done_cb cb); + +#endif //__POWER_STATE_WAIT_H__ diff --git a/plugins/iot-headless/power/sleep-wait.c b/plugins/iot-headless/power/sleep-wait.c deleted file mode 100644 index 85bfd3d..0000000 --- a/plugins/iot-headless/power/sleep-wait.c +++ /dev/null @@ -1,185 +0,0 @@ -#include -#include - -#include "shared/log.h" -#include "shared/device-notifier.h" -#include "shared/common.h" - -#include "sleep-wait.h" - -#define MAX_WAIT_SECOND 5 /* second */ - -struct proc_info { - pid_t pid; - char comm[128]; - int killed; -}; - -struct sleep_wait { - struct proc_info *pi; - int id; -}; - -static GList *proc_list; -static GList *sleep_waiting; - -static int max_wait_timer; - -static void sleep_wait_done(void) -{ - if (max_wait_timer) { - g_source_remove(max_wait_timer); - max_wait_timer = 0; - } - - device_notify(DEVICE_NOTIFIER_POWER_SLEEP_WAIT_DONE, NULL); -} - -static gboolean max_wait_expired_cb(void *data) -{ - struct sleep_wait *sw; - struct proc_info *pi; - GList *elem, *elem_next; - - max_wait_timer = 0; - - SYS_G_LIST_FOREACH_SAFE(sleep_waiting, elem, elem_next, sw) { - if (kill(sw->pi->pid, 0) != 0) - sw->pi->killed = 1; - else - _E("pid=%d(%s) hasn't confirmed sleep wait", sw->pi->pid, sw->pi->comm); - sleep_waiting = g_list_remove_link(sleep_waiting, elem); - g_list_free(elem); - free(sw); - } - - SYS_G_LIST_FOREACH_SAFE(proc_list, elem, elem_next, pi) { - if (pi->killed) { - _D("Clean up not existing pid=%d(%s) from sleep wait", pi->pid, pi->comm); - proc_list = g_list_remove_link(proc_list, elem); - g_list_free(elem); - free(pi); - } - } - - _D("Maximum sleep wait expired, timeout=%ds", MAX_WAIT_SECOND); - device_notify(DEVICE_NOTIFIER_POWER_SLEEP_WAIT_DONE, NULL); - - return G_SOURCE_REMOVE; -} - -int add_sleep_wait(pid_t pid) -{ - struct proc_info *pi; - GList *elem; - - SYS_G_LIST_FOREACH(proc_list, elem, pi) { - if (pi->pid == pid) - return -EEXIST; - } - - pi = calloc(1, sizeof(struct proc_info)); - if (!pi) - return -ENOMEM; - - pi->pid = pid; - get_command(pid, pi->comm, sizeof(pi->comm)); - SYS_G_LIST_APPEND(proc_list, pi); - - return 0; -} - -void remove_sleep_wait(pid_t pid) -{ - struct sleep_wait *sw; - struct proc_info *pi; - GList *elem, *elem_next; - - SYS_G_LIST_FOREACH_SAFE(sleep_waiting, elem, elem_next, sw) { - if (sw->pi->pid == pid) { - sleep_waiting = g_list_remove_link(sleep_waiting, elem); - g_list_free(elem); - free(sw); - } - } - - SYS_G_LIST_FOREACH_SAFE(proc_list, elem, elem_next, pi) { - if (pi->pid == pid) { - sleep_waiting = g_list_remove_link(sleep_waiting, elem); - g_list_free(elem); - free(pi); - } - } -} - -int confirm_sleep_wait(pid_t pid, int id) -{ - struct sleep_wait *sw; - GList *elem, *elem_next; - - SYS_G_LIST_FOREACH_SAFE(sleep_waiting, elem, elem_next, sw) { - if (sw->pi->pid == pid && sw->id == id) { - _D("pid=%d(%s) confirmed sleep id=%d", sw->pi->pid, sw->pi->comm, sw->id); - sleep_waiting = g_list_remove_link(sleep_waiting, elem); - g_list_free(elem); - free(sw); - - if (SYS_G_LIST_LENGTH(sleep_waiting) == 0) { - /* all sleep-waits are checked */ - sleep_wait_done(); - return 0; - } - } - } - - return 0; -} - -int start_sleep_wait(int id) -{ - struct proc_info *pi; - struct sleep_wait *sw; - GList *elem; - int n_sleep_wait; - - /* create sleep_wait for every pid of proc_list */ - SYS_G_LIST_FOREACH(proc_list, elem, pi) { - sw = calloc(1, sizeof(struct sleep_wait)); - if (!sw) - continue; - - sw->pi = pi; - sw->id = id; - SYS_G_LIST_APPEND(sleep_waiting, sw); - } - - n_sleep_wait = SYS_G_LIST_LENGTH(sleep_waiting); - if (n_sleep_wait == 0) - return 0; - - /* reset timer */ - if (max_wait_timer) - g_source_remove(max_wait_timer); - - _D("Sleep wait is triggered, expected number of confirmation=%d", n_sleep_wait); - max_wait_timer = g_timeout_add_seconds(MAX_WAIT_SECOND, max_wait_expired_cb, NULL); - - return n_sleep_wait; -} - -void stop_sleep_wait(void) -{ - struct sleep_wait *sw; - GList *elem, *elem_next; - - if (max_wait_timer) { - g_source_remove(max_wait_timer); - max_wait_timer = 0; - } - - SYS_G_LIST_FOREACH_SAFE(sleep_waiting, elem, elem_next, sw) { - sleep_waiting = g_list_remove_link(sleep_waiting, elem); - g_list_free(elem); - free(sw); - } -} diff --git a/plugins/iot-headless/power/sleep-wait.h b/plugins/iot-headless/power/sleep-wait.h deleted file mode 100644 index 5110e3b..0000000 --- a/plugins/iot-headless/power/sleep-wait.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __SLEEP_WAIT_H__ -#define __SLEEP_WAIT_H__ - -#include - -int add_sleep_wait(pid_t pid); -void remove_sleep_wait(pid_t pid); -int confirm_sleep_wait(pid_t pid, int id); -int start_sleep_wait(int id); -void stop_sleep_wait(void); - -#endif //__SLEEP_WAIT_H__ diff --git a/src/shared/device-notifier.h b/src/shared/device-notifier.h index 07b4ec0..c917049 100644 --- a/src/shared/device-notifier.h +++ b/src/shared/device-notifier.h @@ -38,7 +38,6 @@ enum device_notifier_type { DEVICE_NOTIFIER_DISPLAY_AMBIENT_STATE, DEVICE_NOTIFIER_DISPLAY_LOCK, DEVICE_NOTIFIER_POWER_RESUME, - DEVICE_NOTIFIER_POWER_SLEEP_WAIT_DONE, DEVICE_NOTIFIER_POWEROFF, DEVICE_NOTIFIER_APPLICATION_BACKGROUND, DEVICE_NOTIFIER_APPLICATION_FOREGROUND,