display: misc: Relocate save_display_log()/print_info() to reduce plugin duplication 33/292633/16
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 10 May 2023 07:42:30 +0000 (16:42 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Tue, 30 May 2023 11:48:34 +0000 (20:48 +0900)
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>
13 files changed:
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/display/core.h
src/display/display-lock.c [moved from src/display/plugin-common/display-lock.c with 100% similarity]
src/display/display-lock.h [moved from src/display/plugin-common/display-lock.h with 100% similarity]
src/display/display-misc.c
src/display/display-misc.h
src/display/display-plugin.c
src/display/lock-detector.c [moved from src/display/plugin-common/lock-detector.c with 98% similarity]
src/display/lock-detector.h [moved from src/display/plugin-common/lock-detector.h with 100% similarity]
src/power/power-off.c

index 0278ef0..9cfcc87 100644 (file)
@@ -927,118 +927,6 @@ void update_lcdoff_source(int source)
                _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
  */
index 19e752e..a35689d 100644 (file)
@@ -937,118 +937,6 @@ void update_lcdoff_source(int source)
                _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
  */
index a008cbf..5f55e81 100644 (file)
@@ -927,118 +927,6 @@ void update_lcdoff_source(int source)
                _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
  */
index f16c389..4976023 100644 (file)
@@ -1237,118 +1237,6 @@ void update_lcdoff_source(int source)
                _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
  */
index 95502e3..b0141cd 100644 (file)
@@ -138,7 +138,6 @@ int display_on_by_reason(const char *reason, int timeout);
 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);
index c0bb9f8..ec3cc91 100644 (file)
 
 #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;
@@ -120,4 +126,134 @@ void display_misc_register_battery_health_notifier(void)
 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(), &current_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, &current_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
index 0ddb640..3176350 100644 (file)
@@ -33,5 +33,6 @@ void display_misc_set_stay_touchscreen_off(bool on);
 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
index 11f6483..62af72d 100644 (file)
@@ -59,6 +59,7 @@ int display_plugin_update_pm_setting(int key_idx, int val)
        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)
similarity index 98%
rename from src/display/plugin-common/lock-detector.c
rename to src/display/lock-detector.c
index 0b6ae12..593d4f6 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "util.h"
 #include "core.h"
+#include "display-misc.h"
 #include "shared/device-notifier.h"
 
 struct lock_info {
@@ -338,7 +339,7 @@ int pm_save_logdump(void)
        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;
 }
@@ -352,7 +353,7 @@ static int pmlock_detector_poweroff_cb(void *data)
        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;
 }
index a42261f..1d4bdec 100644 (file)
@@ -257,7 +257,7 @@ static gboolean __poweroff_main(gpointer data)
           - 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()