thermal : add overheat 30 seconds timer for power off 48/105748/5 accepted/tizen/3.0/ivi/20161221.011227 accepted/tizen/3.0/mobile/20161221.011702 accepted/tizen/3.0/tv/20161221.010840 accepted/tizen/3.0/wearable/20161221.011312 submit/tizen_3.0/20161220.112821
authorlokilee73 <changjoo.lee@samsung.com>
Mon, 19 Dec 2016 10:40:11 +0000 (19:40 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Tue, 20 Dec 2016 10:16:57 +0000 (19:16 +0900)
Change-Id: Ia37636946104b3922a0abe7dda190fae1cac71f0
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/shared/dbus.h [changed mode: 0644->0755]
src/thermal/thermal.c

old mode 100644 (file)
new mode 100755 (executable)
index eed12cb..74c44a0
 #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 */
index b69729e..5b197c8 100755 (executable)
 #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)