diff options
-rwxr-xr-x | src/apps/apps.c | 30 | ||||
-rwxr-xr-x | src/apps/apps.h | 2 | ||||
-rwxr-xr-x | src/battery/lowbat-handler.c | 20 | ||||
-rwxr-xr-x | src/thermal/thermal.c | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/usb/usb-state.c | 2 |
5 files changed, 45 insertions, 11 deletions
diff --git a/src/apps/apps.c b/src/apps/apps.c index 4b7cec61..d23334e7 100755 --- a/src/apps/apps.c +++ b/src/apps/apps.c @@ -23,6 +23,7 @@ #include "core/edbus-handler.h" #define POPUP_METHOD "PopupLaunch" +#define BUFF_MAX 255 static const struct app_dbus_match { const char *type; @@ -92,15 +93,38 @@ int launch_message_post(char *type) return ret; } -int add_notification(char *type) +int add_notification(char *type, char *sig, ...) { + int ret; + int count; + int len; + char *data = NULL; + char *param[BUFF_MAX] = {NULL}; + va_list args; + if (!type) return -EINVAL; - return dbus_method_sync(POPUP_BUS_NAME, + if (sig) { + len = strlen(sig); + va_start(args, sig); + + for (count = 0; count < len; count++) { + data = va_arg(args, char *); + param[count] = data; + } + + va_end(args); + } + + ret = dbus_method_sync(POPUP_BUS_NAME, POPUP_PATH_NOTI, POPUP_INTERFACE_NOTI, - type, NULL, NULL); + type, + sig, + param); + + return ret; } int remove_notification(char *type, int id) diff --git a/src/apps/apps.h b/src/apps/apps.h index cfcea7ad..b0c7a58c 100755 --- a/src/apps/apps.h +++ b/src/apps/apps.h @@ -31,7 +31,7 @@ int launch_system_app(char *type, int num, ...); int launch_message_post(char *type); -int add_notification(char *type); +int add_notification(char *type, char *sig, ...); int remove_notification(char *type, int id); #endif /* __APPS_H__ */ diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 782daeae..097c20c2 100755 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -244,9 +244,10 @@ void power_off_timer_stop(void) power_off_timer = NULL; } -static void get_lowbat_noti_value(int low_battery_type, char **actvie_noti, char **event_noti) +static int get_lowbat_noti_value(int low_battery_type, char **actvie_noti, char **event_noti) { int len; + int ret = 1; len = strlen(battery.power_source_s); if (!strncmp(battery.power_source_s, POWER_SOURCE_NONE, len)) { @@ -257,6 +258,7 @@ static void get_lowbat_noti_value(int low_battery_type, char **actvie_noti, char *actvie_noti = "BatteryCriticalActNotiOn"; *event_noti = "BatteryCriticalNotiOn"; } + ret = 0; } else if (!strncmp(battery.power_source_s, POWER_SOURCE_AC, len) || !strncmp(battery.power_source_s, POWER_SOURCE_WIRELESS, len)) { if (low_battery_type == LOW_BATTERY) { @@ -280,6 +282,7 @@ static void get_lowbat_noti_value(int low_battery_type, char **actvie_noti, char *event_noti = NULL; } _I("actvie_noti=%s event_noti=%s", actvie_noti, event_noti); + return ret; } static int lowbat_popup(char *option) @@ -287,9 +290,11 @@ static int lowbat_popup(char *option) static int launched_poweroff; static int lowbat_popup_option; int ret; + int power_source = 1; int r_disturb, s_disturb, r_block, s_block; static char *value; char *active_noti = NULL, *event_noti = NULL; + char temp[10] = {NULL}; if (!option) { if (!value) @@ -302,10 +307,10 @@ static int lowbat_popup(char *option) launched_poweroff = 0; if (!strcmp(option, WARNING_LOW_BAT_ACT)) { - get_lowbat_noti_value(LOW_BATTERY, &active_noti, &event_noti); + power_source = get_lowbat_noti_value(LOW_BATTERY, &active_noti, &event_noti); lowbat_popup_option = LOWBAT_OPT_CHECK; } else if (!strcmp(option, CRITICAL_LOW_BAT_ACT)) { - get_lowbat_noti_value(CRITICAL_BATTERY, &active_noti, &event_noti); + power_source = get_lowbat_noti_value(CRITICAL_BATTERY, &active_noti, &event_noti); lowbat_popup_option = LOWBAT_OPT_WARNING; } else if (!strcmp(option, POWER_OFF_BAT_ACT)) { value = "poweroff"; @@ -359,7 +364,12 @@ direct_launch: _E("Failed to launch remove_active_noti : %d", ret); } - ret = add_notification(active_noti); + if (!power_source) { + snprintf(temp, sizeof(temp), "%d", cur_bat_capacity); + ret = add_notification(active_noti, "s", temp); + } else + ret = add_notification(active_noti, NULL, NULL); + if (ret < 0) _E("Failed to launch active_noti : %d", ret); else @@ -373,7 +383,7 @@ direct_launch: _E("Failed to launch remove_event_noti : %d", ret); } - ret = add_notification(event_noti); + ret = add_notification(event_noti, NULL, NULL); if (ret < 0) _E("Failed to launch event noti : %d", ret); else diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index ff20b265..a87c4cdb 100755 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -189,7 +189,7 @@ static void thermal_remove_popup(void) static void thermal_add_noti(void) { if (!noti) - noti = add_notification("TempCooldownNotiOn"); + noti = add_notification("TempCooldownNotiOn", NULL, NULL); } static void broadcast_thermal_state_legacy(int state, int level) diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index fc8d1900..f0150479 100644..100755 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -190,7 +190,7 @@ void usb_state_update_state(usb_connection_state_e state, unsigned int mode) } } else if (mode & USB_FUNCTION_MTP) { if (noti_id < 0) - noti_id = add_notification("MediaDeviceNotiOn"); + noti_id = add_notification("MediaDeviceNotiOn", NULL, NULL); if (noti_id < 0) _E("Failed to show notification for usb connection"); } |