From cebe16ccbe3c8ed0d40030eff7214087a5f5cdeb Mon Sep 17 00:00:00 2001 From: Joachim Fritzsch Date: Wed, 14 Aug 2013 08:56:51 +0200 Subject: [PATCH] android: re-enable cpu throttling with bug fixes. --- .../src/edu/berkeley/boinc/PrefsActivity.java | 5 ++--- .../berkeley/boinc/client/ClientStatus.java | 14 ++++---------- .../edu/berkeley/boinc/client/Monitor.java | 19 +++---------------- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/android/BOINC/src/edu/berkeley/boinc/PrefsActivity.java b/android/BOINC/src/edu/berkeley/boinc/PrefsActivity.java index 1ee3da31f7..a0aa56dc89 100644 --- a/android/BOINC/src/edu/berkeley/boinc/PrefsActivity.java +++ b/android/BOINC/src/edu/berkeley/boinc/PrefsActivity.java @@ -204,7 +204,7 @@ public class PrefsActivity extends FragmentActivity { // cpu if(advanced) data.add(new PrefsListItemWrapper(this,R.string.prefs_category_cpu,true)); if(advanced && hostinfo.p_ncpus > 1) data.add(new PrefsListItemWrapperValue(this,R.string.prefs_cpu_number_cpus_header,R.string.prefs_category_cpu,pctCpuCoresToNumber(clientPrefs.max_ncpus_pct))); - //if(advanced) data.add(new PrefsListItemWrapperValue(this,R.string.prefs_cpu_time_max_header,R.string.prefs_category_cpu,clientPrefs.cpu_usage_limit)); + if(advanced) data.add(new PrefsListItemWrapperValue(this,R.string.prefs_cpu_time_max_header,R.string.prefs_category_cpu,clientPrefs.cpu_usage_limit)); if(advanced) data.add(new PrefsListItemWrapperValue(this,R.string.prefs_cpu_other_load_suspension_header,R.string.prefs_category_cpu,clientPrefs.suspend_cpu_usage)); // storage if(advanced) data.add(new PrefsListItemWrapper(this,R.string.prefs_category_storage,true)); @@ -482,10 +482,9 @@ public class PrefsActivity extends FragmentActivity { //convert value back to number for layout update value = pctCpuCoresToNumber(value); break; - /* case R.string.prefs_cpu_time_max_header: clientPrefs.cpu_usage_limit = value; - break;*/ + break; case R.string.prefs_cpu_other_load_suspension_header: clientPrefs.suspend_cpu_usage = value; break; diff --git a/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java b/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java index d8db9f8362..6be4e2eed9 100644 --- a/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java +++ b/android/BOINC/src/edu/berkeley/boinc/client/ClientStatus.java @@ -458,21 +458,15 @@ public class ClientStatus { computingParseError = false; return; } - if(status.task_mode == BOINCDefs.RUN_MODE_AUTO && status.task_suspend_reason == BOINCDefs.SUSPEND_REASON_CPU_THROTTLE) { - // suspended due to CPU throttling, treat as if was running! - computingStatus = COMPUTING_STATUS_COMPUTING; - computingSuspendReason = status.task_suspend_reason; // = 64 - SUSPEND_REASON_CPU_THROTTLE - computingParseError = false; - return; - - } - if((status.task_mode == BOINCDefs.RUN_MODE_AUTO) && (status.task_suspend_reason != BOINCDefs.SUSPEND_NOT_SUSPENDED)) { + if((status.task_mode == BOINCDefs.RUN_MODE_AUTO) && (status.task_suspend_reason != BOINCDefs.SUSPEND_NOT_SUSPENDED) && (status.task_suspend_reason != BOINCDefs.SUSPEND_REASON_CPU_THROTTLE)) { + // do not expose cpu throttling as suspension to UI computingStatus = COMPUTING_STATUS_SUSPENDED; computingSuspendReason = status.task_suspend_reason; computingParseError = false; return; } - if((status.task_mode == BOINCDefs.RUN_MODE_AUTO) && (status.task_suspend_reason == BOINCDefs.SUSPEND_NOT_SUSPENDED)) { + if((status.task_mode == BOINCDefs.RUN_MODE_AUTO) && ((status.task_suspend_reason == BOINCDefs.SUSPEND_NOT_SUSPENDED) || (status.task_suspend_reason == BOINCDefs.SUSPEND_REASON_CPU_THROTTLE))) { + // treat cpu throttling as if client was active (either idle, or computing, depending on tasks) //figure out whether we have an active task Boolean activeTask = false; if(results!=null) { diff --git a/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java b/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java index f503dc8074..3ce3b407d2 100644 --- a/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java +++ b/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java @@ -191,21 +191,7 @@ public class Monitor extends Service { rpc.readGlobalPrefsOverride(); // read preferences for GUI to be able to display data GlobalPreferences clientPrefs = rpc.getGlobalPrefsWorkingStruct(); - - // setting cpu_usage_limit to 100 - // preference got remove from UI for two reasons: - // - science apps would crash (timeout) - // - wakelock and foreground service would be frequently acquired / released - // hard-wire to 100% in case user has changed this preference manually before - // it got removed from the UI - // TODO needs to be removed when migrating override prefs to common mechanism - if(clientPrefs != null) { - clientPrefs.cpu_usage_limit = 100.0; - rpc.setGlobalPrefsOverrideStruct(clientPrefs); - // TODO -- end of stuff to be removed - - status.setPrefs(clientPrefs); - } + status.setPrefs(clientPrefs); // read supported projects readAndroidProjectsList(); // set Android model as hostinfo @@ -373,7 +359,8 @@ public class Monitor extends Service { // wake locks and foreground enabled when Client is not suspended, therefore also during // idle. CcStatus status = rpc.getCcStatus(); - Boolean computing = (status.task_suspend_reason == BOINCDefs.SUSPEND_NOT_SUSPENDED); + // treat cpu throttling as if it was computing + Boolean computing = (status.task_suspend_reason == BOINCDefs.SUSPEND_NOT_SUSPENDED) || (status.task_suspend_reason == BOINCDefs.SUSPEND_REASON_CPU_THROTTLE); if(Logging.VERBOSE) Log.d(Logging.TAG,"readClientStatus(): computation enabled: " + computing); Monitor.getClientStatus().setWifiLock(computing); Monitor.getClientStatus().setWakeLock(computing);