power: emit signal on wakeup 42/266842/1
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 19 Nov 2021 08:46:56 +0000 (17:46 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 19 Nov 2021 08:48:07 +0000 (17:48 +0900)
path       : /Org/Tizen/System/DeviceD/Power
interface  : org.tizen.system.deviced.Power
signame    : wakeup
parameter  : "(ii)"
             uint64: current time in milisecond
     uitn64: wakeup reason (refer device API)

Change-Id: I8078b056b8f22e86c545ceb291959fbe62bc6869
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/iot-headless/power/power-control.c

index 0a72e95..157e406 100644 (file)
@@ -25,6 +25,7 @@
 #include <libsyscommon/libgdbus.h>
 #include <libsyscommon/list.h>
 #include <libsyscommon/file.h>
+#include <device/power-internal.h>
 
 #include "shared/devices.h"
 #include "shared/log.h"
@@ -379,12 +380,13 @@ static int powerkey_short_pressed_cb(void *data)
        if (keycode != KEY_POWER)
                return 0;
 
+       retval = clock_gettime(CLOCK_REALTIME, &ts);
+       if (retval == 0)
+               current_time_ms = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
+
        sleep_enabled ^= 1; /* toggle status */
        if (sleep_enabled) {
                ++sleep_id;
-               retval = clock_gettime(CLOCK_REALTIME, &ts);
-               if (retval == 0)
-                       current_time_ms = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
 
                gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
                        "sleep", g_variant_new("(tt)", current_time_ms, sleep_id));
@@ -392,6 +394,8 @@ static int powerkey_short_pressed_cb(void *data)
        } else {
                device_notify(DEVICE_NOTIFIER_REQUEST_DISABLE_AUTOSLEEP, NULL);
                stop_sleep_wait();
+               gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
+                       "wakeup", g_variant_new("(tt)", current_time_ms, DEVICE_SIG_WAKEUP_SHORTKEY));
        }
 
        return 0;