Add function to get wakeup reason by calling hal api function
and save wakup reason.
Add dbus method to delliver saved wakeup reason to device API.
"wakeup reason" is the power transition state reason of sleep to normal.
There are several reasons why the device wakeup and
sometimes it Is needed to get the reason.
added dbus method:
dbus_power_get_wakeup_reason
path: "/Org/Tizen/System/DeviceD/Power"
interace: "org.tizen.system.deviced.Power"
member: "PowerGetWakeupReason"
paremeter: "(i)", enum transition reason to get.
return: "(i)", 0 on success, negative on error.
Change-Id: I2f96fecb3bc1308afc712421e3b2f6c8a7efefea
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
(cherry picked from commit
5f262d9d915ec4b49e6a78a0bec04bfb30f3fdfd)
return g_variant_new("(t)", mapping_device_state[index]);
}
+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());
+}
+
static const dbus_method_s dbus_methods[] = {
{ "LockCpu", "i", "i", dbus_power_lock_cpu },
{ "UnlockCpu", NULL, "i", dbus_power_unlock_cpu },
{ "ConfirmChangeStateWait", "t", "i", dbus_power_confirm_change_state_wait },
{ "PowerChangeState", "t", "i", dbus_power_change_state },
{ "PowerGetState", NULL, "t", dbus_power_get_state },
+ { "PowerGetWakeupReason", NULL, "i", dbus_power_get_wakeup_reason },
/* Add methods here */
};
* limitations under the License.
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
static int vital_service;
static bool vital_sleep;
static int vital_support = -2;
+static enum hal_device_power_transition_reason wakeup_reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN;
#ifdef ENABLE_PM_LOG
return vital_support;
}
+static int update_wakeup_reason(void)
+{
+ return hal_device_power_get_wakeup_reason(&wakeup_reason);
+}
+
int suspend_other_process(int type)
{
int ret = 0;
_I("system suspend");
ret_val = sys_set_str(POWER_STATE_PATH, "mem");
_I("System resume: %d", ret_val);
+
+ ret_val = update_wakeup_reason();
+ if (ret_val < 0) {
+ _E("Failed to update wakeup reason");
+ wakeup_reason = HAL_DEVICE_POWER_TRANSITION_REASON_UNKNOWN;
+ return ret_val;
+ }
+
return 0;
}
return sys_set_str(POWER_UNLOCK_PATH, "mainlock");
}
+enum hal_device_power_transition_reason power_get_wakeup_reason(void)
+{
+ return wakeup_reason;
+}
+
int check_wakeup_src(void)
{
/* TODO if nedded.
#define __DEVICED_POWER_SUSPEND_H__
#include "display/core.h"
+#include <hal/device/hal-device-power.h>
#define POWER_AUTOSLEEP_PATH "/sys/power/autosleep"
#define POWER_LOCK_PATH "/sys/power/wake_lock"
int power_release_wakelock(void);
int pm_get_power_lock(void);
int pm_get_power_lock_support(void);
+enum hal_device_power_transition_reason power_get_wakeup_reason(void);
int check_wakeup_src(void);
int get_wakeup_count(int *cnt);
int set_wakeup_count(int cnt);