From 91e358d91a7bf9f20d689ced4a78035c1c85c666 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 2 Jul 2020 17:39:57 +0900 Subject: [PATCH] Add low and critical battery popup Change-Id: I650a5f365d24635ff7770838f2fd2342a37f1ccc Signed-off-by: lokilee73 --- src/battery/battery-mobile.c | 36 ++++++++++++++++++++++++++++++++++-- src/battery/battery-wearable.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/battery/battery-mobile.c b/src/battery/battery-mobile.c index 625bebc..6a102a0 100644 --- a/src/battery/battery-mobile.c +++ b/src/battery/battery-mobile.c @@ -19,6 +19,8 @@ #include "popup-common.h" static const struct popup_ops lowbattery_poweroff_ops; +static const struct popup_ops lowbattery_critical_ops; +static const struct popup_ops lowbattery_warning_ops; static const struct popup_ops charge_error_low_ops; static const struct popup_ops charge_error_high_ops; static const struct popup_ops battery_disconnected_ops; @@ -32,6 +34,12 @@ static void remove_other_lowbattery_popups(const struct popup_ops *ops) _D("remove_other_lowbattery_popups() is finished."); if (ops != &lowbattery_poweroff_ops) unload_simple_popup(&lowbattery_poweroff_ops); + + if (ops != &lowbattery_critical_ops) + unload_simple_popup(&lowbattery_critical_ops); + + if (ops != &lowbattery_warning_ops) + unload_simple_popup(&lowbattery_warning_ops); } static int remove_other_charge_popups(bundle *b, const struct popup_ops *ops) @@ -98,7 +106,6 @@ static void unregister_battery_status_handler(void) battery_status_changed); } - static void register_charger_status_handler(const struct popup_ops *ops) { if (vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, @@ -150,7 +157,6 @@ static void poweroff_clicked(const struct popup_ops *ops) "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); - } static void charge_error_ok_clicked(const struct popup_ops *ops) @@ -171,6 +177,8 @@ static int remove_battery_popups(bundle *b, const struct popup_ops *ops) { _I("Remove battery related popups."); unload_simple_popup(&lowbattery_poweroff_ops); + unload_simple_popup(&lowbattery_critical_ops); + unload_simple_popup(&lowbattery_warning_ops); unload_simple_popup(&charge_error_low_ops); unload_simple_popup(&charge_error_high_ops); unload_simple_popup(&battery_disconnected_ops); @@ -191,6 +199,28 @@ static const struct popup_ops lowbattery_poweroff_ops = { .terminate = lowbattery_terminate, }; +static const struct popup_ops lowbattery_critical_ops = { + .name = "lowbattery_critical", + .pattern = FEEDBACK_PATTERN_LOWBATT, + .title = "IDS_COM_HEADER_BATTERY_CRITICALLY_LOW", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops lowbattery_warning_ops = { + .name = "lowbattery_warning", + .pattern = FEEDBACK_PATTERN_LOWBATT, + .title = "IDS_COM_HEADER_BATTERY_LOW_ABB", + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + static const struct popup_ops battery_remove_ops = { .name = "remove_battery_popups", .show = remove_battery_popups, @@ -231,6 +261,8 @@ static const struct popup_ops battery_disconnected_ops = { static __attribute__ ((constructor)) void battery_register_popup(void) { register_popup(&lowbattery_poweroff_ops); + register_popup(&lowbattery_critical_ops); + register_popup(&lowbattery_warning_ops); register_popup(&battery_remove_ops); register_popup(&charge_error_low_ops); register_popup(&charge_error_high_ops); diff --git a/src/battery/battery-wearable.c b/src/battery/battery-wearable.c index fc0f209..8ac5591 100644 --- a/src/battery/battery-wearable.c +++ b/src/battery/battery-wearable.c @@ -22,6 +22,8 @@ #define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" static const struct popup_ops lowbattery_poweroff_ops; +static const struct popup_ops lowbattery_critical_ops; +static const struct popup_ops lowbattery_warning_ops; static const struct popup_ops charge_error_low_ops; static const struct popup_ops charge_error_high_ops; static const struct popup_ops battery_disconnected_ops; @@ -33,6 +35,12 @@ static int remove_other_lowbattery_popups(const struct popup_ops *ops) if (ops != &lowbattery_poweroff_ops) unload_simple_popup(&lowbattery_poweroff_ops); + if (ops != &lowbattery_critical_ops) + unload_simple_popup(&lowbattery_critical_ops); + + if (ops != &lowbattery_warning_ops) + unload_simple_popup(&lowbattery_warning_ops); + return 0; } @@ -169,6 +177,8 @@ static int remove_battery_popups(bundle *b, const struct popup_ops *ops) { _I("Remove battery related popups."); unload_simple_popup(&lowbattery_poweroff_ops); + unload_simple_popup(&lowbattery_critical_ops); + unload_simple_popup(&lowbattery_warning_ops); unload_simple_popup(&charge_error_low_ops); unload_simple_popup(&charge_error_high_ops); unload_simple_popup(&battery_disconnected_ops); @@ -187,6 +197,26 @@ static const struct popup_ops lowbattery_poweroff_ops = { .terminate = lowbattery_terminate, }; +static const struct popup_ops lowbattery_critical_ops = { + .name = "lowbattery_critical", + .pattern = FEEDBACK_PATTERN_LOWBATT, + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + +static const struct popup_ops lowbattery_warning_ops = { + .name = "lowbattery_warning", + .pattern = FEEDBACK_PATTERN_LOWBATT, + .show = load_simple_popup, + .content = "IDS_COM_POP_BATTERYLOW", + .left_text = "IDS_COM_SK_OK", + .pre = lowbattery_launch, + .terminate = lowbattery_terminate, +}; + static const struct popup_ops battery_remove_ops = { .name = "remove_battery_popups", .show = remove_battery_popups, @@ -224,6 +254,8 @@ static const struct popup_ops battery_disconnected_ops = { static __attribute__ ((constructor)) void battery_register_popup(void) { register_popup(&lowbattery_poweroff_ops); + register_popup(&lowbattery_critical_ops); + register_popup(&lowbattery_warning_ops); register_popup(&battery_remove_ops); register_popup(&charge_error_low_ops); register_popup(&charge_error_high_ops); -- 2.7.4