From 37eb54f12f75667b3206560aadd9fa6471563e0c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 22 Jun 2013 09:58:39 -0700 Subject: [PATCH] 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). --- client/client_state.cpp | 4 ++++ client/cs_prefs.cpp | 5 +++++ client/gui_rpc_server_ops.cpp | 6 ++++-- lib/common_defs.h | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/client/client_state.cpp b/client/client_state.cpp index 1c3318ce17..6b0fa06fa6 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -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"); diff --git a/client/cs_prefs.cpp b/client/cs_prefs.cpp index 58f94f4d7f..1eac33ed8a 100644 --- a/client/cs_prefs.cpp +++ b/client/cs_prefs.cpp @@ -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"); diff --git a/client/gui_rpc_server_ops.cpp b/client/gui_rpc_server_ops.cpp index 6c3136c077..67c6f616a8 100644 --- a/client/gui_rpc_server_ops.cpp +++ b/client/gui_rpc_server_ops.cpp @@ -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; } diff --git a/lib/common_defs.h b/lib/common_defs.h index 289a6d13f5..715148d5cf 100644 --- a/lib/common_defs.h +++ b/lib/common_defs.h @@ -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; } };