mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Make ApiService thread safe
This commit is contained in:
parent
b83d82146b
commit
dbbd8f6856
@ -44,12 +44,6 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO:
|
|
||||||
*
|
|
||||||
* - is this service thread safe? Probably not!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ApgApiService extends Service {
|
public class ApgApiService extends Service {
|
||||||
Context mContext;
|
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,
|
boolean useAsciiArmor, int compression, long[] encryptionKeyIds,
|
||||||
String encryptionPassphrase, int symmetricEncryptionAlgorithm, long signatureKeyId,
|
String encryptionPassphrase, int symmetricEncryptionAlgorithm, long signatureKeyId,
|
||||||
int signatureHashAlgorithm, boolean signatureForceV3, String signaturePassphrase,
|
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)
|
String passphrase, boolean assumeSymmetric, IApgDecryptHandler handler)
|
||||||
throws RemoteException {
|
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) {
|
IApgGetDecryptionKeyIdHandler handler) {
|
||||||
|
|
||||||
// TODO: implement inputUri
|
// TODO: implement inputUri
|
||||||
@ -237,9 +231,8 @@ public class ApgApiService extends Service {
|
|||||||
int compression, long[] encryptionKeyIds, int symmetricEncryptionAlgorithm,
|
int compression, long[] encryptionKeyIds, int symmetricEncryptionAlgorithm,
|
||||||
IApgEncryptHandler handler) throws RemoteException {
|
IApgEncryptHandler handler) throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
|
encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, encryptionKeyIds,
|
||||||
encryptionKeyIds, null, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
|
null, symmetricEncryptionAlgorithm, Id.key.none, 0, false, null, handler);
|
||||||
null, handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -247,7 +240,7 @@ public class ApgApiService extends Service {
|
|||||||
int compression, String encryptionPassphrase, int symmetricEncryptionAlgorithm,
|
int compression, String encryptionPassphrase, int symmetricEncryptionAlgorithm,
|
||||||
IApgEncryptHandler handler) throws RemoteException {
|
IApgEncryptHandler handler) throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
|
encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, null,
|
||||||
encryptionPassphrase, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
|
encryptionPassphrase, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
|
||||||
null, handler);
|
null, handler);
|
||||||
}
|
}
|
||||||
@ -259,9 +252,9 @@ public class ApgApiService extends Service {
|
|||||||
boolean signatureForceV3, String signaturePassphrase, IApgEncryptHandler handler)
|
boolean signatureForceV3, String signaturePassphrase, IApgEncryptHandler handler)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
|
encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, encryptionKeyIds,
|
||||||
encryptionKeyIds, null, symmetricEncryptionAlgorithm, signatureKeyId,
|
null, symmetricEncryptionAlgorithm, signatureKeyId, signatureHashAlgorithm,
|
||||||
signatureHashAlgorithm, signatureForceV3, signaturePassphrase, handler);
|
signatureForceV3, signaturePassphrase, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -271,7 +264,7 @@ public class ApgApiService extends Service {
|
|||||||
boolean signatureForceV3, String signaturePassphrase, IApgEncryptHandler handler)
|
boolean signatureForceV3, String signaturePassphrase, IApgEncryptHandler handler)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
|
encryptAndSignSafe(inputBytes, inputUri, useAsciiArmor, compression, null,
|
||||||
encryptionPassphrase, symmetricEncryptionAlgorithm, signatureKeyId,
|
encryptionPassphrase, symmetricEncryptionAlgorithm, signatureKeyId,
|
||||||
signatureHashAlgorithm, signatureForceV3, signaturePassphrase, handler);
|
signatureHashAlgorithm, signatureForceV3, signaturePassphrase, handler);
|
||||||
}
|
}
|
||||||
@ -280,22 +273,21 @@ public class ApgApiService extends Service {
|
|||||||
public void decryptAndVerifyAsymmetric(byte[] inputBytes, String inputUri,
|
public void decryptAndVerifyAsymmetric(byte[] inputBytes, String inputUri,
|
||||||
String keyPassphrase, IApgDecryptHandler handler) throws RemoteException {
|
String keyPassphrase, IApgDecryptHandler handler) throws RemoteException {
|
||||||
|
|
||||||
decryptAndVerifyImplementation(inputBytes, inputUri, keyPassphrase, false, handler);
|
decryptAndVerifySafe(inputBytes, inputUri, keyPassphrase, false, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decryptAndVerifySymmetric(byte[] inputBytes, String inputUri,
|
public void decryptAndVerifySymmetric(byte[] inputBytes, String inputUri,
|
||||||
String encryptionPassphrase, IApgDecryptHandler handler) throws RemoteException {
|
String encryptionPassphrase, IApgDecryptHandler handler) throws RemoteException {
|
||||||
|
|
||||||
decryptAndVerifyImplementation(inputBytes, inputUri, encryptionPassphrase, true,
|
decryptAndVerifySafe(inputBytes, inputUri, encryptionPassphrase, true, handler);
|
||||||
handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getDecryptionKeyId(byte[] inputBytes, String inputUri,
|
public void getDecryptionKeyId(byte[] inputBytes, String inputUri,
|
||||||
IApgGetDecryptionKeyIdHandler handler) throws RemoteException {
|
IApgGetDecryptionKeyIdHandler handler) throws RemoteException {
|
||||||
|
|
||||||
getDecryptionKeyImplementation(inputBytes, inputUri, handler);
|
getDecryptionKeySafe(inputBytes, inputUri, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -29,12 +29,6 @@ import android.content.Intent;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO:
|
|
||||||
*
|
|
||||||
* - is this service thread safe?
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ApgKeyService extends Service {
|
public class ApgKeyService extends Service {
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user