thermal: add legacy signal for thermal state 48/109848/1
authortaeyoung <ty317.kim@samsung.com>
Thu, 12 Jan 2017 04:19:17 +0000 (13:19 +0900)
committertaeyoung <ty317.kim@samsung.com>
Thu, 12 Jan 2017 04:19:17 +0000 (13:19 +0900)
Tizen 2.4 broadcasted a dbus signal for other apps
to know the thermal state. Thus the signal needs
to be applied to Tizen 3.0.

The signal is just for legacy uses, and tizen 3.0
needs to add new signal for new thermal module.

Change-Id: Ib1b947aabb30c434930ff88f45d41b6601183707
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/thermal/thermal.c

index 5b197c8..ff20b26 100755 (executable)
@@ -192,6 +192,57 @@ static void thermal_add_noti(void)
                noti = add_notification("TempCooldownNotiOn");
 }
 
+static void broadcast_thermal_state_legacy(int state, int level)
+{
+       static int old = NOTHING;
+       int type;
+       char *param[1];
+
+       switch (state) {
+       case THERMAL_STATE_LOW:
+       case THERMAL_STATE_NORMAL:
+               type = NOTHING;
+               break;
+       case THERMAL_STATE_HIGH:
+               if (level == THERMAL_LEVEL_WARNING)
+                       type = WARNING;
+               else if (level == THERMAL_LEVEL_CRITICAL ||
+                                level == THERMAL_LEVEL_POWEROFF)
+                       type = CRITICAL;
+               else
+                       type = NOTHING;
+               break;
+       default:
+               _E("Invalid state(%d)", state);
+               return;
+       }
+
+       if (old == type)
+               return;
+
+       switch (type) {
+       case NOTHING:
+               param[0] = "CoolDownRelease";
+               break;
+       case WARNING:
+               param[0] = "WarningAction";
+               break;
+       case CRITICAL:
+               param[0] = "LimitAction";
+               break;
+       default:
+               _I("Invalid type (%d)", type);
+               return;
+       }
+
+       old = type;
+
+       broadcast_edbus_signal(DEVICED_PATH_SYSNOTI,
+                       DEVICED_INTERFACE_SYSNOTI,
+                       "CoolDownChanged",
+                       "s", param);
+}
+
 static Eina_Bool thermal_overheat_time_broadcast(void *data)
 {
        int ret;
@@ -290,6 +341,8 @@ static void thermal_action(struct thermal_info *info, void *data)
                }
        }
 
+       broadcast_thermal_state_legacy(info->state, info->level);
+
        if (update == UPDATE) {
                old_state = info->state;
                old_level = info->level;