From 3f9e37d4c1d9a6f5c2c8f11580f1fa0364f88373 Mon Sep 17 00:00:00 2001 From: taeyoung Date: Wed, 23 Nov 2016 18:17:19 +0900 Subject: [PATCH] thermal: launch overhead popup and noti According to the thermal status, overheat popup and notification are launched. Change-Id: I2513fdd931460cb1a15b7f8338dd9b0f56f66d16 Signed-off-by: taeyoung --- src/apps/apps.c | 1 + src/apps/apps.h | 1 + src/shared/dbus.h | 3 +++ src/thermal/thermal.c | 38 ++++++++++++++++++++++++++++++++++---- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/apps/apps.c b/src/apps/apps.c index be8f3e8..4b7cec6 100755 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -33,6 +33,7 @@ static const struct app_dbus_match { } app_match[] = { { APP_DEFAULT , POPUP_BUS_NAME, POPUP_PATH_SYSTEM , POPUP_INTERFACE_SYSTEM , POPUP_METHOD }, { APP_POWERKEY, POPUP_BUS_NAME, POPUP_PATH_POWERKEY, POPUP_INTERFACE_POWERKEY, POPUP_METHOD }, + { APP_OVERHEAT, POPUP_BUS_NAME, POPUP_PATH_OVERHEAT, POPUP_INTERFACE_OVERHEAT, POPUP_METHOD }, }; int launch_system_app(char *type, int num, ...) diff --git a/src/apps/apps.h b/src/apps/apps.h index 37d4ff3..cfcea7a 100755 --- a/src/apps/apps.h +++ b/src/apps/apps.h @@ -25,6 +25,7 @@ #include "display/poll.h" #define APP_POWERKEY "powerkey" +#define APP_OVERHEAT "overheat" #define APP_DEFAULT "system" #define APP_KEY_TYPE "_SYSPOPUP_CONTENT_" diff --git a/src/shared/dbus.h b/src/shared/dbus.h index a9816d5..eed12cb 100644 --- a/src/shared/dbus.h +++ b/src/shared/dbus.h @@ -198,6 +198,9 @@ /* System */ #define POPUP_PATH_SYSTEM POPUP_OBJECT_PATH"/System" #define POPUP_INTERFACE_SYSTEM POPUP_INTERFACE_NAME".System" +/* Overheat */ +#define POPUP_PATH_OVERHEAT POPUP_OBJECT_PATH"/Overheat" +#define POPUP_INTERFACE_OVERHEAT POPUP_INTERFACE_NAME".Overheat" /* Crash */ #define POPUP_PATH_CRASH POPUP_OBJECT_PATH"/Crash" #define POPUP_INTERFACE_CRASH POPUP_INTERFACE_NAME".Crash" diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index 2ebc546..603eda4 100644 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -22,12 +22,35 @@ #include #include +#include "apps/apps.h" #include "core/devices.h" #include "core/log.h" #include "core/device-notifier.h" static struct thermal_device *thermal_dev; +static int noti; + +static void thermal_remove_noti(void) +{ + if (noti) { + remove_notification("TempCooldownNotiOff", noti); + noti = 0; + } +} + +static void thermal_add_noti(void) +{ + if (!noti) + noti = add_notification("TempCooldownNotiOn"); +} + +static void thermal_add_popup(void) +{ + launch_system_app(APP_OVERHEAT, 2, + APP_KEY_TYPE, "overheat"); +} + static void thermal_action(struct thermal_info *info, void *data) { if (!info) @@ -36,18 +59,25 @@ static void thermal_action(struct thermal_info *info, void *data) switch (info->state) { case THERMAL_STATE_LOW: _E("THERMAL: temparature LOW"); + thermal_remove_noti(); break; case THERMAL_STATE_NORMAL: _I("THERMAL: temparature normal"); + thermal_remove_noti(); break; case THERMAL_STATE_HIGH: - if (info->level == THERMAL_LEVEL_WARNING) + if (info->level == THERMAL_LEVEL_WARNING) { _E("THERMAL: temparature HIGH (warning)"); - else if (info->level == THERMAL_LEVEL_CRITICAL) + thermal_add_noti(); + } else if (info->level == THERMAL_LEVEL_CRITICAL) { _E("THERMAL: temparature HIGH (critical)"); - else if (info->level == THERMAL_LEVEL_POWEROFF) + thermal_remove_noti(); + thermal_add_popup(); + } else if (info->level == THERMAL_LEVEL_POWEROFF) { _E("THERMAL: temparature HIGH (poweroff)"); - else + thermal_remove_noti(); + thermal_add_popup(); + } else _E("THERMAL: temparature HIGH"); break; default: -- 2.7.4