summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungjae Cho <y0.cho@samsung.com>2020-03-31 16:48:22 +0900
committerHyotaek Shim <hyotaek.shim@samsung.com>2020-03-31 08:10:31 +0000
commite297cd2642247ab2d11cdeeedb4ee153f3e9cb48 (patch)
treeec29d3b320ab8a5da372b33d5a06d84662c05468
parent6b0553796377417ea333f246742dc302e024cc6e (diff)
downloaddeviced-e297cd2642247ab2d11cdeeedb4ee153f3e9cb48.tar.gz
deviced-e297cd2642247ab2d11cdeeedb4ee153f3e9cb48.tar.bz2
deviced-e297cd2642247ab2d11cdeeedb4ee153f3e9cb48.zip
If the battery continues to run out even though it is being charged for a certain period of time, turn off the device. Change-Id: Ieebd03bf43202201d3f1e619f553ec77d3928332 Signed-off-by: Youngjae Cho <y0.cho@samsung.com> (cherry picked from commit 3846f4b14dd1dff648c67b4c1a51c7bfa609f7e1)
-rw-r--r--src/battery/lowbat-handler.c22
-rw-r--r--src/battery/power-supply.c3
2 files changed, 23 insertions, 2 deletions
diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c
index ff72f51f..905717f1 100644
--- a/src/battery/lowbat-handler.c
+++ b/src/battery/lowbat-handler.c
@@ -58,7 +58,8 @@
#define METHOD_CRITICAL_NOTI_ON "BatteryCriticalNotiOn"
#define METHOD_CRITICAL_NOTI_UPDATE "BatteryCriticalNotiUpdate"
#define METHOD_CRITICAL_NOTI_OFF "BatteryCriticalNotiOff"
-#define RETRY_MAX 5
+#define RETRY_MAX 5
+#define MIN_INOW_VALUE -50
enum custom_level_control_type {
CUSTOM_CONTROL_NONE,
@@ -698,6 +699,7 @@ static int lowbat_process(int bat_percent, void *ad)
{
static int online;
static bool low_bat_old;
+ static int low_bat_skip_cnt = 0;
int new_bat_capacity;
int new_bat_state;
int vconf_state = -1;
@@ -761,6 +763,24 @@ static int lowbat_process(int bat_percent, void *ad)
}
}
+ /* If the battery continues to run out even though it is being charged
+ * for a certain period of time, turn off the device. */
+ if (new_bat_capacity <= battery_info.realoff && battery.charge_now == CHARGER_CHARGING) {
+ if (low_bat_skip_cnt >= RETRY_MAX) {
+ new_bat_state = battery_info.realoff;
+ status = VCONFKEY_SYSMAN_BAT_REAL_POWER_OFF;
+ _I("Go to real poweroff inspite of charging (c:%d charge:%d online:%d charger_charging %d current now %d)",
+ battery.capacity, battery.charge_now, battery.online, battery.charger_charging, battery.current_now);
+ low_bat_skip_cnt = 0;
+ } else if (battery.current_now <= MIN_INOW_VALUE) {
+ low_bat_skip_cnt++;
+ } else {
+ low_bat_skip_cnt = 0;
+ }
+ } else {
+ low_bat_skip_cnt = 0;
+ }
+
if (status != -1) {
result = status;
if (disp_plgn.update_pm_setting)
diff --git a/src/battery/power-supply.c b/src/battery/power-supply.c
index 4227a763..19324e10 100644
--- a/src/battery/power-supply.c
+++ b/src/battery/power-supply.c
@@ -795,7 +795,8 @@ static void process_power_supply(void *data)
if (power_supply_broadcast(CHARGE_CAPACITY_SIGNAL, battery.capacity) < 0)
broadcasted = false;
}
- battery.charging_level = lowbat_execute(data);
+
+ (void)lowbat_execute(data);
if (update_online()) {
ret = vconf_set_int(VCONFKEY_SYSMAN_CHARGER_STATUS, online_status);