summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsh.pi <sh.pi@samsung.com>2012-08-22 15:51:02 +0900
committersh.pi <sh.pi@samsung.com>2012-08-23 10:43:26 +0900
commit5a2e7ca17f27d8a481b84844c68224b129646862 (patch)
tree85f8d4f6c3ba042170d2f580b60c7576d6ddf081
parent0c984fff9da8352c7222de3976d6481668349e99 (diff)
downloadpower-manager-5a2e7ca17f27d8a481b84844c68224b129646862.tar.gz
power-manager-5a2e7ca17f27d8a481b84844c68224b129646862.tar.bz2
power-manager-5a2e7ca17f27d8a481b84844c68224b129646862.zip
Change-Id: Ibb96dab6d3a542f9c39fb12bfc69d26994b5f15f
-rw-r--r--debian/changelog8
-rw-r--r--debian/power-manager-bin.postinst.in2
-rw-r--r--packaging/power-manager.spec2
-rw-r--r--pm_core.c282
-rw-r--r--pm_key_filter.c99
-rw-r--r--pm_llinterface.c50
-rw-r--r--pm_lsensor.c103
-rw-r--r--pm_poll.c8
-rw-r--r--pm_setting.c19
-rw-r--r--pm_setting.h2
-rw-r--r--pm_x_lcd_onoff.c2
-rw-r--r--util.h11
12 files changed, 419 insertions, 169 deletions
diff --git a/debian/changelog b/debian/changelog
index 345debe..f2640b9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+power-manager (1.3.21-96) unstable; urgency=low
+
+ * Update for tizen 2.0
+ * Git: magnolia/framework/system/power-manager
+ * Tag: power-manager_1.3.21-96
+
+ -- Seunghun Pi <sh.pi@samsung.com> Thu, 23 Aug 2012 10:43:03 +0900
+
power-manager (1.3.21-87) unstable; urgency=low
* update for new oal layer
diff --git a/debian/power-manager-bin.postinst.in b/debian/power-manager-bin.postinst.in
index 9c188d0..7805f53 100644
--- a/debian/power-manager-bin.postinst.in
+++ b/debian/power-manager-bin.postinst.in
@@ -1,6 +1,6 @@
#!/bin/sh
-vconftool set -t int memory/pwrmgr/state 0 -i
+vconftool set -t int memory/pm/state 0 -i
heynotitool set system_wakeup
diff --git a/packaging/power-manager.spec b/packaging/power-manager.spec
index 1427427..f8f7334 100644
--- a/packaging/power-manager.spec
+++ b/packaging/power-manager.spec
@@ -48,7 +48,7 @@ ln -s %{_sysconfdir}/init.d/power_manager.sh %{buildroot}%{_sysconfdir}/rc.d/rc3
ln -s %{_sysconfdir}/init.d/power_manager.sh %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S00power-manager
%post bin
-vconftool set -t int memory/pwrmgr/state 0 -i
+vconftool set -t int memory/pm/state 0 -i
heynotitool set system_wakeup
mkdir -p /etc/udev/rules.d
diff --git a/pm_core.c b/pm_core.c
index 085bc19..4b20866 100644
--- a/pm_core.c
+++ b/pm_core.c
@@ -104,12 +104,19 @@ static int trans_table[S_END][EVENT_END] = {
#define SHIFT_CHANGE_STATE 7
#define CHANGE_STATE_BIT 0xF00 /* 1111 0000 0000 */
#define LOCK_SCREEN_TIMEOUT 5
+#define SHIFT_HOLD_KEY_BLOCK 16
+
+#define DEFAULT_NORMAL_TIMEOUT 30
+#define DEFAULT_DIM_TIMEOUT 5
+#define DEFAULT_OFF_TIMEOUT 5
+#define GET_HOLDKEY_BLOCK_STATE(x) ((x >> SHIFT_HOLD_KEY_BLOCK) & 0x1)
static int received_sleep_cmd = 0;
typedef struct _node {
pid_t pid;
int timeout_id;
+ gboolean holdkey_block;
struct _node *next;
} Node;
@@ -141,7 +148,8 @@ static Node *find_node(enum state_t s_index, pid_t pid)
return t;
}
-static Node *add_node(enum state_t s_index, pid_t pid, int timeout_id)
+static Node *add_node(enum state_t s_index, pid_t pid, int timeout_id,
+ gboolean holdkey_block)
{
Node *n;
@@ -153,6 +161,7 @@ static Node *add_node(enum state_t s_index, pid_t pid, int timeout_id)
n->pid = pid;
n->timeout_id = timeout_id;
+ n->holdkey_block = holdkey_block;
n->next = cond_head[s_index];
cond_head[s_index] = n;
@@ -189,7 +198,7 @@ static int del_node(enum state_t s_index, Node *n)
static gboolean del_dim_cond(gpointer data)
{
Node *tmp = NULL;
- LOGDBG("delete prohibit dim condition by timeout\n");
+ LOGINFO("delete prohibit dim condition by timeout\n");
tmp = find_node(S_LCDDIM, (pid_t) data);
del_node(S_LCDDIM, tmp);
@@ -203,7 +212,7 @@ static gboolean del_dim_cond(gpointer data)
static gboolean del_off_cond(gpointer data)
{
Node *tmp = NULL;
- LOGDBG("delete prohibit off condition by timeout\n");
+ LOGINFO("delete prohibit off condition by timeout\n");
tmp = find_node(S_LCDOFF, (pid_t) data);
del_node(S_LCDOFF, tmp);
@@ -217,7 +226,7 @@ static gboolean del_off_cond(gpointer data)
static gboolean del_sleep_cond(gpointer data)
{
Node *tmp = NULL;
- LOGDBG("delete prohibit sleep condition by timeout\n");
+ LOGINFO("delete prohibit sleep condition by timeout\n");
tmp = find_node(S_SLEEP, (pid_t) data);
del_node(S_SLEEP, tmp);
@@ -236,6 +245,7 @@ static int proc_condition(PMMsg *data)
unsigned int val = data->cond;
pid_t pid = data->pid;
int cond_timeout_id = -1;
+ gboolean holdkey_block = 0;
if (val == 0)
return 0;
@@ -261,12 +271,14 @@ static int proc_condition(PMMsg *data)
(GSourceFunc) del_dim_cond,
(gpointer) pid, NULL);
}
+ holdkey_block = GET_HOLDKEY_BLOCK_STATE(val);
tmp = find_node(S_LCDDIM, pid);
if (tmp == NULL)
- tmp = add_node(S_LCDDIM, pid, cond_timeout_id);
+ tmp = add_node(S_LCDDIM, pid, cond_timeout_id, holdkey_block);
else if (tmp->timeout_id > 0) {
g_source_remove(tmp->timeout_id);
tmp->timeout_id = cond_timeout_id;
+ tmp->holdkey_block = holdkey_block;
}
/* for debug */
LOGINFO("[%s] locked by pid %d - process %s\n", "S_NORMAL", pid,
@@ -280,12 +292,14 @@ static int proc_condition(PMMsg *data)
(GSourceFunc) del_off_cond,
(gpointer) pid, NULL);
}
+ holdkey_block = GET_HOLDKEY_BLOCK_STATE(val);
tmp = find_node(S_LCDOFF, pid);
if (tmp == NULL)
- tmp = add_node(S_LCDOFF, pid, cond_timeout_id);
+ tmp = add_node(S_LCDOFF, pid, cond_timeout_id, holdkey_block);
else if (tmp->timeout_id > 0) {
g_source_remove(tmp->timeout_id);
tmp->timeout_id = cond_timeout_id;
+ tmp->holdkey_block = holdkey_block;
}
/* for debug */
LOGINFO("[%s] locked by pid %d - process %s\n", "S_LCDDIM", pid,
@@ -301,10 +315,11 @@ static int proc_condition(PMMsg *data)
}
tmp = find_node(S_SLEEP, pid);
if (tmp == NULL)
- tmp = add_node(S_SLEEP, pid, cond_timeout_id);
+ tmp = add_node(S_SLEEP, pid, cond_timeout_id, 0);
else if (tmp->timeout_id > 0) {
g_source_remove(tmp->timeout_id);
tmp->timeout_id = cond_timeout_id;
+ tmp->holdkey_block = 0;
}
sysman_inform_active(pid);
/* for debug */
@@ -365,7 +380,7 @@ static int proc_change_state(unsigned int cond)
break;
}
}
- LOGDBG("Change State to %s", state_string[next_state]);
+ LOGINFO("Change State to %s", state_string[next_state]);
switch (next_state) {
case S_NORMAL:
@@ -432,10 +447,50 @@ int check_processes(enum state_t prohibit_state)
return ret;
}
+int check_holdkey_block(enum state_t state)
+{
+ Node *t = cond_head[state];
+ int ret = 0;
+
+ LOGINFO("check holdkey block : state of %s", state_string[state]);
+
+ while(t != NULL) {
+ if(t->holdkey_block == true) {
+ ret = 1;
+ LOGINFO("Hold key blocked by pid(%d)!", t->pid);
+ break;
+ }
+ t = t->next;
+ }
+
+ return ret;
+}
+
+int delete_condition(enum state_t state)
+{
+ Node *t = cond_head[state];
+ int ret = 0;
+ Node *tmp = NULL;
+
+ LOGINFO("delete condition : state of %s", state_string[state]);
+
+ while(t != NULL) {
+ if(t->timeout_id > 0) {
+ g_source_remove(t->timeout_id);
+ }
+ tmp = t;
+ t = t->next;
+ LOGINFO("delete node of pid(%d)", tmp->pid);
+ del_node(state, tmp);
+ }
+
+ return 0;
+}
+
/* SIGINT, SIGTERM, SIGQUIT signal handler */
static void sig_quit(int signo)
{
- LOGDBG("received %d signal : stops a main loop", signo);
+ LOGINFO("received %d signal : stops a main loop", signo);
if (mainloop)
g_main_loop_quit(mainloop);
}
@@ -532,7 +587,7 @@ static void sig_hup(int signo)
/* timeout handler */
gboolean timeout_handler(gpointer data)
{
- LOGDBG("Time out state %s\n", state_string[cur_state]);
+ LOGINFO("Time out state %s\n", state_string[cur_state]);
if (timeout_src_id != 0) {
g_source_remove(timeout_src_id);
@@ -580,13 +635,18 @@ static int default_trans(int evt)
struct state *st = &states[cur_state];
int next_state;
+ if(cur_state == S_NORMAL && st->timeout == 0) {
+ LOGINFO("LCD always on enabled!");
+ return 0;
+ }
+
next_state = (enum state_t)trans_table[cur_state][evt];
/* check conditions */
while (st->check && !st->check(next_state)) {
/* There is a condition. */
- LOGDBG("%s -> %s : check fail", state_string[cur_state],
- state_string[next_state]);
+ LOGINFO("%s -> %s : check fail", state_string[cur_state],
+ state_string[next_state]);
if (!check_processes(next_state)) {
/* this is valid condition - the application that sent the condition is running now. */
return -1;
@@ -614,7 +674,7 @@ static int default_action(int timeout)
char buf[NAME_MAX];
char *pkgname = NULL;
int i = 0;
- int lock_state = 0;
+ int lock_state = -1;
if (cur_state != old_state && cur_state != S_SLEEP)
set_setting_pmstate(cur_state);
@@ -672,7 +732,7 @@ static int default_action(int timeout)
/* set timer with current state timeout */
reset_timeout(timeout);
- LOGDBG("timout set: %s state %d sec", state_string[cur_state], timeout);
+ LOGINFO("timout set: %s state %d sec", state_string[cur_state], timeout);
return 0;
@@ -704,8 +764,15 @@ go_lcd_off:
static int default_check(int next)
{
int trans_cond = trans_condition & MASK_BIT;
+ int lock_state = -1;
- LOGDBG("trans_cond : %x", trans_cond);
+ LOGINFO("trans_cond : %x", trans_cond);
+
+ vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state);
+ if(lock_state==VCONFKEY_IDLE_LOCK && next != S_SLEEP) {
+ LOGINFO("default_check : LOCK STATE, it's transitable");
+ return 1;
+ }
switch (next) {
case S_LCDDIM:
@@ -756,12 +823,25 @@ static int get_settings()
ret = -1;
break;
}
- if (ret == 0)
+ if (ret == 0 || val < 0) {
states[i].timeout = val;
- else
- states[i].timeout = 0;
- LOGDBG("%s state : %d timeout", state_string[i],
- states[i].timeout);
+ } else {
+ switch (states[i].state) {
+ case S_NORMAL:
+ states[i].timeout = DEFAULT_NORMAL_TIMEOUT;
+ break;
+ case S_LCDDIM:
+ states[i].timeout = DEFAULT_DIM_TIMEOUT;
+ break;
+ case S_LCDOFF:
+ states[i].timeout = DEFAULT_OFF_TIMEOUT;
+ break;
+ default:
+ states[i].timeout = 0;
+ break;
+ }
+ }
+ LOGINFO("%s state : %d timeout", state_string[i], states[i].timeout);
}
return 0;
@@ -769,23 +849,10 @@ static int get_settings()
static void default_saving_mode(int onoff)
{
- int ret = -1, val = 5;
- char tmp[NAME_MAX];
-
if (onoff) {
status_flag |= PWRSV_FLAG;
- get_env(EN_SYS_DIMBRT, tmp, sizeof(tmp));
- set_default_brt(atoi(tmp)); /* Minimum brightness */
} else {
status_flag &= ~PWRSV_FLAG;
- ret = get_setting_brightness(&val);
- if (ret > -1) {
- LOGDBG("Set brightness from Setting App. %d", ret);
- set_default_brt(val);
- } else {
- LOGERR("Failed to get the brightness value");
- set_default_brt(5);
- }
}
if (cur_state == S_NORMAL)
backlight_restore();
@@ -813,7 +880,7 @@ static int poll_callback(int condition, PMMsg *data)
if (data->cond & CHANGE_STATE_BIT) {
- LOGDBG("Change state by pid(%d) request.", data->pid);
+ LOGINFO("Change state by pid(%d) request.", data->pid);
proc_change_state(data->cond);
}
}
@@ -827,35 +894,65 @@ static int update_setting(int key_idx, int val)
int ret = -1;
int dim_timeout = -1;
int run_timeout = -1;
+ int power_saving_stat = -1;
+ int power_saving_display_stat = -1;
switch (key_idx) {
- case SETTING_TO_NORMAL:
- ret = get_dim_timeout(&dim_timeout);
- if(ret < 0) {
- LOGERR("Can not get dim timeout. set default 5 seconds");
- dim_timeout = 5;
- }
+ case SETTING_TO_NORMAL:
+ ret = get_dim_timeout(&dim_timeout);
+ if(ret < 0 || dim_timeout < 0) {
+ LOGERR("Can not get dim timeout. set default 5 seconds");
+ dim_timeout = 5;
+ }
+ if(val < 0) {
+ LOGERR("LCD timeout is wrong, set default 15 seconds");
+ val = 15;
+ }
+ if(val == 0) {
+ states[S_NORMAL].timeout = 0;
+ } else if(val > dim_timeout) {
states[S_NORMAL].timeout = val - dim_timeout;
- states[cur_state].trans(EVENT_INPUT);
- break;
- case SETTING_LOW_BATT:
- if (val < VCONFKEY_SYSMAN_BAT_WARNING_LOW) {
+ } else {
+ states[S_NORMAL].timeout = 1;
+ }
+ states[cur_state].trans(EVENT_INPUT);
+ break;
+ case SETTING_LOW_BATT:
+ if (val < VCONFKEY_SYSMAN_BAT_WARNING_LOW) {
+ if (!(status_flag & CHRGR_FLAG))
power_saving_func(true);
- status_flag |= LOWBT_FLAG;
- } else {
- if (status_flag & PWRSV_FLAG)
- power_saving_func(false);
+ status_flag |= LOWBT_FLAG;
+ } else {
+ if (status_flag & PWRSV_FLAG)
+ power_saving_func(false);
+ status_flag &= ~LOWBT_FLAG;
+ }
+ break;
+ case SETTING_CHARGING:
+ if (val) {
+ if (status_flag & LOWBT_FLAG) {
+ power_saving_func(false);
status_flag &= ~LOWBT_FLAG;
}
- break;
- case SETTING_BRT_LEVEL:
- if (status_flag & PWRSV_FLAG)
- break;
- set_default_brt(val);
- snprintf(buf, sizeof(buf), "%s %d", SET_BRIGHTNESS_IN_BOOTLOADER, val);
- LOGINFO("Brightness set in bl : %d",val);
- system(buf);
- break;
+ status_flag |= CHRGR_FLAG;
+ } else {
+ int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
+ vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state);
+ if(bat_state < VCONFKEY_SYSMAN_BAT_NORMAL) {
+ power_saving_func(true);
+ status_flag |= LOWBT_FLAG;
+ }
+ status_flag &= ~CHRGR_FLAG;
+ }
+ break;
+ case SETTING_BRT_LEVEL:
+ if (status_flag & PWRSV_FLAG)
+ break;
+ set_default_brt(val);
+ snprintf(buf, sizeof(buf), "%s %d", SET_BRIGHTNESS_IN_BOOTLOADER, val);
+ LOGINFO("Brightness set in bl : %d",val);
+ system(buf);
+ break;
case SETTING_LOCK_SCREEN:
if (val == VCONFKEY_IDLE_LOCK) {
states[S_NORMAL].timeout = LOCK_SCREEN_TIMEOUT;
@@ -867,13 +964,33 @@ static int update_setting(int key_idx, int val)
run_timeout = 10;
}
states[S_NORMAL].timeout = run_timeout;
+ LOGINFO("LCD NORMAL timeout is set by %d seconds because phone is unlocked", run_timeout);
}
if (cur_state == S_NORMAL) {
states[cur_state].trans(EVENT_INPUT);
}
- break;
- default:
- return -1;
+ break;
+ case SETTING_POWER_SAVING:
+ if (val == 1)
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat);
+ if (power_saving_display_stat != 1)
+ power_saving_display_stat = 0;
+ plugin_intf->OEM_sys_set_display_frame_rate(power_saving_display_stat);
+ backlight_restore();
+ break;
+ case SETTING_POWER_SAVING_DISPLAY:
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat);
+ if (power_saving_stat == 1) {
+ if (val == 1)
+ power_saving_display_stat = 1;
+ else
+ power_saving_display_stat = 0;
+ plugin_intf->OEM_sys_set_display_frame_rate(power_saving_display_stat);
+ backlight_restore();
+ }
+ break;
+ default:
+ return -1;
}
return 0;
}
@@ -882,14 +999,19 @@ static void check_seed_status(void)
{
int ret = -1;
int tmp = 0;
- int bat_state = 4;
+ int bat_state = VCONFKEY_SYSMAN_BAT_NORMAL;
int max_brt = 0;
int brt = 0;
int lock_state = -1;
+ /* Charging check */
+ if ((get_charging_status(&tmp) == 0) && (tmp > 0)) {
+ status_flag |= CHRGR_FLAG;
+ }
+
ret = get_setting_brightness(&tmp);
if (ret != 0 || tmp < 0) {
- LOGDBG("fail to read vconf value for brightness");
+ LOGINFO("fail to read vconf value for brightness");
if (0 > plugin_intf->OEM_sys_get_backlight_max_brightness(DEFAULT_DISPLAY, &max_brt))
brt = 7;
@@ -897,16 +1019,18 @@ static void check_seed_status(void)
brt = max_brt * 0.4;
if(tmp < 0)
vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt);
- tmp=brt;
+ tmp = brt;
}
vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state);
if(bat_state >= VCONFKEY_SYSMAN_BAT_WARNING_LOW || bat_state == -1 ) {
- LOGDBG("Set brightness from Setting App. %d", tmp);
+ LOGINFO("Set brightness from Setting App. %d", tmp);
set_default_brt(tmp);
} else {
- power_saving_func(true);
- status_flag |= LOWBT_FLAG;
+ if (!(status_flag & CHRGR_FLAG)) {
+ power_saving_func(true);
+ status_flag |= LOWBT_FLAG;
+ }
}
backlight_restore();
@@ -915,7 +1039,7 @@ static void check_seed_status(void)
if ((get_usb_status(&tmp) == 0) && (tmp > 0)) {
tmp = readpid(USB_CON_PIDFILE);
if (tmp != -1) {
- add_node(S_SLEEP, tmp, -1);
+ add_node(S_SLEEP, tmp, -1, 0);
}
}
@@ -944,6 +1068,24 @@ static char *errMSG[INIT_END] = {
[INIT_FIFO] = "FIFO poll init error",
};
+/* logging indev_list for debug */
+void printglist()
+{
+ int i;
+ guint total=0;
+ indev *tmp;
+
+ total=g_list_length(indev_list);
+ LOGINFO("***** total list : %d *****",total);
+ for(i=0;i<total;i++) {
+ tmp=(indev*)(g_list_nth(indev_list, i)->data);
+ LOGINFO("* %d | path:%s, gsource:%d, gfd:%d", i, tmp->dev_path, tmp->dev_src, tmp->dev_fd);
+ if(i==total-1 && g_list_nth(indev_list, i)->next==NULL)
+ LOGINFO("okokok");
+ }
+ LOGINFO("***************************\n");
+}
+
static GList *find_glist(GList *glist, char *path)
{
int i;
@@ -1010,6 +1152,8 @@ static void input_cb(void* data)
}
ret=0;
}
+ /* debug */
+ printglist();
break;
}
@@ -1059,7 +1203,7 @@ static int set_noti(int noti_fd)
static int unset_noti(int noti_fd)
{
if (noti_fd < 0) {
- LOGDBG("set noti already failed. nothing to do in unset");
+ LOGINFO("set noti already failed. nothing to do in unset");
return 0;
}
@@ -1113,7 +1257,7 @@ void start_main(unsigned int flags)
ret = init_sysfs(flags);
break;
case INIT_POLL:
- LOGDBG("poll init");
+ LOGINFO("poll init");
ret = init_pm_poll(poll_callback);
break;
}
diff --git a/pm_key_filter.c b/pm_key_filter.c
index 3820c1e..7ee21da 100644
--- a/pm_key_filter.c
+++ b/pm_key_filter.c
@@ -40,8 +40,6 @@
#define LONG_PRESS_INTERVAL 1000000 /* 1000 ms */
#define COMBINATION_INTERVAL 300000 /* 300 ms */
-#define VCONFKEY_TESTMODE_POWER_OFF_POPUP "db/testmode/pwr_off_popup"
-
#define KEY_RELEASED 0
#define KEY_PRESSED 1
#define KEY_BEING_PRESSED 2
@@ -97,68 +95,63 @@ int check_key_filter(int length, char buf[])
int ignore = true;
int idx = 0;
int val = -1;
- int val1 = -1;
- int ret = -1;
- int ret1 = -1;
do {
pinput = (struct input_event *)&buf[idx];
if (pinput->type == EV_SYN) ;
else if (pinput->type == EV_KEY) {
if (pinput->code == KEY_POWER) {
- ret = vconf_get_int("memory/startapps/sequence", &val);
- ret1 = vconf_get_int("memory/boot-animation/finished", &val1);
- if ((val == 1 || ret != 0) && (val1 == 1 || ret1 != 0)) {
- if (pinput->value == KEY_RELEASED) { /* release */
- if (!(cur_state == S_LCDOFF || cur_state == S_SLEEP) && !cancel_lcdoff && !(key_combination == KEY_COMBINATION_SCREENCAPTURE)) {
- check_processes(S_LCDOFF);
- check_processes(S_LCDDIM);
- if (!(trans_condition & (MASK_DIM | MASK_OFF))) {
- recv_data.pid = -1;
- recv_data.cond = 0x400; /* go to S_LCDOFF */
- if(vconf_get_int(VCONFKEY_FLASHPLAYER_FULLSCREEN, &val)<0 || val == 0)
- (*g_pm_callback)(PM_CONTROL_EVENT, &recv_data);
- }
- } else
- ignore = false;
- key_combination = KEY_COMBINATION_STOP;
+ if (pinput->value == KEY_RELEASED) { /* release */
+ if (!(cur_state == S_LCDOFF || cur_state == S_SLEEP) && !cancel_lcdoff && !(key_combination == KEY_COMBINATION_SCREENCAPTURE)) {
+ check_processes(S_LCDOFF);
+ check_processes(S_LCDDIM);
+ if( check_holdkey_block(S_LCDOFF) == false &&
+ check_holdkey_block(S_LCDDIM) == false) {
+ delete_condition(S_LCDOFF);
+ delete_condition(S_LCDDIM);
+ /* LCD off forcly */
+ recv_data.pid = -1;
+ recv_data.cond = 0x400;
+ if(vconf_get_int(VCONFKEY_FLASHPLAYER_FULLSCREEN, &val)<0 || val == 0)
+ (*g_pm_callback)(PM_CONTROL_EVENT, &recv_data);
+ }
+ } else
+ ignore = false;
+ key_combination = KEY_COMBINATION_STOP;
+ if (combination_timeout_id > 0) {
+ g_source_remove(combination_timeout_id);
+ combination_timeout_id = 0;
+ }
+ cancel_lcdoff = 0;
+ if (longkey_timeout_id > 0) {
+ g_source_remove(longkey_timeout_id);
+ longkey_timeout_id = 0;
+ }
+ } else if (pinput->value == KEY_PRESSED) {
+ LOGINFO("power key pressed");
+ pressed_time.tv_sec = (pinput->time).tv_sec;
+ pressed_time.tv_usec = (pinput->time).tv_usec;
+ if (key_combination == KEY_COMBINATION_STOP) {
+ /* add long key timer */
+ longkey_timeout_id = g_timeout_add_full(G_PRIORITY_DEFAULT, LONG_PRESS_INTERVAL / 1000,
+ (GSourceFunc)longkey_pressed, NULL, NULL);
+ key_combination = KEY_COMBINATION_START;
+ combination_timeout_id = g_timeout_add_full(G_PRIORITY_DEFAULT, COMBINATION_INTERVAL / 1000,
+ (GSourceFunc)combination_failed, NULL, NULL);
+ } else if (key_combination == KEY_COMBINATION_START) {
if (combination_timeout_id > 0) {
g_source_remove(combination_timeout_id);
combination_timeout_id = 0;
}
- cancel_lcdoff = 0;
- if (longkey_timeout_id > 0) {
- g_source_remove(longkey_timeout_id);
- longkey_timeout_id = 0;
- }
- } else if (pinput->value == KEY_PRESSED) {
- LOGINFO("power key pressed");
- pressed_time.tv_sec = (pinput->time).tv_sec;
- pressed_time.tv_usec = (pinput->time).tv_usec;
- if (key_combination == KEY_COMBINATION_STOP) {
- /* add long key timer */
- longkey_timeout_id = g_timeout_add_full(G_PRIORITY_DEFAULT, LONG_PRESS_INTERVAL / 1000,
- (GSourceFunc)longkey_pressed, NULL, NULL);
- key_combination = KEY_COMBINATION_START;
- combination_timeout_id = g_timeout_add_full(G_PRIORITY_DEFAULT, COMBINATION_INTERVAL / 1000,
- (GSourceFunc)combination_failed, NULL, NULL);
- } else if (key_combination == KEY_COMBINATION_START) {
- if (combination_timeout_id > 0) {
- g_source_remove(combination_timeout_id);
- combination_timeout_id = 0;
- }
- LOGINFO("capture mode");
- key_combination = KEY_COMBINATION_SCREENCAPTURE;
- ignore = false;
- }
+ LOGINFO("capture mode");
+ key_combination = KEY_COMBINATION_SCREENCAPTURE;
+ ignore = false;
+ }
- } else if (pinput->value == KEY_BEING_PRESSED && /* being pressed */
- (((pinput->time).tv_sec - pressed_time.tv_sec) * 1000000 + ((pinput->time).tv_usec - pressed_time.tv_usec))
- > LONG_PRESS_INTERVAL) {
- longkey_pressed(NULL);
- }
- } else {
- ignore = false;
+ } else if (pinput->value == KEY_BEING_PRESSED && /* being pressed */
+ (((pinput->time).tv_sec - pressed_time.tv_sec) * 1000000 + ((pinput->time).tv_usec - pressed_time.tv_usec))
+ > LONG_PRESS_INTERVAL) {
+ longkey_pressed(NULL);
}
} else {
if (pinput->code == KEY_VOLUMEDOWN) {
diff --git a/pm_llinterface.c b/pm_llinterface.c
index 3690fb8..ce0383d 100644
--- a/pm_llinterface.c
+++ b/pm_llinterface.c
@@ -29,6 +29,8 @@
#include "pm_device_plugin.h"
#include "util.h"
#include "pm_conf.h"
+#include "vconf.h"
+#include "pm_core.h"
typedef struct _PMSys PMSys;
struct _PMSys {
@@ -38,6 +40,7 @@ struct _PMSys {
int (*sys_suspend) (PMSys *);
int (*bl_onoff) (PMSys *, int);
int (*bl_brt) (PMSys *, int);
+ int (*bl_dim) (PMSys *);
};
static PMSys *pmsys;
@@ -49,7 +52,14 @@ static bool x_dpms_enable = false;
static void _update_curbrt(PMSys *p)
{
- plugin_intf->OEM_sys_get_backlight_brightness(DEFAULT_DISPLAY, &(p->def_brt));
+ int power_saving_stat = -1;
+ int power_saving_display_stat = -1;
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat);
+ if (power_saving_stat == 1)
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat);
+ if (power_saving_display_stat != 1)
+ power_saving_display_stat = 0;
+ plugin_intf->OEM_sys_get_backlight_brightness(DEFAULT_DISPLAY, &(p->def_brt), power_saving_display_stat);
}
static int _bl_onoff(PMSys *p, int onoff)
@@ -59,7 +69,25 @@ static int _bl_onoff(PMSys *p, int onoff)
static int _bl_brt(PMSys *p, int brightness)
{
- return plugin_intf->OEM_sys_set_backlight_brightness(DEFAULT_DISPLAY, brightness);
+ int power_saving_stat = -1;
+ int power_saving_display_stat = -1;
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat);
+ if (power_saving_stat == 1)
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat);
+ if (power_saving_display_stat != 1)
+ power_saving_display_stat = 0;
+ int ret = plugin_intf->OEM_sys_set_backlight_brightness(DEFAULT_DISPLAY, brightness, power_saving_display_stat);
+LOGERR("set brightness %d,%d(saving %d) %d", DEFAULT_DISPLAY, brightness, power_saving_display_stat, ret);
+ return ret;
+}
+
+static int _bl_dim(PMSys *p)
+{
+ int ret = -1;
+
+ LOGINFO("LCD dim");
+ ret = plugin_intf->OEM_sys_set_backlight_dimming(DEFAULT_DISPLAY, 1);
+ return ret;
}
static int _sys_suspend(PMSys *p)
@@ -70,9 +98,10 @@ static int _sys_suspend(PMSys *p)
static void _init_bldev(PMSys *p, unsigned int flags)
{
int ret;
- _update_curbrt(p);
- p->bl_brt = _bl_brt;
- p->bl_onoff = _bl_onoff;
+ _update_curbrt(p);
+ p->bl_brt = _bl_brt;
+ p->bl_onoff = _bl_onoff;
+ p->bl_dim = _bl_dim;
#ifdef ENABLE_X_LCD_ONOFF
if (flags & FLAG_X_DPMS) {
p->bl_onoff = pm_x_set_lcd_backlight;
@@ -128,8 +157,8 @@ int backlight_off()
int backlight_dim()
{
int ret = 0;
- if (pmsys && pmsys->bl_brt) {
- ret = pmsys->bl_brt(pmsys, pmsys->dim_brt);
+ if (pmsys && pmsys->bl_dim) {
+ ret = pmsys->bl_dim(pmsys);
}
return ret;
}
@@ -137,7 +166,10 @@ int backlight_dim()
int backlight_restore()
{
int ret = 0;
- if (pmsys && pmsys->bl_brt) {
+
+ if (status_flag & PWRSV_FLAG) {
+ ret = backlight_dim();
+ } else if (pmsys && pmsys->bl_brt) {
ret = pmsys->bl_brt(pmsys, pmsys->def_brt);
}
return ret;
@@ -184,7 +216,7 @@ int init_sysfs(unsigned int flags)
if (pmsys->bl_onoff == NULL && pmsys->sys_suspend == NULL) {
LOGERR
- ("We have no managable resource to reduce the power consumption");
+ ("We have no managable resource to reduce the power consumption");
return -1;
}
diff --git a/pm_lsensor.c b/pm_lsensor.c
index 0f1cf52..d006b12 100644
--- a/pm_lsensor.c
+++ b/pm_lsensor.c
@@ -37,8 +37,48 @@ static int (*_default_action) (int);
static int alc_timeout_id = 0;
static int sf_handle = -1;
static int max_brightness = 10;
+static int min_brightness = 1;
+static int range_brightness = 9;
+static int init_brightness = FALSE;
static int fault_count = 0;
+static int get_backlight_brightness()
+{
+ int max_value = 0;
+ int min_value = 0;
+ int range_value = 0;
+ int ret = -1;
+
+ ret = plugin_intf->OEM_sys_get_backlight_max_brightness(
+ DEFAULT_DISPLAY,&max_value);
+ if (ret != 0 || max_value <= 0) {
+ LOGERR("max brightness is wrong! (%d, %d)", ret, max_value);
+ return FALSE;
+ }
+
+ ret = plugin_intf->OEM_sys_get_backlight_min_brightness(
+ DEFAULT_DISPLAY, &min_value);
+ if (ret != 0 || min_value < 0) {
+ LOGERR("min brightness is wrong! (%d, %d)", ret, min_value);
+ return FALSE;
+ }
+
+ range_value = max_value - min_value;
+ if (range_value <= 0) {
+ LOGERR("range brightness is wrong! (%d, %d, %d)",
+ max_value, min_value, range_value);
+ return FALSE;
+ }
+
+ max_brightness = max_value;
+ min_brightness = min_value;
+ range_brightness = range_value;
+ LOGINFO("get brightness success max(%d) min(%d) range(%d)",
+ max_brightness, min_brightness, range_brightness);
+
+ return TRUE;
+}
+
static gboolean alc_handler(gpointer data)
{
int value = 0;
@@ -54,13 +94,23 @@ static gboolean alc_handler(gpointer data)
if (sf_get_data(sf_handle, LIGHT_BASE_DATA_SET, &light_data) < 0) {
fault_count++;
} else {
+ if (init_brightness == FALSE)
+ init_brightness = get_backlight_brightness();
if (light_data.values[0] < 0.0 || light_data.values[0] > 10.0) {
LOGINFO("fail to load light data : %d", (int)light_data.values[0]);
fault_count++;
} else {
int tmp_value;
- value = max_brightness * (int)light_data.values[0] / 10;
- plugin_intf->OEM_sys_get_backlight_brightness(DEFAULT_DISPLAY, &tmp_value);
+ int power_saving_stat = -1;
+ int power_saving_display_stat = -1;
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat);
+ if (power_saving_stat == 1)
+ vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat);
+ if (power_saving_display_stat != 1)
+ power_saving_display_stat = 0;
+ value = min_brightness +
+ (range_brightness * (int)light_data.values[0] / 10);
+ plugin_intf->OEM_sys_get_backlight_brightness(DEFAULT_DISPLAY, &tmp_value, power_saving_display_stat);
if (tmp_value != value) {
set_default_brt(value);
backlight_restore();
@@ -74,7 +124,7 @@ static gboolean alc_handler(gpointer data)
if (alc_timeout_id != 0)
g_source_remove(alc_timeout_id);
alc_timeout_id = 0;
- vconf_set_bool(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_BOOL, 0);
+ vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_OFF);
LOGERR("Fault counts is over 5, disable automatic brightness");
return FALSE;
}
@@ -87,7 +137,7 @@ static gboolean alc_handler(gpointer data)
static int alc_action(int timeout)
{
- LOGDBG("alc action");
+ LOGINFO("alc action");
/* sampling timer add */
if (alc_timeout_id == 0 && !(status_flag & PWRSV_FLAG))
alc_timeout_id =
@@ -107,7 +157,7 @@ static int connect_sfsvc()
{
int sf_state = -1;
/* connect with sensor fw */
- LOGDBG("connect with sensor fw");
+ LOGINFO("connect with sensor fw");
sf_handle = sf_connect(LIGHT_SENSOR);
if (sf_handle < 0) {
LOGERR("sensor attach fail");
@@ -126,7 +176,7 @@ static int connect_sfsvc()
static int disconnect_sfsvc()
{
- LOGDBG("disconnect with sensor fw");
+ LOGINFO("disconnect with sensor fw");
if(sf_handle >= 0)
{
sf_stop(sf_handle);
@@ -149,15 +199,19 @@ static int disconnect_sfsvc()
static int set_alc_function(keynode_t *key_nodes, void *data)
{
int onoff = 0;
+ int ret = -1;
+ int brt = -1;
+ int default_brt = -1;
+ int max_brt = -1;
if (key_nodes == NULL) {
LOGERR("wrong parameter, key_nodes is null");
return -1;
}
- onoff = vconf_keynode_get_bool(key_nodes);
+ onoff = vconf_keynode_get_int(key_nodes);
- if (onoff == true) {
+ if (onoff == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
if(connect_sfsvc() < 0)
return -1;
@@ -170,8 +224,27 @@ static int set_alc_function(keynode_t *key_nodes, void *data)
SAMPLING_INTERVAL,
(GSourceFunc) alc_handler, NULL,
NULL);
+ } else if (onoff == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) {
+ LOGINFO("auto brightness paused!");
+ disconnect_sfsvc();
} else {
disconnect_sfsvc();
+
+ ret = get_setting_brightness(&default_brt);
+ if (ret != 0 || default_brt < 0) {
+ LOGINFO("fail to read vconf value for brightness");
+
+ if (0 > plugin_intf->OEM_sys_get_backlight_max_brightness(DEFAULT_DISPLAY, &max_brt))
+ brt = 7;
+ else
+ brt = max_brt * 0.4;
+ if(default_brt < 0)
+ vconf_set_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, brt);
+ default_brt = brt;
+ }
+
+ set_default_brt(default_brt);
+ backlight_restore();
}
return 0;
@@ -185,8 +258,8 @@ static gboolean check_sfsvc(gpointer data)
LOGINFO("register sfsvc");
- vconf_get_bool(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_BOOL, &vconf_auto);
- if (vconf_auto == true) {
+ vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &vconf_auto);
+ if (vconf_auto == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
if(connect_sfsvc() < 0)
return TRUE;
@@ -200,7 +273,7 @@ static gboolean check_sfsvc(gpointer data)
(GSourceFunc) alc_handler, NULL,
NULL);
if (alc_timeout_id != 0)
- return FALSE;
+ return FALSE;
disconnect_sfsvc();
return TRUE;
}
@@ -213,10 +286,10 @@ static int prepare_lsensor(void *data)
int alc_conf;
int sf_state = 0;
- plugin_intf->OEM_sys_get_backlight_max_brightness(DEFAULT_DISPLAY, &max_brightness);
- vconf_get_bool(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_BOOL, &alc_conf);
+ init_brightness = get_backlight_brightness();
+ vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &alc_conf);
- if (alc_conf == true) {
+ if (alc_conf == SETTING_BRIGHTNESS_AUTOMATIC_ON) {
g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
SAMPLING_INTERVAL,
(GSourceFunc) check_sfsvc, NULL,
@@ -224,7 +297,7 @@ static int prepare_lsensor(void *data)
}
/* add auto_brt_setting change handler */
- vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_BOOL,
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT,
(void *)set_alc_function, NULL);
if (prev_init_extention != NULL)
diff --git a/pm_poll.c b/pm_poll.c
index 82274fb..21e925f 100644
--- a/pm_poll.c
+++ b/pm_poll.c
@@ -153,7 +153,7 @@ static int init_sock(char *sock_path)
if (!strcmp(sock_path, SOCK_PATH))
sockfd = fd;
- LOGDBG("init sock() sueccess!");
+ LOGINFO("init sock() sueccess!");
return fd;
}
@@ -173,7 +173,7 @@ int init_pm_poll(int (*pm_callback) (int, PMMsg *))
pm_input_env = getenv("PM_INPUT");
if ((pm_input_env != NULL) && (strlen(pm_input_env) < 1024)) {
- LOGDBG("Getting input device path from environment: %s",
+ LOGINFO("Getting input device path from environment: %s",
pm_input_env);
/* Add 2 bytes for following strncat() */
dev_paths_size = strlen(pm_input_env) + strlen(SOCK_PATH) + strlen(DEV_PATH_DLM) + 1;
@@ -212,11 +212,11 @@ int init_pm_poll(int (*pm_callback) (int, PMMsg *))
if (strcmp(path_tok, SOCK_PATH) == 0) {
gpollfd->fd = init_sock(SOCK_PATH);
- LOGDBG("pm_poll domain socket file: %s, fd: %d",
+ LOGINFO("pm_poll domain socket file: %s, fd: %d",
path_tok, gpollfd->fd);
} else {
gpollfd->fd = open(path_tok, O_RDONLY);
- LOGDBG("pm_poll input device file: %s, fd: %d",
+ LOGINFO("pm_poll input device file: %s, fd: %d",
path_tok, gpollfd->fd);
}
diff --git a/pm_setting.c b/pm_setting.c
index 8a1f5f3..4a3b70c 100644
--- a/pm_setting.c
+++ b/pm_setting.c
@@ -22,11 +22,13 @@
#include "util.h"
static const char *setting_keys[SETTING_GET_END] = {
- [SETTING_TO_NORMAL] = VCONFKEY_SYSMAN_LCD_TIMEOUT_NORMAL,
+ [SETTING_TO_NORMAL] = VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL,
[SETTING_LOW_BATT] = VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
[SETTING_CHARGING] = VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW,
[SETTING_BRT_LEVEL] = VCONFKEY_SETAPPL_LCD_BRIGHTNESS,
[SETTING_LOCK_SCREEN] = VCONFKEY_IDLE_LOCK_STATE,
+ [SETTING_POWER_SAVING] = VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS,
+ [SETTING_POWER_SAVING_DISPLAY] = VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY,
};
static int (*update_setting) (int key_idx, int val);
@@ -67,7 +69,11 @@ int get_run_timeout(int *timeout)
}
ret = vconf_get_int(setting_keys[SETTING_TO_NORMAL], &vconf_timeout);
- *timeout = vconf_timeout - dim_timeout;
+
+ if(vconf_timeout == 0)
+ *timeout = 0; //timeout 0 : Always ON (Do not apply dim_timeout)
+ else
+ *timeout = vconf_timeout - dim_timeout;
return ret;
}
@@ -78,7 +84,7 @@ int get_dim_timeout(int *timeout)
/* TODO if needed */
*timeout = 5; /* default timeout */
get_env("PM_TO_LCDDIM", buf, sizeof(buf));
- LOGDBG("Get lcddim timeout [%s]", buf);
+ LOGINFO("Get lcddim timeout [%s]", buf);
*timeout = atoi(buf);
return 0;
}
@@ -89,7 +95,7 @@ int get_off_timeout(int *timeout)
/* TODO if needed */
*timeout = 5; /* default timeout */
get_env("PM_TO_LCDOFF", buf, sizeof(buf));
- LOGDBG("Get lcdoff timeout [%s]", buf);
+ LOGINFO("Get lcdoff timeout [%s]", buf);
*timeout = atoi(buf);
return 0;
}
@@ -104,7 +110,10 @@ static int setting_cb(keynode_t *key_nodes, void *data)
return -1;
}
if (update_setting != NULL) {
- update_setting((int)data, vconf_keynode_get_int(tmp));
+ if ((int)data >= SETTING_POWER_SAVING)
+ update_setting((int)data, vconf_keynode_get_bool(tmp));
+ else
+ update_setting((int)data, vconf_keynode_get_int(tmp));
}
return 0;
diff --git a/pm_setting.h b/pm_setting.h
index 5672768..12c09ee 100644
--- a/pm_setting.h
+++ b/pm_setting.h
@@ -37,6 +37,8 @@ enum {
SETTING_CHARGING,
SETTING_BRT_LEVEL,
SETTING_LOCK_SCREEN,
+ SETTING_POWER_SAVING,
+ SETTING_POWER_SAVING_DISPLAY,
SETTING_GET_END,
SETTING_PM_STATE = SETTING_GET_END,
SETTING_END
diff --git a/pm_x_lcd_onoff.c b/pm_x_lcd_onoff.c
index 58980a8..10ed383 100644
--- a/pm_x_lcd_onoff.c
+++ b/pm_x_lcd_onoff.c
@@ -33,7 +33,7 @@ static int pm_x_set_lcd_backlight(struct _PMSys *p, int onoff)
char cmd_line[32];
int ret;
- LOGDBG("Backlight onoff=%d", onoff);
+ LOGINFO("Backlight onoff=%d", onoff);
if (onoff == STATUS_ON)
snprintf(cmd_line, sizeof(cmd_line), "%s", CMD_STANDBY);
else
diff --git a/util.h b/util.h
index d9f85e3..8eb072d 100644
--- a/util.h
+++ b/util.h
@@ -103,17 +103,6 @@ extern void pm_log(int priority, char *fmt, ...);
# define LOGERR(fmt, arg...) pm_log(LOG_ERR, fmt, ## arg)
#endif
-/*
- * @brief LOG_DEBUG wrapper
- */
-#if defined(DEBUG_PRINT) && defined(ENABLE_DLOG_OUT)
-# define LOGDBG(fmt, arg...) pm_log(DLOG_DEBUG, fmt, ## arg)
-#elif defined(DEBUG_PRINT)
-# define LOGDBG(fmt, arg...) pm_log(LOG_DEBUG, fmt, ## arg)
-#else
-# define LOGDBG(fmt, arg...) do { } while (0);
-#endif
-
/**
* @}
*/