Skip to content

Commit c183a0e

Browse files
authored
Merge pull request #6714 from BOINC/dpa_android_battery3
client, Android: clarify message
2 parents 3497cca + 8e8909b commit c183a0e

File tree

5 files changed

+32
-65
lines changed

5 files changed

+32
-65
lines changed

client/client_state.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ CLIENT_STATE::CLIENT_STATE()
161161
total_disk_usage = 0.0;
162162
#ifdef ANDROID
163163
device_status_time = dtime();
164+
battery_charge_resume_time = 0;
165+
battery_heat_resume_time = 0;
164166
#endif
165167

166168
rec_interval_start = 0;

client/client_state.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ struct CLIENT_STATE {
106106
// info from GUI, e.g. battery status
107107
double device_status_time;
108108
// time of last RPC from GUI
109+
double battery_charge_resume_time;
110+
double battery_heat_resume_time;
109111
#endif
110112

111113
char language[16]; // ISO language code reported by GUI

client/cs_prefs.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,6 @@ int CLIENT_STATE::check_suspend_processing() {
283283
// If suspend because of hot battery, don't resume for at least 5 min
284284
// (crude hysteresis)
285285
//
286-
static double battery_heat_resume_time=0;
287-
if (now < battery_heat_resume_time) {
288-
return SUSPEND_REASON_BATTERY_OVERHEATED;
289-
}
290286
if (device_status.battery_state == BATTERY_STATE_OVERHEATED) {
291287
battery_heat_resume_time = now + ANDROID_BATTERY_BACKOFF;
292288
return SUSPEND_REASON_BATTERY_OVERHEATED;
@@ -295,20 +291,20 @@ int CLIENT_STATE::check_suspend_processing() {
295291
battery_heat_resume_time = now + ANDROID_BATTERY_BACKOFF;
296292
return SUSPEND_REASON_BATTERY_OVERHEATED;
297293
}
294+
if (now < battery_heat_resume_time) {
295+
return SUSPEND_REASON_BATTERY_HEAT_WAIT;
296+
}
298297

299298
// check for sufficient battery charge.
300299
// If suspend, don't resume for at least 5 min
301300
//
302-
static double battery_charge_resume_time=0;
303-
if (now < battery_charge_resume_time) {
301+
int cp = device_status.battery_charge_pct;
302+
if ((cp >= 0) && (cp < global_prefs.battery_charge_min_pct)) {
303+
battery_charge_resume_time = now + ANDROID_BATTERY_BACKOFF;
304304
return SUSPEND_REASON_BATTERY_CHARGING;
305305
}
306-
int cp = device_status.battery_charge_pct;
307-
if (cp >= 0) {
308-
if (cp < global_prefs.battery_charge_min_pct) {
309-
battery_charge_resume_time = now + ANDROID_BATTERY_BACKOFF;
310-
return SUSPEND_REASON_BATTERY_CHARGING;
311-
}
306+
if (now < battery_charge_resume_time) {
307+
return SUSPEND_REASON_BATTERY_CHARGE_WAIT;
312308
}
313309
}
314310
#endif
@@ -375,12 +371,28 @@ void CLIENT_STATE::show_suspend_tasks_message(int reason) {
375371
case SUSPEND_REASON_BATTERY_CHARGING:
376372
if (log_flags.task) {
377373
msg_printf(NULL, MSG_INFO,
378-
"(battery charge level %.1f%% < threshold %.1f%%",
374+
"(battery charge level %.1f%% < threshold %.1f%%)",
379375
device_status.battery_charge_pct,
380376
global_prefs.battery_charge_min_pct
381377
);
382378
}
383379
break;
380+
case SUSPEND_REASON_BATTERY_CHARGE_WAIT:
381+
if (log_flags.task) {
382+
msg_printf(NULL, MSG_INFO,
383+
"(battery charge wait: %.0f sec)",
384+
battery_charge_resume_time - now
385+
);
386+
}
387+
break;
388+
case SUSPEND_REASON_BATTERY_HEAT_WAIT:
389+
if (log_flags.task) {
390+
msg_printf(NULL, MSG_INFO,
391+
"(battery heat wait: %.0f sec)",
392+
battery_heat_resume_time - now
393+
);
394+
}
395+
break;
384396
}
385397
#endif
386398
}

lib/common_defs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ enum SUSPEND_REASON {
181181
SUSPEND_REASON_BATTERY_CHARGING = 4098,
182182
SUSPEND_REASON_BATTERY_OVERHEATED = 4099,
183183
SUSPEND_REASON_NO_GUI_KEEPALIVE = 4100,
184-
SUSPEND_REASON_PODMAN_INIT = 4101
184+
SUSPEND_REASON_PODMAN_INIT = 4101,
185+
SUSPEND_REASON_BATTERY_CHARGE_WAIT = 4102,
186+
SUSPEND_REASON_BATTERY_HEAT_WAIT = 4103
185187
};
186188

187189
// battery state (currently used only for Android)

testbase

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)