back to using an operation for interactive update (for progress dialog)

This commit is contained in:
Vincent Breitmoser
2018-06-25 16:59:20 +02:00
parent a64d898716
commit 1425f34321
19 changed files with 276 additions and 246 deletions

View File

@@ -18,8 +18,6 @@
package org.sufficientlysecure.keychain.service;
import java.util.concurrent.atomic.AtomicBoolean;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
@@ -28,7 +26,10 @@ import android.os.Message;
import android.os.Messenger;
import android.os.Parcelable;
import android.os.RemoteException;
import android.support.v4.os.CancellationSignal;
import org.sufficientlysecure.keychain.operations.KeySyncOperation;
import org.sufficientlysecure.keychain.operations.KeySyncParcel;
import org.sufficientlysecure.keychain.operations.BackupOperation;
import org.sufficientlysecure.keychain.operations.BaseOperation;
import org.sufficientlysecure.keychain.operations.BenchmarkOperation;
@@ -70,7 +71,7 @@ public class KeychainService extends Service implements Progressable {
public static final String ACTION_CANCEL = "action_cancel";
// this attribute can possibly merged with the one above? not sure...
private AtomicBoolean mActionCanceled = new AtomicBoolean(false);
private CancellationSignal mActionCanceled = new CancellationSignal();
ThreadLocal<Messenger> mMessenger = new ThreadLocal<>();
@@ -86,16 +87,13 @@ public class KeychainService extends Service implements Progressable {
public int onStartCommand(final Intent intent, int flags, int startId) {
if (intent.getAction() != null && intent.getAction().equals(ACTION_CANCEL)) {
mActionCanceled.set(true);
mActionCanceled.cancel();
return START_NOT_STICKY;
}
Runnable actionRunnable = new Runnable() {
@Override
public void run() {
// We have not been cancelled! (yet)
mActionCanceled.set(false);
Bundle extras = intent.getExtras();
// Set messenger for communication (for this particular thread)
@@ -140,6 +138,8 @@ public class KeychainService extends Service implements Progressable {
op = new InputDataOperation(outerThis, databaseInteractor, outerThis);
} else if (inputParcel instanceof BenchmarkInputParcel) {
op = new BenchmarkOperation(outerThis, databaseInteractor, outerThis);
} else if (inputParcel instanceof KeySyncParcel) {
op = new KeySyncOperation(outerThis, databaseInteractor, outerThis, mActionCanceled);
} else {
throw new AssertionError("Unrecognized input parcel in KeychainService!");
}