diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2016-12-19 19:40:11 +0900 |
---|---|---|
committer | lokilee73 <changjoo.lee@samsung.com> | 2016-12-20 19:16:57 +0900 |
commit | 6a3259a732fc880b26ea3cdf20ade51644dbd314 (patch) | |
tree | fee107dc418b8eb5eea13129dc678c157d8fe11d | |
parent | 4f7aa807df17982c5151cfa8cd9dbb7000a2c641 (diff) | |
download | deviced-6a3259a732fc880b26ea3cdf20ade51644dbd314.tar.gz deviced-6a3259a732fc880b26ea3cdf20ade51644dbd314.tar.bz2 deviced-6a3259a732fc880b26ea3cdf20ade51644dbd314.zip |
thermal : add overheat 30 seconds timer for power offsubmit/tizen_3.0/20161220.112821accepted/tizen/3.0/wearable/20161221.011312accepted/tizen/3.0/tv/20161221.010840accepted/tizen/3.0/mobile/20161221.011702accepted/tizen/3.0/ivi/20161221.011227
Change-Id: Ia37636946104b3922a0abe7dda190fae1cac71f0
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rwxr-xr-x[-rw-r--r--] | src/shared/dbus.h | 3 | ||||
-rwxr-xr-x | src/thermal/thermal.c | 62 |
2 files changed, 62 insertions, 3 deletions
diff --git a/src/shared/dbus.h b/src/shared/dbus.h index eed12cbd..74c44a0a 100644..100755 --- a/src/shared/dbus.h +++ b/src/shared/dbus.h @@ -273,6 +273,9 @@ #define POPUP_PATH_BATTERY POPUP_OBJECT_PATH"/Battery" #define POPUP_INTERFACE_BATTERY POPUP_INTERFACE_NAME".Battery" #define POPUP_METHOD_SCREENOFF_TTS "ScreenOffTts" +/* Overheat Timer*/ +#define POPUP_OVERHEAT_PATH POPUP_OBJECT_PATH"/Overheat" +#define POPUP_OVERHEAT_INTERFACE POPUP_INTERFACE_NAME".Overheat" /***********************************************/ /* End of the Experimental for Specific device */ diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index b69729e4..5b197c8a 100755 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -26,12 +26,15 @@ #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, @@ -101,6 +104,17 @@ static struct thermal_level highhigh_temp_level[] = { { 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; @@ -178,16 +192,58 @@ static void thermal_add_noti(void) 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) |