static gboolean del_dim_cond(void *data);
static gboolean del_off_cond(void *data);
-static gboolean pmlock_normal_check(void *data);
-static gboolean pmlock_dim_check(void *data);
-static gboolean pmlock_off_check(void *data);
+static gboolean pmlock_check(void *data);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
{ S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
};
-static GSourceFunc warning_cb[S_END] = {
- NULL, pmlock_normal_check, pmlock_dim_check, pmlock_off_check,
-};
-
enum signal_type {
SIGNAL_INVALID = 0,
SIGNAL_PRE,
pid_t pid;
guint timeout_id;
guint warning_id;
+ GVariant *warning_param;
time_t time;
bool holdkey_block;
bool background;
{
guint warning_id = 0;
PmLockNode *n;
+ GVariant *v = NULL;
time_t now;
n = (PmLockNode *) malloc(sizeof(PmLockNode));
return NULL;
}
- if (pid < INTERNAL_LOCK_BASE)
- warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
- warning_cb[s_index], (void *)((intptr_t)pid));
+ if (pid < INTERNAL_LOCK_BASE) {
+ v = g_variant_new("(ii)", s_index, pid);
+ if (v) {
+ warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
+ pmlock_check, (void *)v);
+ } else {
+ _E("Failed to make GVariant.");
+ }
+ }
time(&now);
n->pid = pid;
n->timeout_id = timeout_id;
n->warning_id = warning_id;
+ n->warning_param = v;
n->time = now;
n->holdkey_block = holdkey_block;
n->background = false;
g_source_remove(n->warning_id);
n->warning_id = 0;
}
+ if (n->warning_param) {
+ g_variant_unref(n->warning_param);
+ n->warning_param = NULL;
+ }
free(n);
refresh_app_cond();
* or good process. so infinity or more then 1 min lock process, deviced
* will be checked it to resoured. And then, it will be asked quit or maintain to user.
*/
-static void pmlock_check(void *data, char *st)
+static gboolean pmlock_check(void *data)
{
const char *arr[2];
char chr_pid[PID_MAX];
+ PmLockNode *node;
+ GVariant *v;
+ enum state_t state;
pid_t pid;
int ret;
- if (!data || !st)
- return;
+ if (!data) {
+ _E("Invalid parameter.");
+ return G_SOURCE_REMOVE;
+ }
+
+ v = (GVariant*)data;
+ g_variant_get(v, "(ii)", &state, &pid);
+
+ _D("Process %d requested state %d lock.", pid, state);
- if (!strncmp(st, "lcdoff", 4) && backlight_ops.get_lcd_power() == DPMS_ON) {
+ if (state == S_LCDOFF && backlight_ops.get_lcd_power() == DPMS_ON) {
_D("Lcd state is PM_LCD_POWER_ON");
- return;
+ return G_SOURCE_CONTINUE;
+ }
+
+ /* Stop checking lock if process had been terminated */
+ if (kill(pid, 0) == -1) {
+ node = find_node(state, pid);
+ del_node(state, node);
+ _I("Process %d not found. Stop checking lock.", pid);
+ return G_SOURCE_REMOVE;
}
- pid = (pid_t)((intptr_t)data);
snprintf(chr_pid, sizeof(chr_pid), "%d", pid);
arr[0] = chr_pid;
- arr[1] = st;
+ switch (state) {
+ case S_NORMAL:
+ arr[1] = "normal";
+ break;
+ case S_LCDDIM:
+ arr[1] = "lcddim";
+ break;
+ case S_LCDOFF:
+ arr[1] = "lcdoff";
+ break;
+ default:
+ _E("Invalid state.");
+ g_variant_unref(v);
+ return G_SOURCE_REMOVE;
+ }
ret = dbus_handle_method_async_with_reply(RESOURCED_BUS_NAME,
RESOURCED_PATH_PROCESS,
"is", arr, pmlock_check_cb, -1, NULL);
if (ret < 0)
_E("Failed to call dbus method");
-}
-static gboolean pmlock_normal_check(void *data)
-{
- pmlock_check(data, "normal");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_dim_check(void *data)
-{
- pmlock_check(data, "lcddim");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_off_check(void *data)
-{
- pmlock_check(data, "lcdoff");
return G_SOURCE_CONTINUE;
}
static gboolean del_dim_cond(void *data);
static gboolean del_off_cond(void *data);
-static gboolean pmlock_normal_check(void *data);
-static gboolean pmlock_dim_check(void *data);
-static gboolean pmlock_off_check(void *data);
+static gboolean pmlock_check(void *data);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
{ S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
};
-static GSourceFunc warning_cb[S_END] = {
- NULL, pmlock_normal_check, pmlock_dim_check, pmlock_off_check,
-};
-
enum signal_type {
SIGNAL_INVALID = 0,
SIGNAL_PRE,
pid_t pid;
guint timeout_id;
guint warning_id;
+ GVariant *warning_param;
time_t time;
bool holdkey_block;
bool background;
{
guint warning_id = 0;
PmLockNode *n;
+ GVariant *v = NULL;
time_t now;
n = (PmLockNode *) malloc(sizeof(PmLockNode));
return NULL;
}
- if (pid < INTERNAL_LOCK_BASE)
- warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
- warning_cb[s_index], (void *)((intptr_t)pid));
+ if (pid < INTERNAL_LOCK_BASE) {
+ v = g_variant_new("(ii)", s_index, pid);
+ if (v) {
+ warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
+ pmlock_check, (void *)v);
+ } else {
+ _E("Failed to make GVariant.");
+ }
+
+ }
time(&now);
n->pid = pid;
n->timeout_id = timeout_id;
n->warning_id = warning_id;
+ n->warning_param = v;
n->time = now;
n->holdkey_block = holdkey_block;
n->background = false;
g_source_remove(n->warning_id);
n->warning_id = 0;
}
+ if (n->warning_param) {
+ g_variant_unref(n->warning_param);
+ n->warning_param = NULL;
+ }
free(n);
refresh_app_cond();
* or good process. so infinity or more then 1 min lock process, deviced
* will be checked it to resoured. And then, it will be asked quit or maintain to user.
*/
-static void pmlock_check(void *data, char *st)
+static gboolean pmlock_check(void *data)
{
const char *arr[2];
char chr_pid[PID_MAX];
+ PmLockNode *node;
+ GVariant *v;
+ enum state_t state;
pid_t pid;
int ret;
- if (!data || !st)
- return;
+ if (!data) {
+ _E("Invalid parameter.");
+ return G_SOURCE_REMOVE;
+ }
+
+ v = (GVariant*)data;
+ g_variant_get(v, "(ii)", &state, &pid);
- if (!strncmp(st, "lcdoff", 4) && backlight_ops.get_lcd_power() == DPMS_ON) {
+ if (state == S_LCDOFF && backlight_ops.get_lcd_power() == DPMS_ON) {
_D("Lcd state is PM_LCD_POWER_ON");
- return;
+ return G_SOURCE_CONTINUE;
}
- pid = (pid_t)((intptr_t)data);
- snprintf(chr_pid, sizeof(chr_pid), "%d", pid);
+ /* Stop checking lock if process had been terminated */
+ if (kill(pid, 0) == -1) {
+ node = find_node(state, pid);
+ del_node(state, node);
+ _I("Process %d not found. Stop checking lock.", pid);
+ return G_SOURCE_REMOVE;
+ }
+ snprintf(chr_pid, sizeof(chr_pid), "%d", pid);
arr[0] = chr_pid;
- arr[1] = st;
+ switch (state) {
+ case S_NORMAL:
+ arr[1] = "normal";
+ break;
+ case S_LCDDIM:
+ arr[1] = "lcddim";
+ break;
+ case S_LCDOFF:
+ arr[1] = "lcdoff";
+ break;
+ default:
+ _E("Invalid state.");
+ g_variant_unref(v);
+ return G_SOURCE_REMOVE;
+ }
ret = dbus_handle_method_async_with_reply(RESOURCED_BUS_NAME,
RESOURCED_PATH_PROCESS,
"is", arr, pmlock_check_cb, -1, NULL);
if (ret < 0)
_E("Failed to call dbus method");
-}
-static gboolean pmlock_normal_check(void *data)
-{
- pmlock_check(data, "normal");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_dim_check(void *data)
-{
- pmlock_check(data, "lcddim");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_off_check(void *data)
-{
- pmlock_check(data, "lcdoff");
return G_SOURCE_CONTINUE;
}
static gboolean del_dim_cond(void *data);
static gboolean del_off_cond(void *data);
-static gboolean pmlock_normal_check(void *data);
-static gboolean pmlock_dim_check(void *data);
-static gboolean pmlock_off_check(void *data);
+static gboolean pmlock_check(void *data);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
{ S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
};
-static GSourceFunc warning_cb[S_END] = {
- NULL, pmlock_normal_check, pmlock_dim_check, pmlock_off_check,
-};
-
enum signal_type {
SIGNAL_INVALID = 0,
SIGNAL_PRE,
pid_t pid;
guint timeout_id;
guint warning_id;
+ GVariant *warning_param;
time_t time;
bool holdkey_block;
bool background;
{
guint warning_id = 0;
PmLockNode *n;
+ GVariant *v = NULL;
time_t now;
n = (PmLockNode *) malloc(sizeof(PmLockNode));
return NULL;
}
- if (pid < INTERNAL_LOCK_BASE)
- warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
- warning_cb[s_index], (void *)((intptr_t)pid));
+ if (pid < INTERNAL_LOCK_BASE) {
+ v = g_variant_new("(ii)", s_index, pid);
+ if (v) {
+ warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
+ pmlock_check, (void *)v);
+ } else {
+ _E("Failed to make GVariant.");
+ }
+ }
time(&now);
n->pid = pid;
n->timeout_id = timeout_id;
n->warning_id = warning_id;
+ n->warning_param = v;
n->time = now;
n->holdkey_block = holdkey_block;
n->background = false;
g_source_remove(n->warning_id);
n->warning_id = 0;
}
+ if (n->warning_param) {
+ g_variant_unref(n->warning_param);
+ n->warning_param = NULL;
+ }
free(n);
refresh_app_cond();
* or good process. so infinity or more then 1 min lock process, deviced
* will be checked it to resoured. And then, it will be asked quit or maintain to user.
*/
-static void pmlock_check(void *data, char *st)
+static gboolean pmlock_check(void *data)
{
const char *arr[2];
char chr_pid[PID_MAX];
+ PmLockNode *node;
+ GVariant *v;
+ enum state_t state;
pid_t pid;
int ret;
- if (!data || !st)
- return;
+ if (!data) {
+ _E("Invalid parameter.");
+ return G_SOURCE_REMOVE;
+ }
+
+ v = (GVariant*)data;
+ g_variant_get(v, "(ii)", &state, &pid);
- if (!strncmp(st, "lcdoff", 4) && backlight_ops.get_lcd_power() == DPMS_ON) {
+ if (state == S_LCDOFF && backlight_ops.get_lcd_power() == DPMS_ON) {
_D("Lcd state is PM_LCD_POWER_ON");
- return;
+ return G_SOURCE_CONTINUE;
}
- pid = (pid_t)((intptr_t)data);
- snprintf(chr_pid, sizeof(chr_pid), "%d", pid);
+ /* Stop checking lock if process had been terminated */
+ if (kill(pid, 0) == -1) {
+ node = find_node(state, pid);
+ del_node(state, node);
+ _I("Process %d not found. Stop checking lock.", pid);
+ return G_SOURCE_REMOVE;
+ }
+ snprintf(chr_pid, sizeof(chr_pid), "%d", pid);
arr[0] = chr_pid;
- arr[1] = st;
+ switch (state) {
+ case S_NORMAL:
+ arr[1] = "normal";
+ break;
+ case S_LCDDIM:
+ arr[1] = "lcddim";
+ break;
+ case S_LCDOFF:
+ arr[1] = "lcdoff";
+ break;
+ default:
+ _E("Invalid state.");
+ g_variant_unref(v);
+ return G_SOURCE_REMOVE;
+ }
ret = dbus_handle_method_async_with_reply(RESOURCED_BUS_NAME,
RESOURCED_PATH_PROCESS,
"is", arr, pmlock_check_cb, -1, NULL);
if (ret < 0)
_E("Failed to call dbus method");
-}
-static gboolean pmlock_normal_check(void *data)
-{
- pmlock_check(data, "normal");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_dim_check(void *data)
-{
- pmlock_check(data, "lcddim");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_off_check(void *data)
-{
- pmlock_check(data, "lcdoff");
return G_SOURCE_CONTINUE;
}
static gboolean del_dim_cond(void *data);
static gboolean del_off_cond(void *data);
-static gboolean pmlock_normal_check(void *data);
-static gboolean pmlock_dim_check(void *data);
-static gboolean pmlock_off_check(void *data);
+static gboolean pmlock_check(void *data);
static int default_proc_change_state(unsigned int cond, pid_t pid);
static int (*proc_change_state)(unsigned int cond, pid_t pid) = default_proc_change_state;
{ S_POWEROFF, S_POWEROFF }, /* S_POWEROFF */
};
-static GSourceFunc warning_cb[S_END] = {
- NULL, pmlock_normal_check, pmlock_dim_check, pmlock_off_check,
-};
-
enum signal_type {
SIGNAL_INVALID = 0,
SIGNAL_PRE,
pid_t pid;
guint timeout_id;
guint warning_id;
+ GVariant *warning_param;
time_t time;
bool holdkey_block;
bool background;
{
guint warning_id = 0;
PmLockNode *n;
+ GVariant *v = NULL;
time_t now;
n = (PmLockNode *) malloc(sizeof(PmLockNode));
return NULL;
}
- if (pid < INTERNAL_LOCK_BASE)
- warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
- warning_cb[s_index], (void *)((intptr_t)pid));
+ if (pid < INTERNAL_LOCK_BASE) {
+ v = g_variant_new("(ii)", s_index, pid);
+ if (v) {
+ warning_id = g_timeout_add_seconds(display_conf.lightsensor_interval,
+ pmlock_check, (void *)v);
+ } else {
+ _E("Failed to make GVariant.");
+ }
+ }
time(&now);
n->pid = pid;
n->timeout_id = timeout_id;
n->warning_id = warning_id;
+ n->warning_param = v;
n->time = now;
n->holdkey_block = holdkey_block;
n->background = false;
g_source_remove(n->warning_id);
n->warning_id = 0;
}
+ if (n->warning_param) {
+ g_variant_unref(n->warning_param);
+ n->warning_param = NULL;
+ }
free(n);
refresh_app_cond();
* or good process. so infinity or more then 1 min lock process, deviced
* will be checked it to resoured. And then, it will be asked quit or maintain to user.
*/
-static void pmlock_check(void *data, char *st)
+static gboolean pmlock_check(void *data)
{
const char *arr[2];
char chr_pid[PID_MAX];
+ PmLockNode *node;
+ GVariant *v;
+ enum state_t state;
pid_t pid;
int ret;
- if (!data || !st)
- return;
+ if (!data) {
+ _E("Invalid parameter.");
+ return G_SOURCE_REMOVE;
+ }
+
+ v = (GVariant*)data;
+ g_variant_get(v, "(ii)", &state, &pid);
- if (!strncmp(st, "lcdoff", 4) && backlight_ops.get_lcd_power() == DPMS_ON) {
+ if (state == S_LCDOFF && backlight_ops.get_lcd_power() == DPMS_ON) {
_D("Lcd state is PM_LCD_POWER_ON");
- return;
+ return G_SOURCE_CONTINUE;
}
- pid = (pid_t)((intptr_t)data);
- snprintf(chr_pid, sizeof(chr_pid), "%d", pid);
+ /* Stop checking lock if process had been terminated */
+ if (kill(pid, 0) == -1) {
+ node = find_node(state, pid);
+ del_node(state, node);
+ _I("Process %d not found. Stop checking lock.", pid);
+ return G_SOURCE_REMOVE;
+ }
+ snprintf(chr_pid, sizeof(chr_pid), "%d", pid);
arr[0] = chr_pid;
- arr[1] = st;
+ switch (state) {
+ case S_NORMAL:
+ arr[1] = "normal";
+ break;
+ case S_LCDDIM:
+ arr[1] = "lcddim";
+ break;
+ case S_LCDOFF:
+ arr[1] = "lcdoff";
+ break;
+ default:
+ _E("Invalid state.");
+ g_variant_unref(v);
+ return G_SOURCE_REMOVE;
+ }
ret = dbus_handle_method_async_with_reply(RESOURCED_BUS_NAME,
RESOURCED_PATH_PROCESS,
"is", arr, pmlock_check_cb, -1, NULL);
if (ret < 0)
_E("Failed to call dbus method");
-}
-static gboolean pmlock_normal_check(void *data)
-{
- pmlock_check(data, "normal");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_dim_check(void *data)
-{
- pmlock_check(data, "lcddim");
- return G_SOURCE_CONTINUE;
-}
-
-static gboolean pmlock_off_check(void *data)
-{
- pmlock_check(data, "lcdoff");
return G_SOURCE_CONTINUE;
}