To move display-lock/lock-detector files to core, save_display_log, print_info functions are also relocated.
Because there is a dependence between files and functions.
This function is added to below display-misc.
void display_misc_save_display_log(const char *path);
-> This function is called when the poweroff notify, sighup situation
or dbus method is called to save display log.
Change-Id: I8d8865aa3fc04ab3ac51e7e3106bdd3f42baf92e
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
_E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno());
}
-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];
-
- if (fd < 0)
- return;
-
- snprintf(buf, sizeof(buf),
- "\n==========================================="
- "===========================\n");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- snprintf(buf, sizeof(buf), "Timeout Info: Run[%dms] Dim[%dms] Off[%dms]\n",
- states[S_NORMAL].timeout,
- states[S_LCDDIM].timeout, states[S_LCDOFF].timeout);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Tran. Locked : %s %s %s\n",
- (get_trans_condition() & MASK_NORMAL) ? states[S_NORMAL].name : "-",
- (get_trans_condition() & MASK_DIM) ? states[S_LCDDIM].name : "-",
- (get_trans_condition() & MASK_OFF) ? states[S_LCDOFF].name : "-");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current State: %s\n",
- states[get_pm_cur_state()].name);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current Lock Conditions: \n");
- ret = write(fd, buf, strlen(buf));
- 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;
- snprintf(buf, sizeof(buf),
- " %d: [%s] locked by pid %d %s %s\n",
- i++, states[s_index].name, t->pid, pname, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- }
- }
-
- print_lock_info_list(fd);
-
-#ifdef ENABLE_PM_LOG
- pm_history_print(fd, 250);
-#endif
-}
-
-void save_display_log(const char *path)
-{
- int fd, ret;
- char buf[255];
- time_t now_time;
- char time_buf[30];
-
- _D("internal state is saved!");
-
- time(&now_time);
- ctime_r(&now_time, time_buf);
- time_buf[strlen(time_buf) - 1] = 0;
-
- fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
- if (fd != -1) {
- snprintf(buf, sizeof(buf),
- "\npm_state_log now-time : %d(s) %s\n\n",
- (int)now_time, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- snprintf(buf, sizeof(buf), "pm_status_flag: %#x\n", get_pm_status_flag());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- if (disp_plgn->get_lock_screen_state ) {
- snprintf(buf, sizeof(buf), "screen lock status : %d\n",
- disp_plgn->get_lock_screen_state());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
- }
- print_info(fd);
- close(fd);
- }
-
- fd = open("/dev/console", O_WRONLY);
- if (fd != -1) {
- print_info(fd);
- close(fd);
- }
-}
-
/* SIGHUP signal handler
* For debug... print info to syslog
*/
_E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno());
}
-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];
-
- if (fd < 0)
- return;
-
- snprintf(buf, sizeof(buf),
- "\n==========================================="
- "===========================\n");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- snprintf(buf, sizeof(buf), "Timeout Info: Run[%dms] Dim[%dms] Off[%dms]\n",
- states[S_NORMAL].timeout,
- states[S_LCDDIM].timeout, states[S_LCDOFF].timeout);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Tran. Locked : %s %s %s\n",
- (get_trans_condition() & MASK_NORMAL) ? states[S_NORMAL].name : "-",
- (get_trans_condition() & MASK_DIM) ? states[S_LCDDIM].name : "-",
- (get_trans_condition() & MASK_OFF) ? states[S_LCDOFF].name : "-");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current State: %s\n",
- states[get_pm_cur_state()].name);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current Lock Conditions: \n");
- ret = write(fd, buf, strlen(buf));
- 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;
- snprintf(buf, sizeof(buf),
- " %d: [%s] locked by pid %d %s %s\n",
- i++, states[s_index].name, t->pid, pname, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- }
- }
-
- print_lock_info_list(fd);
-
-#ifdef ENABLE_PM_LOG
- pm_history_print(fd, 250);
-#endif
-}
-
-void save_display_log(const char *path)
-{
- int fd, ret;
- char buf[255];
- time_t now_time;
- char time_buf[30];
-
- _D("internal state is saved!");
-
- time(&now_time);
- ctime_r(&now_time, time_buf);
- time_buf[strlen(time_buf) - 1] = 0;
-
- fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
- if (fd != -1) {
- snprintf(buf, sizeof(buf),
- "\npm_state_log now-time : %d(s) %s\n\n",
- (int)now_time, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- snprintf(buf, sizeof(buf), "pm_status_flag: %#x\n", get_pm_status_flag());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- if (disp_plgn->get_lock_screen_state ) {
- snprintf(buf, sizeof(buf), "screen lock status : %d\n",
- disp_plgn->get_lock_screen_state());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
- }
- print_info(fd);
- close(fd);
- }
-
- fd = open("/dev/console", O_WRONLY);
- if (fd != -1) {
- print_info(fd);
- close(fd);
- }
-}
-
/* SIGHUP signal handler
* For debug... print info to syslog
*/
_E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno());
}
-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];
-
- if (fd < 0)
- return;
-
- snprintf(buf, sizeof(buf),
- "\n==========================================="
- "===========================\n");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- snprintf(buf, sizeof(buf), "Timeout Info: Run[%dms] Dim[%dms] Off[%dms]\n",
- states[S_NORMAL].timeout,
- states[S_LCDDIM].timeout, states[S_LCDOFF].timeout);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Tran. Locked : %s %s %s\n",
- (get_trans_condition() & MASK_NORMAL) ? states[S_NORMAL].name : "-",
- (get_trans_condition() & MASK_DIM) ? states[S_LCDDIM].name : "-",
- (get_trans_condition() & MASK_OFF) ? states[S_LCDOFF].name : "-");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current State: %s\n",
- states[get_pm_cur_state()].name);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current Lock Conditions: \n");
- ret = write(fd, buf, strlen(buf));
- 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;
- snprintf(buf, sizeof(buf),
- " %d: [%s] locked by pid %d %s %s\n",
- i++, states[s_index].name, t->pid, pname, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- }
- }
-
- print_lock_info_list(fd);
-
-#ifdef ENABLE_PM_LOG
- pm_history_print(fd, 250);
-#endif
-}
-
-void save_display_log(const char *path)
-{
- int fd, ret;
- char buf[255];
- time_t now_time;
- char time_buf[30];
-
- _D("internal state is saved!");
-
- time(&now_time);
- ctime_r(&now_time, time_buf);
- time_buf[strlen(time_buf) - 1] = 0;
-
- fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
- if (fd != -1) {
- snprintf(buf, sizeof(buf),
- "\npm_state_log now-time : %d(s) %s\n\n",
- (int)now_time, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- snprintf(buf, sizeof(buf), "pm_status_flag: %#x\n", get_pm_status_flag());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- if (disp_plgn->get_lock_screen_state ) {
- snprintf(buf, sizeof(buf), "screen lock status : %d\n",
- disp_plgn->get_lock_screen_state());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
- }
- print_info(fd);
- close(fd);
- }
-
- fd = open("/dev/console", O_WRONLY);
- if (fd != -1) {
- print_info(fd);
- close(fd);
- }
-}
-
/* SIGHUP signal handler
* For debug... print info to syslog
*/
_E("Failed to set vconf value for lcd off source: %d", vconf_get_ext_errno());
}
-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];
-
- if (fd < 0)
- return;
-
- snprintf(buf, sizeof(buf),
- "\n==========================================="
- "===========================\n");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- snprintf(buf, sizeof(buf), "Timeout Info: Run[%dms] Dim[%dms] Off[%dms]\n",
- states[S_NORMAL].timeout,
- states[S_LCDDIM].timeout, states[S_LCDOFF].timeout);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Tran. Locked : %s %s %s\n",
- (get_trans_condition() & MASK_NORMAL) ? states[S_NORMAL].name : "-",
- (get_trans_condition() & MASK_DIM) ? states[S_LCDDIM].name : "-",
- (get_trans_condition() & MASK_OFF) ? states[S_LCDOFF].name : "-");
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current State: %s\n",
- states[get_pm_cur_state()].name);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
-
- snprintf(buf, sizeof(buf), "Current Lock Conditions: \n");
- ret = write(fd, buf, strlen(buf));
- 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;
- snprintf(buf, sizeof(buf),
- " %d: [%s] locked by pid %d %s %s\n",
- i++, states[s_index].name, t->pid, pname, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("Write() failed: %d", errno);
- }
- }
-
- print_lock_info_list(fd);
-
-#ifdef ENABLE_PM_LOG
- pm_history_print(fd, 250);
-#endif
-}
-
-void save_display_log(const char *path)
-{
- int fd, ret;
- char buf[255];
- time_t now_time;
- char time_buf[30];
-
- _D("internal state is saved!");
-
- time(&now_time);
- ctime_r(&now_time, time_buf);
- time_buf[strlen(time_buf) - 1] = 0;
-
- fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
- if (fd != -1) {
- snprintf(buf, sizeof(buf),
- "\npm_state_log now-time : %d(s) %s\n\n",
- (int)now_time, time_buf);
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- snprintf(buf, sizeof(buf), "pm_status_flag: %#x\n", get_pm_status_flag());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
-
- if (disp_plgn->get_lock_screen_state ) {
- snprintf(buf, sizeof(buf), "screen lock status : %d\n",
- disp_plgn->get_lock_screen_state());
- ret = write(fd, buf, strlen(buf));
- if (ret < 0)
- _E("write() failed (%d)", errno);
- }
- print_info(fd);
- close(fd);
- }
-
- fd = open("/dev/console", O_WRONLY);
- if (fd != -1) {
- print_info(fd);
- close(fd);
- }
-}
-
/* SIGHUP signal handler
* For debug... print info to syslog
*/
int display_off_by_reason(const char *reason);
void update_lcdoff_source(int source);
int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name);
-void save_display_log(const char *path);
int custom_lcdon(int timeout);
void lcd_on_direct(enum device_flags flags);
void lcd_on_procedure(int state, enum device_flags flag);
#include <stdio.h>
#include <stdbool.h>
+#include <time.h>
+#include <unistd.h>
#include <vconf-keys.h>
#include "battery/power-supply.h"
#include "shared/device-notifier.h"
#include "shared/log.h"
+#include "core.h"
#include "display.h"
#include "display-backlight.h"
+#include "display-lock.h"
#include "display-misc.h"
#include "display-panel.h"
#include "display-plugin.h"
+#include "display-state-transition.h"
+#include "lock-detector.h"
#include "poll.h"
static bool stay_touchscreen_off = false;
void display_misc_unregister_battery_health_notifier(void)
{
unregister_notifier(DEVICE_NOTIFIER_BATTERY_HEALTH, changed_battery_health);
+}
+
+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;
+ const char *normal_state_name;
+ const char *dim_state_name;
+ const char *off_state_name;
+ const char *current_state_name;
+
+ display_plugin_state_get_timeout(S_NORMAL, &normal_state_timeout);
+ display_plugin_state_get_timeout(S_LCDDIM, &dim_state_timeout);
+ display_plugin_state_get_timeout(S_LCDOFF, &off_stata_timeout);
+
+ if (fd < 0)
+ return;
+
+ snprintf(buf, sizeof(buf),
+ "\n==========================================="
+ "===========================\n");
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("Write() failed: %d", errno);
+ snprintf(buf, sizeof(buf), "Timeout Info: Run[%dms] Dim[%dms] Off[%dms]\n",
+ normal_state_timeout, dim_state_timeout, off_stata_timeout);
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("Write() failed: %d", errno);
+
+ display_plugin_state_get_name(S_NORMAL, &normal_state_name);
+ display_plugin_state_get_name(S_LCDDIM, &dim_state_name);
+ display_plugin_state_get_name(S_LCDOFF, &off_state_name);
+ snprintf(buf, sizeof(buf), "Tran. Locked : %s %s %s\n",
+ (get_trans_condition() & MASK_NORMAL) ? normal_state_name : "-",
+ (get_trans_condition() & MASK_DIM) ? dim_state_name : "-",
+ (get_trans_condition() & MASK_OFF) ? off_state_name : "-");
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("Write() failed: %d", errno);
+
+ display_plugin_state_get_name(get_pm_cur_state(), ¤t_state_name);
+ snprintf(buf, sizeof(buf), "Current State: %s\n", current_state_name);
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("Write() failed: %d", errno);
+
+ snprintf(buf, sizeof(buf), "Current Lock Conditions: \n");
+ ret = write(fd, buf, strlen(buf));
+ 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);
+ }
+ }
+
+ print_lock_info_list(fd);
+
+#ifdef ENABLE_PM_LOG
+ pm_history_print(fd, 250);
+#endif
+}
+
+/** FIXME: This function should be relocated after refactoring.
+ * Because, display log functions are spreaded to slave-logging.c, lock-detector.c.
+ * Function location should be discussed.
+ */
+void display_misc_save_display_log(const char *path)
+{
+ int fd, ret;
+ char buf[255];
+ time_t now_time;
+ char time_buf[30];
+
+ _D("internal state is saved!");
+
+ time(&now_time);
+ ctime_r(&now_time, time_buf);
+ time_buf[strlen(time_buf) - 1] = 0;
+
+ fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0644);
+ if (fd != -1) {
+ snprintf(buf, sizeof(buf),
+ "\npm_state_log now-time : %d(s) %s\n\n",
+ (int)now_time, time_buf);
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("write() failed (%d)", errno);
+
+ snprintf(buf, sizeof(buf), "pm_status_flag: %#x\n", get_pm_status_flag());
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("write() failed (%d)", errno);
+
+ /* FIXME: display_plugin_get_lock_screen_state should be checked return value after modification */
+ snprintf(buf, sizeof(buf), "screen lock status : %d\n",
+ display_plugin_get_lock_screen_state());
+ ret = write(fd, buf, strlen(buf));
+ if (ret < 0)
+ _E("write() failed (%d)", errno);
+
+ print_info(fd);
+ close(fd);
+ }
+
+ fd = open("/dev/console", O_WRONLY);
+ if (fd != -1) {
+ print_info(fd);
+ close(fd);
+ }
}
\ No newline at end of file
void display_misc_get_stay_touchscreen_off(bool *on);
void display_misc_register_battery_health_notifier(void);
void display_misc_unregister_battery_health_notifier(void);
+void display_misc_save_display_log(const char *path);
#endif /* __DISPLAY_MISC_H__ */
\ No newline at end of file
return 0;
}
+/* FIXME: return 0 can be value of get_lock_screen_state, it is hard to distinguish error or not */
int display_plugin_get_lock_screen_state(void)
{
if (g_display_plugin.get_lock_screen_state)
#include "util.h"
#include "core.h"
+#include "display-misc.h"
#include "shared/device-notifier.h"
struct lock_info {
if (ret < 0)
_W("Can not move(%d)", ret);
- save_display_log(PM_STATE_LOG_FILE);
+ display_misc_save_display_log(PM_STATE_LOG_FILE);
return ret;
}
if (ret < 0)
_W("Can not move(%d)", ret);
- save_display_log(PM_STATE_LOG_GHOST_PATH);
+ display_misc_save_display_log(PM_STATE_LOG_GHOST_PATH);
return 0;
}
- pmlock_detector_poweroff_cb()
- cleanup_pmlock_statistics()
- do_copy_force()
- - save_display_log()
+ - display_misc_save_display_log()
2. tzip
- tzip_poweroff()
- tzip_server_exit()