power: get wakeup_reason by calling hal-api 91/288191/2
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 13 Feb 2023 08:46:11 +0000 (17:46 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 13 Feb 2023 09:05:23 +0000 (18:05 +0900)
As the previous patch,
 - power: update wakeup reason immediately after wakeup
has changed not to maintain wakeup reason after resume, it is necessary
to access it via hal-api for every request for wakeup reason.

Change-Id: Ibf2aebb5b542dd1d55f799be0fbaddf65a6a8e7c
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/power/power-dbus.c

index 6ffd260..7f68edf 100644 (file)
@@ -495,7 +495,14 @@ static GVariant *dbus_power_get_wakeup_reason(GDBusConnection *conn,
        const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
        GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
 {
-       return g_variant_new("(i)", power_get_wakeup_reason());
+       enum hal_device_power_transition_reason wakeup_reason;
+       int retval;
+
+       retval = hal_device_power_get_wakeup_reason(&wakeup_reason);
+       if (retval < 0)
+               wakeup_reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN;
+
+       return g_variant_new("(i)", wakeup_reason);
 }
 
 static const dbus_method_s dbus_methods[] = {