aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-01-10 19:37:51 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2013-01-10 19:37:51 +0100
commitdbbd8f6856086a9aa17b565080959fb77dc24cd9 (patch)
tree6309e58b2054d0374ef66a2492d40ce2ac80636f
parentb83d82146b10d2c01f5124cddaf68d823cc44c65 (diff)
downloadopen-keychain-dbbd8f6856086a9aa17b565080959fb77dc24cd9.tar.gz
open-keychain-dbbd8f6856086a9aa17b565080959fb77dc24cd9.tar.bz2
open-keychain-dbbd8f6856086a9aa17b565080959fb77dc24cd9.zip
Make ApiService thread safe
-rw-r--r--APG/src/org/thialfihar/android/apg/service/ApgApiService.java34
-rw-r--r--APG/src/org/thialfihar/android/apg/service/ApgKeyService.java6
2 files changed, 13 insertions, 27 deletions
diff --git a/APG/src/org/thialfihar/android/apg/service/ApgApiService.java b/APG/src/org/thialfihar/android/apg/service/ApgApiService.java
index 81d665e13..88f062b87 100644
--- a/APG/src/org/thialfihar/android/apg/service/ApgApiService.java
+++ b/APG/src/org/thialfihar/android/apg/service/ApgApiService.java
@@ -44,12 +44,6 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
-/**
- * TODO:
- *
- * - is this service thread safe? Probably not!
- *
- */
public class ApgApiService extends Service {
Context mContext;
@@ -79,7 +73,7 @@ public class ApgApiService extends Service {
// }
// }
- private void encryptAndSignImplementation(byte[] inputBytes, String inputUri,
+ private synchronized void encryptAndSignSafe(byte[] inputBytes, String inputUri,
boolean useAsciiArmor, int compression, long[] encryptionKeyIds,
String encryptionPassphrase, int symmetricEncryptionAlgorithm, long signatureKeyId,
int signatureHashAlgorithm, boolean signatureForceV3, String signaturePassphrase,
@@ -143,7 +137,7 @@ public class ApgApiService extends Service {
}
}
- private void decryptAndVerifyImplementation(byte[] inputBytes, String inputUri,
+ private synchronized void decryptAndVerifySafe(byte[] inputBytes, String inputUri,
String passphrase, boolean assumeSymmetric, IApgDecryptHandler handler)
throws RemoteException {
@@ -186,7 +180,7 @@ public class ApgApiService extends Service {
}
}
- private void getDecryptionKeyImplementation(byte[] inputBytes, String inputUri,
+ private synchronized void getDecryptionKeySafe(byte[] inputBytes, String inputUri,
IApgGetDecryptionKeyIdHandler handler) {
// TODO: implement inputUri
@@ -237,9 +231,8 @@ public class ApgApiService extends Service {
int compression, long[] encryptionKeyIds, int symmetricEncryptionAlgorithm,
IApgEncryptHandler handler) throws RemoteException {
- encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
- encryptionKeyIds, null, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
- null, handler);
+ encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, encryptionKeyIds,
+ null, symmetricEncryptionAlgorithm, Id.key.none, 0, false, null, handler);
}
@Override
@@ -247,7 +240,7 @@ public class ApgApiService extends Service {
int compression, String encryptionPassphrase, int symmetricEncryptionAlgorithm,
IApgEncryptHandler handler) throws RemoteException {
- encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
+ encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, null,
encryptionPassphrase, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
null, handler);
}
@@ -259,9 +252,9 @@ public class ApgApiService extends Service {
boolean signatureForceV3, String signaturePassphrase, IApgEncryptHandler handler)
throws RemoteException {
- encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
- encryptionKeyIds, null, symmetricEncryptionAlgorithm, signatureKeyId,
- signatureHashAlgorithm, signatureForceV3, signaturePassphrase, handler);
+ encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, encryptionKeyIds,
+ null, symmetricEncryptionAlgorithm, signatureKeyId, signatureHashAlgorithm,
+ signatureForceV3, signaturePassphrase, handler);
}
@Override
@@ -271,7 +264,7 @@ public class ApgApiService extends Service {
boolean signatureForceV3, String signaturePassphrase, IApgEncryptHandler handler)
throws RemoteException {
- encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
+ encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, null,
encryptionPassphrase, symmetricEncryptionAlgorithm, signatureKeyId,
signatureHashAlgorithm, signatureForceV3, signaturePassphrase, handler);
}
@@ -280,22 +273,21 @@ public class ApgApiService extends Service {
public void decryptAndVerifyAsymmetric(byte[] inputBytes, String inputUri,
String keyPassphrase, IApgDecryptHandler handler) throws RemoteException {
- decryptAndVerifyImplementation(inputBytes, inputUri, keyPassphrase, false, handler);
+ decryptAndVerifySafe(inputBytes, inputUri, keyPassphrase, false, handler);
}
@Override
public void decryptAndVerifySymmetric(byte[] inputBytes, String inputUri,
String encryptionPassphrase, IApgDecryptHandler handler) throws RemoteException {
- decryptAndVerifyImplementation(inputBytes, inputUri, encryptionPassphrase, true,
- handler);
+ decryptAndVerifySafe(inputBytes, inputUri, encryptionPassphrase, true, handler);
}
@Override
public void getDecryptionKeyId(byte[] inputBytes, String inputUri,
IApgGetDecryptionKeyIdHandler handler) throws RemoteException {
- getDecryptionKeyImplementation(inputBytes, inputUri, handler);
+ getDecryptionKeySafe(inputBytes, inputUri, handler);
}
};
diff --git a/APG/src/org/thialfihar/android/apg/service/ApgKeyService.java b/APG/src/org/thialfihar/android/apg/service/ApgKeyService.java
index 9a184c71f..4a7d517c9 100644
--- a/APG/src/org/thialfihar/android/apg/service/ApgKeyService.java
+++ b/APG/src/org/thialfihar/android/apg/service/ApgKeyService.java
@@ -29,12 +29,6 @@ import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
-/**
- * TODO:
- *
- * - is this service thread safe?
- *
- */
public class ApgKeyService extends Service {
Context mContext;