mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-23 15:38:50 -05:00
refactored KeychainService
This commit is contained in:
parent
5726698763
commit
0499b1f056
@ -165,8 +165,6 @@ public class KeychainService extends Service implements Progressable {
|
||||
|
||||
private KeyImportAccumulator mKeyImportAccumulator;
|
||||
|
||||
private KeychainService mKeychainService;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
@ -177,7 +175,6 @@ public class KeychainService extends Service implements Progressable {
|
||||
*/
|
||||
@Override
|
||||
public int onStartCommand(final Intent intent, int flags, int startId) {
|
||||
mKeychainService = this;
|
||||
|
||||
if (ACTION_CANCEL.equals(intent.getAction())) {
|
||||
mActionCanceled.set(true);
|
||||
@ -214,7 +211,7 @@ public class KeychainService extends Service implements Progressable {
|
||||
|
||||
Log.logDebugBundle(data, "EXTRA_DATA");
|
||||
|
||||
ProviderHelper providerHelper = new ProviderHelper(mKeychainService);
|
||||
ProviderHelper providerHelper = new ProviderHelper(KeychainService.this);
|
||||
|
||||
String action = intent.getAction();
|
||||
|
||||
@ -225,9 +222,9 @@ public class KeychainService extends Service implements Progressable {
|
||||
// Operation
|
||||
ConsolidateResult result;
|
||||
if (data.containsKey(CONSOLIDATE_RECOVERY) && data.getBoolean(CONSOLIDATE_RECOVERY)) {
|
||||
result = providerHelper.consolidateDatabaseStep2(mKeychainService);
|
||||
result = providerHelper.consolidateDatabaseStep2(KeychainService.this);
|
||||
} else {
|
||||
result = providerHelper.consolidateDatabaseStep1(mKeychainService);
|
||||
result = providerHelper.consolidateDatabaseStep1(KeychainService.this);
|
||||
}
|
||||
|
||||
// Result
|
||||
@ -290,8 +287,8 @@ public class KeychainService extends Service implements Progressable {
|
||||
}
|
||||
}
|
||||
|
||||
PgpDecryptVerify op = new PgpDecryptVerify(mKeychainService, providerHelper,
|
||||
mKeychainService);
|
||||
PgpDecryptVerify op = new PgpDecryptVerify(KeychainService.this, providerHelper,
|
||||
KeychainService.this);
|
||||
|
||||
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(messageBytes)
|
||||
.setSignedLiteralData(true)
|
||||
@ -336,7 +333,7 @@ public class KeychainService extends Service implements Progressable {
|
||||
boolean isSecret = data.getBoolean(DELETE_IS_SECRET);
|
||||
|
||||
// Operation
|
||||
DeleteOperation op = new DeleteOperation(mKeychainService, providerHelper, mKeychainService);
|
||||
DeleteOperation op = new DeleteOperation(KeychainService.this, providerHelper, KeychainService.this);
|
||||
DeleteResult result = op.execute(masterKeyIds, isSecret);
|
||||
|
||||
// Result
|
||||
@ -351,8 +348,8 @@ public class KeychainService extends Service implements Progressable {
|
||||
CryptoInputParcel cryptoInput = data.getParcelable(EXTRA_CRYPTO_INPUT);
|
||||
|
||||
// Operation
|
||||
EditKeyOperation op = new EditKeyOperation(mKeychainService, providerHelper,
|
||||
mKeychainService, mActionCanceled);
|
||||
EditKeyOperation op = new EditKeyOperation(KeychainService.this, providerHelper,
|
||||
KeychainService.this, mActionCanceled);
|
||||
OperationResult result = op.execute(saveParcel, cryptoInput);
|
||||
|
||||
// Result
|
||||
@ -369,7 +366,7 @@ public class KeychainService extends Service implements Progressable {
|
||||
|
||||
// Operation
|
||||
PromoteKeyOperation op = new PromoteKeyOperation(
|
||||
mKeychainService, providerHelper, mKeychainService,
|
||||
KeychainService.this, providerHelper, KeychainService.this,
|
||||
mActionCanceled);
|
||||
PromoteKeyResult result = op.execute(keyRingId, cardAid, subKeyIds);
|
||||
|
||||
@ -390,7 +387,7 @@ public class KeychainService extends Service implements Progressable {
|
||||
|
||||
// Operation
|
||||
ImportExportOperation importExportOperation = new ImportExportOperation(
|
||||
mKeychainService, providerHelper, mKeychainService);
|
||||
KeychainService.this, providerHelper, KeychainService.this);
|
||||
ExportResult result;
|
||||
if (outputFile != null) {
|
||||
result = importExportOperation.exportToFile(masterKeyIds, exportSecret, outputFile);
|
||||
@ -441,8 +438,8 @@ public class KeychainService extends Service implements Progressable {
|
||||
HkpKeyserver server = new HkpKeyserver(keyServer);
|
||||
|
||||
CanonicalizedPublicKeyRing keyring = providerHelper.getCanonicalizedPublicKeyRing(dataUri);
|
||||
ImportExportOperation importExportOperation = new ImportExportOperation(mKeychainService,
|
||||
providerHelper, mKeychainService);
|
||||
ImportExportOperation importExportOperation = new ImportExportOperation(KeychainService.this,
|
||||
providerHelper, KeychainService.this);
|
||||
|
||||
try {
|
||||
importExportOperation.uploadKeyRingToServer(server, keyring, getProxyFromBundle(data));
|
||||
@ -496,7 +493,7 @@ public class KeychainService extends Service implements Progressable {
|
||||
// contextualize the exception, if necessary
|
||||
String message;
|
||||
if (e instanceof PgpGeneralMsgIdException) {
|
||||
e = ((PgpGeneralMsgIdException) e).getContextualized(mKeychainService);
|
||||
e = ((PgpGeneralMsgIdException) e).getContextualized(KeychainService.this);
|
||||
message = e.getMessage();
|
||||
} else {
|
||||
message = e.getMessage();
|
||||
@ -580,11 +577,11 @@ public class KeychainService extends Service implements Progressable {
|
||||
ProviderHelper providerHelper, Proxy proxy) {
|
||||
Log.d(Constants.TAG, "serial key import starting");
|
||||
ParcelableFileCache<ParcelableKeyRing> cache =
|
||||
new ParcelableFileCache<>(mKeychainService, "key_import.pcl");
|
||||
new ParcelableFileCache<>(KeychainService.this, "key_import.pcl");
|
||||
|
||||
// Operation
|
||||
ImportExportOperation importExportOperation = new ImportExportOperation(
|
||||
mKeychainService, providerHelper, mKeychainService,
|
||||
KeychainService.this, providerHelper, KeychainService.this,
|
||||
mActionCanceled);
|
||||
// Either list or cache must be null, no guarantees otherwise.
|
||||
ImportKeyResult result = keyList != null
|
||||
@ -602,7 +599,7 @@ public class KeychainService extends Service implements Progressable {
|
||||
keyServer, final Proxy proxy) {
|
||||
Log.d(Constants.TAG, "Multi-threaded key import starting");
|
||||
if (keyListIterator != null) {
|
||||
mKeyImportAccumulator = new KeyImportAccumulator(totKeys, mKeychainService);
|
||||
mKeyImportAccumulator = new KeyImportAccumulator(totKeys, KeychainService.this);
|
||||
setProgress(0, totKeys);
|
||||
|
||||
final int maxThreads = 200;
|
||||
@ -621,8 +618,8 @@ public class KeychainService extends Service implements Progressable {
|
||||
ImportKeyResult result = null;
|
||||
try {
|
||||
ImportExportOperation importExportOperation = new ImportExportOperation(
|
||||
mKeychainService,
|
||||
new ProviderHelper(mKeychainService),
|
||||
KeychainService.this,
|
||||
new ProviderHelper(KeychainService.this),
|
||||
mKeyImportAccumulator.getImportProgressable(),
|
||||
mActionCanceled);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user