client (Android): get "user active" from GUI; don't run if user active

On Android, get the "user active" state from the GUI
(as DEVICE_STATUS::user_active).
Never compute if user active (ignore preferences).
This commit is contained in:
David Anderson 2013-06-22 09:58:39 -07:00
parent 727f220766
commit 37eb54f12f
4 changed files with 15 additions and 2 deletions

View File

@ -774,12 +774,16 @@ bool CLIENT_STATE::poll_slow_events() {
#endif
bool old_user_active = user_active;
#ifdef ANDROID
user_active = device_status.user_active;
#else
user_active = !host_info.users_idle(
check_all_logins, global_prefs.idle_time_to_run
#ifdef __APPLE__
, &idletime
#endif
);
#endif
if (user_active != old_user_active) {
request_schedule_cpus("Idle state change");

View File

@ -641,6 +641,11 @@ void CLIENT_STATE::read_global_prefs(
}
if (!global_prefs.run_if_user_active) {
msg_printf(NULL, MSG_INFO, " don't compute while active");
#ifdef ANDROID
} else {
msg_printf(NULL, MSG_INFO, " Android: don't compute while active");
global_prefs.run_if_user_active = false;
#endif
}
if (!global_prefs.run_gpu_if_user_active) {
msg_printf(NULL, MSG_INFO, " don't use GPU while active");

View File

@ -1170,10 +1170,11 @@ static void handle_report_device_status(GUI_RPC_CONN& grc) {
"Android device status:"
);
msg_printf(0, MSG_INFO,
"On AC: %s; on USB: %s; on WiFi: %s",
"On AC: %s; on USB: %s; on WiFi: %s; user active: %s",
d.on_ac_power?"yes":"no",
d.on_usb_power?"yes":"no",
d.wifi_online?"yes":"no"
d.wifi_online?"yes":"no",
d.user_active?"yes":"no"
);
msg_printf(0, MSG_INFO,
"Battery: charge pct: %f; temp %f state %s",
@ -1205,6 +1206,7 @@ int DEVICE_STATUS::parse(XML_PARSER& xp) {
if (xp.parse_int("battery_state", battery_state)) continue;
if (xp.parse_double("battery_temperature_celsius", battery_temperature_celsius)) continue;
if (xp.parse_bool("wifi_online", wifi_online)) continue;
if (xp.parse_bool("user_active", user_active)) continue;
}
return ERR_XML_PARSE;
}

View File

@ -243,6 +243,7 @@ struct DEVICE_STATUS {
int battery_state; // see above
double battery_temperature_celsius;
bool wifi_online;
bool user_active;
int parse(XML_PARSER&);
DEVICE_STATUS() {
@ -252,6 +253,7 @@ struct DEVICE_STATUS {
battery_state = BATTERY_STATE_UNKNOWN;
battery_temperature_celsius = 0;
wifi_online = false;
user_active = false;
}
};