power: fix dbus signal for changestate 31/267731/1 accepted/tizen/unified/20211213.133447 submit/tizen/20211210.062426
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 9 Dec 2021 08:21:47 +0000 (17:21 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Thu, 9 Dec 2021 08:30:28 +0000 (17:30 +0900)
The dbus siganl is broadcasted on changing state
  path : /Org/Tizen/System/DeviceD/Power
  iface: org.tizen.system.deviced.Power
  name : ChangeState
  param: "(iti)"
         int32 : type (0: sleep, 1: wakeup)
 uint64: state transition id
 int32 : state transition reason

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

index 44f89ac..fa8c579 100644 (file)
@@ -17,6 +17,9 @@
 #define KEY_PRESSED_TEMPORAL_LOCK    "templock"
 #define TEMPORAL_LOCK_WAKE_MARGIN    1000 /* milisecond */
 
+#define EVENT_TYPE_SLEEP    0
+#define EVENT_TYPE_WAKEUP   1
+
 static guint keypress_temporal_timer_id;
 
 static const char *psm_name[PSM_MAX] = {
@@ -94,7 +97,7 @@ static void psm_transition_normal_to_sleep(const struct trans_info *ti)
 
        current = PSM_SLEEP;
        gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
-               "sleep", g_variant_new("(ti)", state_transition_counter, ti->reason));
+               "ChangeState", g_variant_new("(iti)", EVENT_TYPE_SLEEP, state_transition_counter, ti->reason));
        n_waiting = start_sleep_wait(state_transition_counter);
        if (n_waiting > 0) {
                /* There are sleep-waits. Defer wake unlock until all sleep-waits
@@ -113,7 +116,7 @@ static void psm_transition_sleep_to_normal(const struct trans_info *ti)
        stop_sleep_wait();
        device_notify(DEVICE_NOTIFIER_REQUEST_WAKE_LOCK, NULL);
        gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
-               "wakeup", g_variant_new("(ti)", state_transition_counter, ti->reason));
+               "ChangeState", g_variant_new("(iti)", EVENT_TYPE_WAKEUP, state_transition_counter, ti->reason));
 }
 
 static void psm_transition_sleep_to_sleep(const struct trans_info *ti)
@@ -122,7 +125,7 @@ static void psm_transition_sleep_to_sleep(const struct trans_info *ti)
 
        device_notify(DEVICE_NOTIFIER_REQUEST_WAKE_LOCK, NULL);
        gdbus_signal_emit(NULL, DEVICED_PATH_POWER, DEVICED_INTERFACE_POWER,
-               "sleep", g_variant_new("(ti)", state_transition_counter, ti->reason));
+               "ChangeState", g_variant_new("(iti)", EVENT_TYPE_SLEEP, state_transition_counter, ti->reason));
        n_waiting = start_sleep_wait(state_transition_counter);
        if (n_waiting > 0) {
                /* There are sleep-waits. Defer wake unlock until all sleep-waits