remove broken(?) cancellation code

This commit is contained in:
Vincent Breitmoser 2014-08-31 20:12:46 +02:00
parent 42acb12059
commit 16a93038dd
2 changed files with 7 additions and 59 deletions

View File

@ -52,23 +52,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class PgpImportExport {
// TODO: is this really used?
public interface KeychainServiceListener {
boolean hasServiceStopped();
}
private Context mContext;
private Progressable mProgressable;
private AtomicBoolean mCancelled;
private KeychainServiceListener mKeychainServiceListener;
private ProviderHelper mProviderHelper;
public PgpImportExport(Context context, Progressable progressable) {
this(context, new ProviderHelper(context), progressable);
}
public PgpImportExport(Context context, ProviderHelper providerHelper, Progressable progressable) {
super();
this.mContext = context;
@ -84,15 +73,6 @@ public class PgpImportExport {
mCancelled = cancelled;
}
public PgpImportExport(Context context,
Progressable progressable, KeychainServiceListener keychainListener) {
super();
this.mContext = context;
this.mProgressable = progressable;
this.mProviderHelper = new ProviderHelper(context);
this.mKeychainServiceListener = keychainListener;
}
public void updateProgress(int message, int current, int total) {
if (mProgressable != null) {
mProgressable.setProgress(message, current, total);
@ -277,11 +257,6 @@ public class PgpImportExport {
// TODO: inform user?
}
if (mKeychainServiceListener.hasServiceStopped()) {
arOutStream.close();
return null;
}
arOutStream.close();
}
@ -306,11 +281,6 @@ public class PgpImportExport {
// TODO: inform user?
}
if (mKeychainServiceListener.hasServiceStopped()) {
arOutStream.close();
return null;
}
arOutStream.close();
}

View File

@ -82,8 +82,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* data from the activities or other apps, queues these intents, executes them, and stops itself
* after doing them.
*/
public class KeychainIntentService extends IntentService
implements Progressable, PgpImportExport.KeychainServiceListener {
public class KeychainIntentService extends IntentService implements Progressable {
/* extras that can be given by intent */
public static final String EXTRA_MESSENGER = "messenger";
@ -201,7 +200,6 @@ public class KeychainIntentService extends IntentService
Messenger mMessenger;
private boolean mIsCanceled;
// this attribute can possibly merged with the one above? not sure...
private AtomicBoolean mActionCanceled = new AtomicBoolean(false);
@ -209,12 +207,6 @@ public class KeychainIntentService extends IntentService
super("KeychainIntentService");
}
@Override
public void onDestroy() {
super.onDestroy();
this.mIsCanceled = true;
}
/**
* The IntentService calls this method from the default worker thread with the intent that
* started the service. When this method returns, IntentService stops the service, as
@ -598,12 +590,11 @@ public class KeychainIntentService extends IntentService
outStream = getContentResolver().openOutputStream(outputUri);
}
PgpImportExport pgpImportExport = new PgpImportExport(this, this, this);
PgpImportExport pgpImportExport = new PgpImportExport(this, new ProviderHelper(this), this);
Bundle resultData = pgpImportExport
.exportKeyRings(publicMasterKeyIds, secretMasterKeyIds,
outStream);
.exportKeyRings(publicMasterKeyIds, secretMasterKeyIds, outStream);
if (mIsCanceled && outputFile != null) {
if (mActionCanceled.get() && outputFile != null) {
new File(outputFile).delete();
}
@ -623,7 +614,7 @@ public class KeychainIntentService extends IntentService
ProviderHelper providerHelper = new ProviderHelper(this);
CanonicalizedPublicKeyRing keyring = providerHelper.getCanonicalizedPublicKeyRing(dataUri);
PgpImportExport pgpImportExport = new PgpImportExport(this, null);
PgpImportExport pgpImportExport = new PgpImportExport(this, new ProviderHelper(this), this);
try {
pgpImportExport.uploadKeyRingToServer(server, keyring);
@ -740,8 +731,7 @@ public class KeychainIntentService extends IntentService
}
if (isSecret && success) {
ConsolidateResult result =
new ProviderHelper(this).consolidateDatabaseStep1(this);
new ProviderHelper(this).consolidateDatabaseStep1(this);
}
if (success) {
@ -768,10 +758,6 @@ public class KeychainIntentService extends IntentService
}
private void sendErrorToHandler(Exception e) {
// Service was canceled. Do not send error to handler.
if (this.mIsCanceled) {
return;
}
// TODO: Implement a better exception handling here
// contextualize the exception, if necessary
String message;
@ -806,10 +792,7 @@ public class KeychainIntentService extends IntentService
}
private void sendMessageToHandler(Integer arg1, Integer arg2, Bundle data) {
// Service was canceled. Do not send message to handler.
if (this.mIsCanceled) {
return;
}
Message msg = Message.obtain();
assert msg != null;
msg.arg1 = arg1;
@ -868,11 +851,6 @@ public class KeychainIntentService extends IntentService
setProgress(null, progress, max);
}
@Override
public boolean hasServiceStopped() {
return mIsCanceled;
}
private InputData createDecryptInputData(Bundle data) throws IOException, PgpGeneralException {
return createCryptInputData(data, DECRYPT_CIPHERTEXT_BYTES);
}