mirror of https://github.com/BOINC/boinc.git
- client (Android): suspend processing if battery temperature > 45 C.
We can adjust this or make it configurable later.
This commit is contained in:
parent
58395eda60
commit
21f580d9ef
|
@ -268,6 +268,16 @@ int CLIENT_STATE::check_suspend_processing() {
|
|||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
// check for hot battery
|
||||
//
|
||||
host_info.get_battery_status();
|
||||
if (host_info.battery_state == BATTERY_STATE_OVERHEATED) {
|
||||
return SUSPEND_REASON_BATTERY_OVERHEATED;
|
||||
}
|
||||
if (host_info.battery_temperature_celsius > 45) {
|
||||
return SUSPEND_REASON_BATTERY_OVERHEATED;
|
||||
}
|
||||
|
||||
// on some devices, running jobs can drain the battery even
|
||||
// while it's recharging.
|
||||
// So use the following hysteresis policy:
|
||||
|
@ -276,10 +286,6 @@ int CLIENT_STATE::check_suspend_processing() {
|
|||
// Repeat.
|
||||
//
|
||||
static bool hyst_state = true;
|
||||
host_info.get_battery_status();
|
||||
if (host_info.battery_state == BATTERY_STATE_OVERHEATED) {
|
||||
return SUSPEND_REASON_BATTERY_OVERHEATED;
|
||||
}
|
||||
int cp = host_info.battery_charge_pct;
|
||||
if (cp >= 0) {
|
||||
if (cp < 90) {
|
||||
|
|
|
@ -446,7 +446,7 @@ bool HOST_INFO::host_is_running_on_batteries() {
|
|||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
// Get battery state and charge percentage
|
||||
// Get battery state, charge percentage, and temperature
|
||||
//
|
||||
void HOST_INFO::get_battery_status() {
|
||||
char msg[1024];
|
||||
|
@ -495,6 +495,17 @@ void HOST_INFO::get_battery_status() {
|
|||
LOGD("battery is charging");
|
||||
battery_state = BATTERY_STATE_CHARGING;
|
||||
}
|
||||
|
||||
battery_temperature_celsius = 0;
|
||||
f = fopen("/sys/class/power_supply/battery/batt_temp", "r");
|
||||
if (!f) {
|
||||
f = fopen("/sys/class/power_supply/battery/temp", "r");
|
||||
}
|
||||
if (f) {
|
||||
fscanf(f, "%d", &battery_temperature_celsius);
|
||||
battery_temperature_celsius /= 10;
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
#ifdef ANDROID
|
||||
int battery_charge_pct;
|
||||
int battery_state;
|
||||
int battery_temperature_celsius;
|
||||
void get_battery_status();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue