Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f230dcd4 authored by HongMin Son's avatar HongMin Son Committed by Ruchi Kandoi
Browse files

power: android-battery: Battery health check only when connected to charger



Only check battery health when connected to a charger.

Change-Id: I43e3f73ac1e5862f8e6dbaa19daa6d322f3bba20
Signed-off-by: default avatarHongMin Son <hongmin.son@samsung.com>
parent d575027f
Loading
Loading
Loading
Loading
+29 −18
Original line number Original line Diff line number Diff line
@@ -201,28 +201,39 @@ static void android_bat_get_temp(struct android_bat_data *battery)
	if (battery->pdata->get_temperature)
	if (battery->pdata->get_temperature)
		battery->pdata->get_temperature(&batt_temp);
		battery->pdata->get_temperature(&batt_temp);


	if (battery->charge_source != CHARGE_SOURCE_NONE) {
		if (batt_temp >= battery->pdata->temp_high_threshold) {
		if (batt_temp >= battery->pdata->temp_high_threshold) {
			if (health != POWER_SUPPLY_HEALTH_OVERHEAT &&
			if (health != POWER_SUPPLY_HEALTH_OVERHEAT &&
				health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE) {
				health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE) {
			pr_info("battery overheat (%d>=%d), charging unavailable\n",
				pr_info("battery overheat (%d>=%d), " \
				batt_temp, battery->pdata->temp_high_threshold);
					"charging unavailable\n",
			battery->batt_health = POWER_SUPPLY_HEALTH_OVERHEAT;
					batt_temp,
					battery->pdata->temp_high_threshold);
				battery->batt_health =
					POWER_SUPPLY_HEALTH_OVERHEAT;
			}
			}
		} else if (batt_temp <= battery->pdata->temp_high_recovery &&
		} else if (batt_temp <= battery->pdata->temp_high_recovery &&
			batt_temp >= battery->pdata->temp_low_recovery) {
			batt_temp >= battery->pdata->temp_low_recovery) {
			if (health == POWER_SUPPLY_HEALTH_OVERHEAT ||
			if (health == POWER_SUPPLY_HEALTH_OVERHEAT ||
				health == POWER_SUPPLY_HEALTH_COLD) {
				health == POWER_SUPPLY_HEALTH_COLD) {
			pr_info("battery recovery (%d,%d~%d), charging available\n",
				pr_info("battery recovery (%d,%d~%d),"	\
				batt_temp, battery->pdata->temp_low_recovery,
					"charging available\n",
					batt_temp,
					battery->pdata->temp_low_recovery,
					battery->pdata->temp_high_recovery);
					battery->pdata->temp_high_recovery);
			battery->batt_health = POWER_SUPPLY_HEALTH_GOOD;
				battery->batt_health =
					POWER_SUPPLY_HEALTH_GOOD;
			}
			}
		} else if (batt_temp <= battery->pdata->temp_low_threshold) {
		} else if (batt_temp <= battery->pdata->temp_low_threshold) {
			if (health != POWER_SUPPLY_HEALTH_COLD &&
			if (health != POWER_SUPPLY_HEALTH_COLD &&
				health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE) {
				health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE) {
			pr_info("battery cold (%d <= %d), charging unavailable\n",
				pr_info("battery cold (%d <= %d),"	\
				batt_temp, battery->pdata->temp_low_threshold);
					"charging unavailable\n",
			battery->batt_health = POWER_SUPPLY_HEALTH_COLD;
					batt_temp,
					battery->pdata->temp_low_threshold);
				battery->batt_health =
					POWER_SUPPLY_HEALTH_COLD;
			}
		}
		}
	}
	}