power: add getter for power state 58/277658/3
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 12 Jul 2022 01:10:23 +0000 (10:10 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 12 Jul 2022 07:33:49 +0000 (07:33 +0000)
Change-Id: I792f01d67adeba213f84003fea4fc506f4f04ad9
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/power/power-dbus.c
src/power/power.c
src/power/power.h

index 61c7922..a0c6cfa 100644 (file)
@@ -327,6 +327,13 @@ out:
        return g_variant_new("(i)", ret);
 }
 
+static GVariant *dbus_power_get_state(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("(t)", power_get_state());
+}
+
 static const dbus_method_s dbus_methods[] = {
        { "LockCpu",                "i",   "i",  dbus_power_lock_cpu },
        { "UnlockCpu",              NULL,  "i",  dbus_power_unlock_cpu },
@@ -334,6 +341,7 @@ static const dbus_method_s dbus_methods[] = {
        { "RemoveChangeStateWait",  "t",   NULL, dbus_power_remove_change_state_wait },
        { "ConfirmChangeStateWait", "t",   "i",  dbus_power_confirm_change_state_wait },
        { "PowerChangeState",       "t",   "i",  dbus_power_change_state },
+       { "PowerGetState",          NULL,  "t",  dbus_power_get_state },
        /* Add methods here */
 };
 
index 43cd084..01ee2df 100644 (file)
@@ -47,6 +47,11 @@ static GList *deferred_transition_list;
 
 static int power_transition_state(void *data);
 
+uint64_t power_get_state(void)
+{
+       return current;
+}
+
 static void power_wake_unlock(void *udata)
 {
        /* for POWER_STATE_NORMAL, POWER_STATE_POWEROFF, do not wake unlock */
index 366b8a4..7ce29b2 100644 (file)
@@ -98,4 +98,6 @@ static inline void power_request_change_state(uint64_t next, int reason)
        power_request_change_state_strict(POWER_STATE_ALL, next, reason, NULL);
 }
 
+uint64_t power_get_state(void);
+
 #endif //__POWER_STATE_MANAGER_H__