Duty on background

pull/194/merge
M66B 3 years ago
parent 3453080f7f
commit 203e975ce6

@ -3559,7 +3559,7 @@ class Core {
} finally {
// Free memory
isub[j] = null;
dc.stop();
dc.stop(state.getForeground());
}
}
}
@ -3647,7 +3647,7 @@ class Core {
} finally {
// Free memory
isub[j] = null;
dc.stop();
dc.stop(state.getForeground());
}
}
}
@ -5625,6 +5625,7 @@ class Core {
private Thread thread = new Thread();
private Semaphore semaphore = new Semaphore(0);
private boolean running = true;
private boolean foreground = false;
private boolean recoverable = true;
private Throwable unrecoverable = null;
private Long lastActivity = null;
@ -5809,6 +5810,14 @@ class Core {
return serial;
}
void setForeground(boolean value) {
this.foreground = value;
}
boolean getForeground() {
return this.foreground;
}
@NonNull
@Override
public String toString() {

@ -48,7 +48,7 @@ public class DutyCycle {
start = new Date().getTime();
}
public void stop() {
public void stop(boolean foreground) {
long end = new Date().getTime();
if (last != null)
@ -59,8 +59,9 @@ public class DutyCycle {
if (busy + idle > interval) {
long wait = (duration - idle);
Log.i(name + " busy=" + busy + " idle=" + idle + " wait=" + wait);
if (wait > 0) {
Log.i(name + " busy=" + busy + " idle=" + idle +
" wait=" + wait + " foreground=" + foreground);
if (wait > 0 && foreground) {
try {
Thread.sleep(wait);
} catch (InterruptedException ex) {

@ -1193,6 +1193,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private void onState(Intent intent) {
foreground = intent.getBooleanExtra("foreground", false);
for (Core.State state : coreStates.values())
state.setForeground(foreground);
}
private void onPoll(Intent intent) {
@ -1992,7 +1994,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
iservice, ifolder,
state, serial);
} finally {
dc.stop();
dc.stop(state.getForeground());
}
} catch (Throwable ex) {

Loading…
Cancel
Save