mirror of https://github.com/BOINC/boinc.git
android: bug fix for issue #1308, screen turning on on random occassions.
bug was caused by full wakelock acquisition every time RPC connection got (re-)connected. This can also happen after Android internal house keeping. moved acquistion of setup wakelock into condition, so it only gets acquired when client gets started from scratch.
This commit is contained in:
parent
d4d5d7ea06
commit
77f61d5694
|
@ -107,6 +107,13 @@ public class Monitor extends Service {
|
|||
private Boolean clientSetup() {
|
||||
if(Logging.DEBUG) Log.d(Logging.TAG,"Monitor.clientSetup()");
|
||||
|
||||
// initialize full wakelock.
|
||||
// gets used if client has to be started from scratch
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
WakeLock setupWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, Logging.TAG);
|
||||
// do not acquire here, otherwise screen turns on, every time rpc connection
|
||||
// gets reconnected.
|
||||
|
||||
// try to get current client status from monitor
|
||||
ClientStatus status;
|
||||
try{
|
||||
|
@ -115,13 +122,6 @@ public class Monitor extends Service {
|
|||
if(Logging.WARNING) Log.w(Logging.TAG,"Monitor.clientSetup: Could not load data, clientStatus not initialized.");
|
||||
return false;
|
||||
}
|
||||
// wake up device and acquire full WakeLock here to allow BOINC client to detect
|
||||
// all available CPU cores if not acquired and device in power saving mode, client
|
||||
// might detect fewer CPU cores than available.
|
||||
// Lock needs to be release, before return!
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
WakeLock setupWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, Logging.TAG);
|
||||
setupWakeLock.acquire();
|
||||
|
||||
status.setSetupStatus(ClientStatus.SETUP_STATUS_LAUNCHING,true);
|
||||
String clientProcessName = clientPath + clientName;
|
||||
|
@ -160,11 +160,9 @@ public class Monitor extends Service {
|
|||
// quit with OS signals
|
||||
if(!success) quitProcessOsLevel(clientProcessName);
|
||||
|
||||
// Install BOINC client software
|
||||
//
|
||||
// at this point client is definitely not running. install new binary...
|
||||
if(!installClient()) {
|
||||
if(Logging.WARNING) Log.w(Logging.TAG, "BOINC client installation failed!");
|
||||
setupWakeLock.release();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +172,11 @@ public class Monitor extends Service {
|
|||
Integer clientPid = getPidForProcessName(clientProcessName);
|
||||
if(clientPid == null) {
|
||||
if(Logging.DEBUG) Log.d(Logging.TAG, "Starting the BOINC client");
|
||||
// wake up device and acquire full WakeLock here to allow BOINC client to detect
|
||||
// all available CPU cores if not acquired and device in power saving mode, client
|
||||
// might detect fewer CPU cores than available.
|
||||
// Lock needs to be release, before return!
|
||||
setupWakeLock.acquire();
|
||||
if (!runClient()) {
|
||||
if(Logging.DEBUG) Log.d(Logging.TAG, "BOINC client failed to start");
|
||||
setupWakeLock.release();
|
||||
|
@ -220,7 +223,9 @@ public class Monitor extends Service {
|
|||
status.setSetupStatus(ClientStatus.SETUP_STATUS_ERROR,true);
|
||||
}
|
||||
|
||||
setupWakeLock.release();
|
||||
try{
|
||||
setupWakeLock.release(); // throws exception if it has not been acquired before
|
||||
} catch(Exception e){}
|
||||
return connected;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue