From af73b2b8626c022daf36190dd4277b135db2e41d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 12 Jun 2013 12:15:57 -0700 Subject: [PATCH] Android client: remove apps from memory if we're on batteries. Because apps poll 10X/sec for messages from the client, there is a CPU overhead in leaving suspended apps in memory, which can cause battery drain. --- client/app_control.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/app_control.cpp b/client/app_control.cpp index 15e86d39b0..bc5c7521e5 100644 --- a/client/app_control.cpp +++ b/client/app_control.cpp @@ -1076,8 +1076,17 @@ void ACTIVE_TASK_SET::suspend_all(int reason) { // atp->preempt(REMOVE_NEVER); break; +#ifdef ANDROID + case SUSPEND_REASON_BATTERIES: + // On Android, remove apps from memory if on batteries. + // The message polling in the BOINC runtime system + // imposes an overhead which drains the battery a bit + atp->preempt(REMOVE_ALWAYS); + break; +#endif default: atp->preempt(REMOVE_MAYBE_USER); + break; } } }