#include "core/devices.h"
#include "core/log.h"
#include "core/device-notifier.h"
+#include "core/devices.h"
static struct thermal_device *thermal_dev;
-
static int noti;
#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+#define SIGNAL_OVERHEAT_TIME "TimeUpdate"
+#define OVERHEAT_CALLBACK_TIME 1 //seconds
+#define OVERHEAT_POWEROFF_TIME 30
enum thermal_trend_type {
NO_CHANGE,
{ THERMAL_LEVEL_POWEROFF, THERMAL_LEVEL_POWEROFF, NOTHING, UPDATE}
};
+static int power_off(void)
+{
+ const struct device_ops *power;
+
+ power = find_device("power");
+ if (check_default(power))
+ return -ENODEV;
+
+ return power->execute("poweroff");
+}
+
static int thermal_state_check(int old_state, int new_state)
{
int i, ret = -1;
noti = add_notification("TempCooldownNotiOn");
}
+static Eina_Bool thermal_overheat_time_broadcast(void *data)
+{
+ int ret;
+ char *arr[1];
+ char buff[32];
+ static int time = OVERHEAT_POWEROFF_TIME;
+
+ snprintf(buff, sizeof(buff), "%d", time);
+ arr[0] = buff;
+
+ /* Transfer Time by Signal */
+ ret = broadcast_edbus_signal(POPUP_OVERHEAT_PATH, POPUP_OVERHEAT_INTERFACE,
+ SIGNAL_OVERHEAT_TIME, "i", arr);
+ if (ret < 0)
+ _E("Fail in updating overheat time");
+
+ time -= 1;
+ if (time < 0) {
+ time = OVERHEAT_POWEROFF_TIME;
+ ret = power_off();
+ if (ret < 0)
+ _E("Fail to power off");
+ return ECORE_CALLBACK_CANCEL;
+ } else
+ return ECORE_CALLBACK_RENEW;
+}
+
static void thermal_add_popup(void)
{
- launch_system_app(APP_OVERHEAT, 2,
+ int ret;
+ Ecore_Timer *timer;
+
+ ret = launch_system_app(APP_OVERHEAT, 2,
APP_KEY_TYPE, "overheat");
+
+ if (ret < 0)
+ _E("error to launch Overheat popup");
+ else {
+ timer = ecore_timer_add(OVERHEAT_CALLBACK_TIME, (Ecore_Task_Cb)thermal_overheat_time_broadcast, NULL);
+ if (!timer)
+ _E("Fail to set over temp timer");
+ }
}
static void thermal_add_recovery_popup(void)
{
- launch_system_app(APP_DEFAULT, 2,
+ int ret;
+
+ ret = launch_system_app(APP_DEFAULT, 2,
APP_KEY_TYPE, "cooled_down");
+ if (ret < 0)
+ _E("Fail to launch recovery popup");
}
static void thermal_action(struct thermal_info *info, void *data)