#include "display-panel.h"
#include "display-plugin.h"
#include "display-config.h"
+#include "display-misc.h"
#include "display-state-transition.h"
#include "shared/log-macro.h"
#include "shared/apps.h"
#define no_foreground_lock(st) (check_lock_state(st) == false)
-static GList *cond_head[S_END];
+static GList *g_display_lock_list[S_END];
static int trans_condition;
bool check_lock_state(int state)
GList *elem;
PmLockNode *t;
- SYS_G_LIST_FOREACH(cond_head[state], elem, t) {
+ SYS_G_LIST_FOREACH(g_display_lock_list[state], elem, t) {
if (t->app_background == false)
return true;
}
bool pmlock_get_lock_state(enum state_t state)
{
- return (bool)SYS_G_LIST_LENGTH(cond_head[state]);
+ return (bool)SYS_G_LIST_LENGTH(g_display_lock_list[state]);
}
enum state_t power_lock_type_to_pmlock(power_lock_e power_lock_type)
return;
}
- num_of_pmlock = g_list_length(cond_head[state]);
+ num_of_pmlock = g_list_length(g_display_lock_list[state]);
if (num_of_pmlock > 1)
return;
GList *elem;
PmLockNode *t = NULL;
- SYS_G_LIST_FOREACH(cond_head[s_index], elem, t) {
+ SYS_G_LIST_FOREACH(g_display_lock_list[s_index], elem, t) {
if (t->pid == pid)
return t;
}
n->warning_id = g_timeout_add_seconds(g_display_plugin.config->lockcheck_timeout,
default_pmlock_check, (gpointer)n);
- SYS_G_LIST_APPEND(cond_head[s_index], n);
+ SYS_G_LIST_APPEND(g_display_lock_list[s_index], n);
refresh_app_cond();
if (n == NULL)
return 0;
- SYS_G_LIST_REMOVE(cond_head[s_index], n);
+ SYS_G_LIST_REMOVE(g_display_lock_list[s_index], n);
/* delete timer */
remove_pmlock_node_timeout_callback_id(n);
display_plugin_state_get_name(state, &state_name);
- SYS_G_LIST_FOREACH(cond_head[state], elem, t) {
+ SYS_G_LIST_FOREACH(g_display_lock_list[state], elem, t) {
if (t->pid != owner && t->app_background == false) {
ret = true;
_I("state change was blocked by pid(%d)!", t->pid);
display_plugin_state_get_name(state, &state_name);
_I("delete condition : state of %s", state_name);
- if (!cond_head[state])
+ if (!g_display_lock_list[state])
return 0;
- SYS_G_LIST_FOREACH_SAFE(cond_head[state], elem, next, t) {
+ SYS_G_LIST_FOREACH_SAFE(g_display_lock_list[state], elem, next, t) {
remove_pmlock_node_timeout_callback_id(t);
if (state == S_LCDOFF)
set_process_active(false, t->pid);
del_node(state, t);
}
- SYS_G_LIST_FREE_LIST(cond_head[state]);
- cond_head[state] = NULL;
+ SYS_G_LIST_FREE_LIST(g_display_lock_list[state]);
+ g_display_lock_list[state] = NULL;
broadcast_pmlock_state_changed(state);
return;
time(&now);
- SYS_G_LIST_FOREACH(cond_head[next], elem, n) {
+ SYS_G_LIST_FOREACH(g_display_lock_list[next], elem, n) {
diff = difftime(now, n->time);
ctime_r(&n->time, buf);
buf[strlen(buf) - 1] = 0;
PmLockNode *t = NULL;
int ret = 0;
- SYS_G_LIST_FOREACH_SAFE(cond_head[prohibit_state], elem, next, t) {
+ SYS_G_LIST_FOREACH_SAFE(g_display_lock_list[prohibit_state], elem, next, t) {
if (t->pid == -1 || (t->pid < INTERNAL_LOCK_BASE && kill(t->pid, 0) == -1)) {
_E("%d process does not exist, delete the REQ"
" - prohibit state %d ",
return trans_condition;
}
-GList *get_cond_head(enum state_t s_index)
-{
- return cond_head[s_index];
-}
-
int display_app_background(void *data)
{
pid_t pid;
return 0;
}
+
+static void print_lock_info(gpointer data, gpointer udata)
+{
+ PmLockNode *t = (PmLockNode *) data;
+ int **param = (int **) udata;
+ int *index = param[0];
+ int fd = *(param[1]);
+
+ char buf[PATH_MAX + 255] = { 0, };
+ char pname[PATH_MAX] = { 0, };
+ char time[32] = { 0, };
+ const char *stname = NULL;
+ int ret;
+
+ display_misc_get_process_name((pid_t)t->pid, pname);
+ ctime_r(&t->time, time);
+ display_plugin_state_get_name(t->state, &stname);
+
+ snprintf(buf, sizeof(buf), " %d: [%s] locked by pid %d %s %s\n", *index, stname, t->pid, pname, time);
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("Failed to write, %m");
+
+ *index = *index + 1;
+}
+
+int display_lock_print_lock_info(int fd)
+{
+ enum state_t s;
+ int index = 1;
+ int *param[2] = { &index, &fd };
+
+ if (fd < 0)
+ return -EINVAL;
+
+ for (s = S_NORMAL; s < S_END; ++s)
+ g_list_foreach(g_display_lock_list[s], print_lock_info, param);
+
+ return 0;
+}
static void print_info(int fd)
{
- int s_index = 0;
char buf[PATH_MAX + 255];
- int i = 1;
int ret;
- char pname[PATH_MAX];
- PmLockNode *t;
- GList *elem;
- char time_buf[30];
int normal_state_timeout;
int dim_state_timeout;
int off_stata_timeout;
if (ret < 0)
_E("Write() failed: %d", errno);
- for (s_index = S_NORMAL; s_index < S_END; s_index++) {
- SYS_G_LIST_FOREACH(get_cond_head(s_index), elem, t) {
- display_misc_get_process_name((pid_t)t->pid, pname);
- ctime_r(&t->time, time_buf);
- time_buf[strlen(time_buf) - 1] = 0;
- display_plugin_state_get_name(s_index, ¤t_state_name);
- snprintf(buf, sizeof(buf),
- " %d: [%s] locked by pid %d %s %s\n",
- i++, current_state_name, t->pid, pname, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- }
- }
+ display_lock_print_lock_info(fd);
print_lock_info_list(fd);
#include "shared/common.h"
#include "shared/device-notifier.h"
#include "shared/plugin.h"
+#include "display-lock.h"
#define PREDEF_SET_DATETIME "set_datetime"
#define PREDEF_SET_TIMEZONE "set_timezone"
static gboolean tfd_cb(gint fd, GIOCondition condition, gpointer user_data);
static int timerfd_check_stop(int fd);
static int timerfd_check_start(void);
-static GList* (*get_cond_head) (enum state_t state);
char *substring(const char *str, size_t begin, size_t len)
{
if (lcd_state < S_LCDOFF)
goto restart;
- if (get_cond_head)
- lcd_state = get_cond_head(S_LCDOFF) != NULL;
- else
- lcd_state = 0;
+ lcd_state = check_lock_condition(S_LCDOFF);
if (lcd_state || !tfdh || tfd == -1)
goto out;
if (timerfd_check_start() == -1)
_E("Failed system time change detector init.");
register_notifier(DEVICE_NOTIFIER_LCD, time_lcd_changed_cb);
-
- get_cond_head = dlsym(display_plugin_handle(), "get_cond_head");
- if (!get_cond_head)
- _E("Failed to load symbol get_cond_head(), %s.", dlerror());
}
static const struct device_ops time_device_ops = {