Add logic to block polling key when display logic is stop state. 26/14726/1
authorsh.pi <sh.pi@samsung.com>
Tue, 23 Apr 2013 06:59:23 +0000 (15:59 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Fri, 10 Jan 2014 09:38:05 +0000 (10:38 +0100)
key polling logic can work during disply logic is stopping.
then block polling logic when display logic is stop state.

Change-Id: I03938aedb7c78034796d9932a6f72f0b33cf705c
Signed-off-by: Krzysztof Sasiak <k.sasiak@samsung.com>
src/core/devices.h
src/display/core.c
src/display/poll.c
src/power/power-handler.c

index 4dd7307..fca9f5b 100644 (file)
@@ -27,6 +27,14 @@ struct device_ops {
        void (*exit) (void *data);
        int (*start) (void);
        int (*stop) (void);
+       int (*status) (void);
+};
+
+enum device_ops_status {
+       DEVICE_OPS_STATUS_UNINIT,
+       DEVICE_OPS_STATUS_START,
+       DEVICE_OPS_STATUS_STOP,
+       DEVICE_OPS_STATUS_MAX,
 };
 
 void devices_init(void *data);
@@ -48,6 +56,14 @@ static inline int device_stop(struct device_ops *dev)
        return -EINVAL;
 }
 
+static inline int device_get_status(struct device_ops *dev)
+{
+       if (dev && dev->status)
+               return dev->status();
+
+       return -EINVAL;
+}
+
 extern const struct device_ops edbus_device_ops;
 extern const struct device_ops display_device_ops;
 extern const struct device_ops sysnoti_device_ops;
index 9e0acf6..c586027 100644 (file)
@@ -76,6 +76,8 @@ static void (*power_saving_func) (int onoff);
 static void reset_timeout(int timeout);
 static int get_lcd_timeout_from_settings();
 
+static enum device_ops_status status = DEVICE_OPS_STATUS_UNINIT;
+
 int pm_cur_state;
 int pm_old_state;
 Ecore_Timer *timeout_src_id;
@@ -781,6 +783,11 @@ static int default_action(int timeout)
        int lock_state = -1;
        struct itimerval val;
 
+       if (status != DEVICE_OPS_STATUS_START) {
+               LOGERR("display is not started!");
+               return -EINVAL;
+       }
+
        if (pm_cur_state != pm_old_state && pm_cur_state != S_SLEEP) {
                set_setting_pmstate(pm_cur_state);
                device_notify(DEVICE_NOTIFIER_LCD, pm_cur_state);
@@ -1467,7 +1474,7 @@ static int noti_fd = -1;
  * Power manager Main
  *
  */
-static void start_pm_main(void *data)
+static void display_init(void *data)
 {
        int ret, i;
        unsigned int flags = (WITHOUT_STARTNOTI | FLAG_X_DPMS);
@@ -1529,12 +1536,14 @@ static void start_pm_main(void *data)
                }
                start_battinfo_gathering(30);
        }
+       status = DEVICE_OPS_STATUS_START;
 }
 
-static void end_pm_main(void *data)
+static void display_exit(void *data)
 {
        int i;
 
+       status = DEVICE_OPS_STATUS_STOP;
        end_battinfo_gathering();
 
        for (i = i - 1; i >= INIT_SETTING; i--) {
@@ -1558,9 +1567,15 @@ static void end_pm_main(void *data)
        LOGINFO("Stop power manager");
 }
 
+static int display_status(void)
+{
+       return status;
+}
+
 const struct device_ops display_device_ops = {
-       .init = start_pm_main,
-       .exit = end_pm_main,
+       .init = display_init,
+       .exit = display_exit,
+       .status = display_status,
 };
 
 /**
index 6fc3fed..542a431 100644 (file)
@@ -42,6 +42,7 @@
 #include "util.h"
 #include "core.h"
 #include "poll.h"
+#include "core/devices.h"
 
 #define SHIFT_UNLOCK                    4
 #define SHIFT_UNLOCK_PARAMETER          12
@@ -77,6 +78,11 @@ static Eina_Bool pm_handler(void *data, Ecore_Fd_Handler *fd_handler)
        int ret;
        int clilen = sizeof(clientaddr);
 
+       if (device_get_status(&display_device_ops) != DEVICE_OPS_STATUS_START) {
+               LOGERR("display is not started!");
+               return EINA_FALSE;
+       }
+
        if (g_pm_callback == NULL) {
                return EINA_FALSE;
        }
index a2dd942..f27dca5 100644 (file)
@@ -301,6 +301,7 @@ int internal_poweroff_def_predefine_action(int argc, char **argv)
 {
        int ret;
 
+       display_device_ops.exit(NULL);
        system("/usr/lib/system-server/shutdown.sh &");
        sync();
 
@@ -481,6 +482,7 @@ int restart_def_predefine_action(int argc, char **argv)
 
        heynoti_publish(POWEROFF_NOTI_NAME);
        pm_change_internal(getpid(), LCD_NORMAL);
+       display_device_ops.exit(NULL);
        system("/etc/rc.d/rc.shutdown &");
        sync();