Removed task interruption

This commit is contained in:
M66B 2021-07-02 07:11:10 +02:00
parent c4736677bf
commit 9dc7795320
3 changed files with 4 additions and 23 deletions

View File

@ -721,7 +721,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
ex instanceof SecurityException);
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
}
}.setInterruptable(false).execute(this, args, "setup:export");
}.execute(this, args, "setup:export");
}
private void handleImport(Intent data, String password) {
@ -1111,7 +1111,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
Log.unexpectedError(getSupportFragmentManager(), ex, !expected);
}
}
}.setInterruptable(false).execute(this, args, "setup:import");
}.execute(this, args, "setup:import");
}
private void handleImportCertificate(Intent data) {

View File

@ -999,9 +999,7 @@ public class FragmentFolders extends FragmentBase {
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.setInterruptable(false).execute(this, args, "folder:export");
}.execute(this, args, "folder:export");
}
public static class FragmentDialogApply extends FragmentDialogBase {

View File

@ -51,12 +51,10 @@ import java.util.concurrent.Future;
public abstract class SimpleTask<T> implements LifecycleObserver {
private boolean log = true;
private boolean count = true;
private boolean interruptable = true;
private String name;
private long started;
private boolean reported;
private boolean interrupted;
private Lifecycle.State state;
private Future<?> future;
private ExecutorService localExecutor;
@ -67,7 +65,6 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
private static final int MAX_WAKELOCK = 30 * 60 * 1000; // milliseconds
private static final int REPORT_AFTER = 15 * 60 * 1000; // milliseconds
private static final int CANCEL_AFTER = MAX_WAKELOCK; // milliseconds
static final String ACTION_TASK_COUNT = BuildConfig.APPLICATION_ID + ".ACTION_TASK_COUNT";
@ -83,11 +80,6 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
return this;
}
public SimpleTask<T> setInterruptable(boolean interruptable) {
this.interruptable = interruptable;
return this;
}
public SimpleTask<T> setExecutor(ExecutorService executor) {
this.localExecutor = executor;
return this;
@ -272,7 +264,6 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
private void cleanup(Context context) {
started = 0;
reported = false;
interrupted = false;
future = null;
synchronized (tasks) {
tasks.remove(this);
@ -288,15 +279,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
for (SimpleTask task : tasks)
if (task.future != null && !task.future.isDone()) {
long elapsed = now - task.started;
if (elapsed > CANCEL_AFTER && !task.interrupted) {
task.interrupted = true;
if (task.interruptable &&
task.future != null && !task.future.isDone()) {
Log.e("Interrupting task " + task +
" tasks=" + getCountLocked() + "/" + tasks.size());
task.future.cancel(true);
}
} else if (elapsed > REPORT_AFTER && !task.reported) {
if (elapsed > REPORT_AFTER && !task.reported) {
task.reported = true;
Log.e("Long running task " + task +
" tasks=" + getCountLocked() + "/" + tasks.size());