add cancel prevention mechanism, improve cancellation for key import
This commit is contained in:
@@ -526,12 +526,17 @@ public class KeychainIntentService extends IntentService
|
||||
}
|
||||
|
||||
ProviderHelper providerHelper = new ProviderHelper(this);
|
||||
PgpImportExport pgpImportExport = new PgpImportExport(this, providerHelper, this);
|
||||
ImportKeyResult result = pgpImportExport.importKeyRings(entries, mActionCanceled);
|
||||
PgpImportExport pgpImportExport = new PgpImportExport(
|
||||
this, providerHelper, this, mActionCanceled);
|
||||
ImportKeyResult result = pgpImportExport.importKeyRings(entries);
|
||||
|
||||
// we do this even on failure or cancellation!
|
||||
if (result.mSecret > 0) {
|
||||
// cannot cancel from here on out!
|
||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_PREVENT_CANCEL);
|
||||
providerHelper.consolidateDatabaseStep1(this);
|
||||
}
|
||||
|
||||
// make sure new data is synced into contacts
|
||||
ContactSyncAdapterService.requestSync();
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface.OnCancelListener;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -37,6 +36,7 @@ public class KeychainIntentServiceHandler extends Handler {
|
||||
public static final int MESSAGE_OKAY = 1;
|
||||
public static final int MESSAGE_EXCEPTION = 2;
|
||||
public static final int MESSAGE_UPDATE_PROGRESS = 3;
|
||||
public static final int MESSAGE_PREVENT_CANCEL = 4;
|
||||
|
||||
// possible data keys for messages
|
||||
public static final String DATA_ERROR = "error";
|
||||
@@ -124,6 +124,9 @@ public class KeychainIntentServiceHandler extends Handler {
|
||||
|
||||
break;
|
||||
|
||||
case MESSAGE_PREVENT_CANCEL:
|
||||
mProgressDialogFragment.setPreventCancel(true);
|
||||
|
||||
default:
|
||||
Log.e(Constants.TAG, "unknown handler message!");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user