From 8873f5de286b40ccf6ead25bfcebe21e82a907ae Mon Sep 17 00:00:00 2001 From: Todd Poynor Date: Thu, 4 Oct 2012 16:11:53 -0700 Subject: [PATCH] power: android-battery: leave full/not-charging status when charger re-sensed If charger was connected and a charge source change event occurs such that the charger is still connected (or a different charge source connected), do not overwrite an existing state such as full or not-charging. Only switch from discharging to charging on a charge source change event. Change-Id: I1b841c8f3a92bf15074999e18b17d1d19ce028d7 Signed-off-by: Todd Poynor --- drivers/power/android_battery.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/power/android_battery.c b/drivers/power/android_battery.c index d6ff01adcd08..d7682d69e3ab 100644 --- a/drivers/power/android_battery.c +++ b/drivers/power/android_battery.c @@ -399,8 +399,18 @@ static void android_bat_charger_work(struct work_struct *work) break; case CHARGE_SOURCE_USB: case CHARGE_SOURCE_AC: - battery->charging_status = POWER_SUPPLY_STATUS_CHARGING; - android_bat_enable_charging(battery, true); + /* + * If charging status indicates a charger was already + * connected prior to this and a non-charging status is + * set, leave the status alone. + */ + if (battery->charging_status == + POWER_SUPPLY_STATUS_DISCHARGING || + battery->charging_status == POWER_SUPPLY_STATUS_UNKNOWN) { + battery->charging_status = POWER_SUPPLY_STATUS_CHARGING; + android_bat_enable_charging(battery, true); + } + break; default: pr_err("%s: Invalid charger type\n", __func__); -- 2.34.1