mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
remove the null check for progress again, not needed in the trunk for now
This commit is contained in:
parent
f37204321d
commit
4e37568eab
@ -400,7 +400,6 @@ public class Apg {
|
||||
throws Apg.GeneralException, NoSuchProviderException, PGPException,
|
||||
NoSuchAlgorithmException, SignatureException, IOException, Database.GeneralException {
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_buildingKey, 0, 100);
|
||||
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
@ -462,7 +461,6 @@ public class Apg {
|
||||
keys.add(editor.getValue());
|
||||
}
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingMasterKey, 10, 100);
|
||||
KeyEditor keyEditor = (KeyEditor) keyEditors.getChildAt(0);
|
||||
int usageId = keyEditor.getUsage();
|
||||
@ -483,7 +481,6 @@ public class Apg {
|
||||
masterKey.extractPrivateKey(oldPassPhrase.toCharArray(),
|
||||
new BouncyCastleProvider());
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_certifyingMasterKey, 20, 100);
|
||||
for (int i = 0; i < userIds.size(); ++i) {
|
||||
String userId = userIds.get(i);
|
||||
@ -528,7 +525,6 @@ public class Apg {
|
||||
hashedPacketsGen.setKeyExpirationTime(true, numDays * 86400);
|
||||
}
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_buildingMasterKeyRing, 30, 100);
|
||||
PGPKeyRingGenerator keyGen =
|
||||
new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION,
|
||||
@ -537,10 +533,8 @@ public class Apg {
|
||||
hashedPacketsGen.generate(), unhashedPacketsGen.generate(),
|
||||
new SecureRandom(), new BouncyCastleProvider().getName());
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_addingSubKeys, 40, 100);
|
||||
for (int i = 1; i < keys.size(); ++i) {
|
||||
if( progress != null )
|
||||
progress.setProgress(40 + 50 * (i - 1)/ (keys.size() - 1), 100);
|
||||
PGPSecretKey subKey = keys.get(i);
|
||||
keyEditor = (KeyEditor) keyEditors.getChildAt(i);
|
||||
@ -590,12 +584,10 @@ public class Apg {
|
||||
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
|
||||
PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_savingKeyRing, 90, 100);
|
||||
mDatabase.saveKeyRing(secretKeyRing);
|
||||
mDatabase.saveKeyRing(publicKeyRing);
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
}
|
||||
|
||||
@ -606,10 +598,8 @@ public class Apg {
|
||||
Bundle returnData = new Bundle();
|
||||
|
||||
if (type == Id.type.secret_key) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_importingSecretKeys, 0, 100);
|
||||
} else {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_importingPublicKeys, 0, 100);
|
||||
}
|
||||
|
||||
@ -681,7 +671,6 @@ public class Apg {
|
||||
} else if (retValue == Id.return_value.bad) {
|
||||
++badKeys;
|
||||
}
|
||||
if( progress != null )
|
||||
progress.setProgress((int)(100 * progressIn.position() / data.getSize()), 100);
|
||||
obj = objectFactory.nextObject();
|
||||
}
|
||||
@ -694,7 +683,6 @@ public class Apg {
|
||||
returnData.putInt("updated", oldKeys);
|
||||
returnData.putInt("bad", badKeys);
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
|
||||
return returnData;
|
||||
@ -707,10 +695,8 @@ public class Apg {
|
||||
Bundle returnData = new Bundle();
|
||||
|
||||
if (keyRingIds.size() == 1) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_exportingKey, 0, 100);
|
||||
} else {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_exportingKeys, 0, 100);
|
||||
}
|
||||
|
||||
@ -721,7 +707,6 @@ public class Apg {
|
||||
|
||||
int numKeys = 0;
|
||||
for (int i = 0; i < keyRingIds.size(); ++i) {
|
||||
if( progress != null )
|
||||
progress.setProgress(i * 100 / keyRingIds.size(), 100);
|
||||
Object obj = mDatabase.getKeyRing(keyRingIds.get(i));
|
||||
PGPPublicKeyRing publicKeyRing;
|
||||
@ -741,7 +726,6 @@ public class Apg {
|
||||
out.close();
|
||||
returnData.putInt("exported", numKeys);
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
|
||||
return returnData;
|
||||
@ -1252,7 +1236,6 @@ public class Apg {
|
||||
if (signaturePassPhrase == null) {
|
||||
throw new GeneralException(context.getString(R.string.error_noSignaturePassPhrase));
|
||||
}
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_extractingSignatureKey, 0, 100);
|
||||
signaturePrivateKey = signingKey.extractPrivateKey(signaturePassPhrase.toCharArray(),
|
||||
new BouncyCastleProvider());
|
||||
@ -1260,7 +1243,6 @@ public class Apg {
|
||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||
}
|
||||
}
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingStreams, 5, 100);
|
||||
// encrypt and compress input file content
|
||||
PGPEncryptedDataGenerator cPk =
|
||||
@ -1283,7 +1265,6 @@ public class Apg {
|
||||
PGPV3SignatureGenerator signatureV3Generator = null;
|
||||
|
||||
if (signatureKeyId != 0) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingSignature, 10, 100);
|
||||
if (forceV3Signature) {
|
||||
signatureV3Generator =
|
||||
@ -1325,7 +1306,6 @@ public class Apg {
|
||||
// file name not needed, so empty string
|
||||
OutputStream pOut = literalGen.open(bcpgOut, PGPLiteralData.BINARY, "",
|
||||
new Date(), new byte[1 << 16]);
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_encrypting, 20, 100);
|
||||
long done = 0;
|
||||
int n = 0;
|
||||
@ -1342,7 +1322,6 @@ public class Apg {
|
||||
}
|
||||
done += n;
|
||||
if (data.getSize() != 0) {
|
||||
if( progress != null )
|
||||
progress.setProgress((int) (20 + (95 - 20) * done / data.getSize()), 100);
|
||||
}
|
||||
}
|
||||
@ -1350,7 +1329,6 @@ public class Apg {
|
||||
literalGen.close();
|
||||
|
||||
if (signatureKeyId != 0) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_generatingSignature, 95, 100);
|
||||
if (forceV3Signature) {
|
||||
signatureV3Generator.generate().encode(pOut);
|
||||
@ -1366,7 +1344,6 @@ public class Apg {
|
||||
armorOut.close();
|
||||
}
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
}
|
||||
|
||||
@ -1406,10 +1383,8 @@ public class Apg {
|
||||
if (signaturePrivateKey == null) {
|
||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||
}
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingStreams, 0, 100);
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingSignature, 30, 100);
|
||||
|
||||
PGPSignatureGenerator signatureGenerator = null;
|
||||
@ -1434,7 +1409,6 @@ public class Apg {
|
||||
signatureGenerator.setHashedSubpackets(spGen.generate());
|
||||
}
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_signing, 40, 100);
|
||||
|
||||
armorOut.beginClearText(hashAlgorithm);
|
||||
@ -1478,7 +1452,6 @@ public class Apg {
|
||||
}
|
||||
armorOut.close();
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
}
|
||||
|
||||
@ -1526,10 +1499,8 @@ public class Apg {
|
||||
if (signaturePrivateKey == null) {
|
||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||
}
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingStreams, 0, 100);
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingSignature, 30, 100);
|
||||
|
||||
PGPSignatureGenerator signatureGenerator = null;
|
||||
@ -1559,7 +1530,6 @@ public class Apg {
|
||||
signatureGenerator.setHashedSubpackets(spGen.generate());
|
||||
}
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_signing, 40, 100);
|
||||
|
||||
InputStream inStream = data.getInputStream();
|
||||
@ -1603,7 +1573,6 @@ public class Apg {
|
||||
out.close();
|
||||
outStream.close();
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
}
|
||||
|
||||
@ -1698,7 +1667,6 @@ public class Apg {
|
||||
long signatureKeyId = 0;
|
||||
|
||||
int currentProgress = 0;
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_readingData, currentProgress, 100);
|
||||
|
||||
if (o instanceof PGPEncryptedDataList) {
|
||||
@ -1734,13 +1702,11 @@ public class Apg {
|
||||
throw new GeneralException(context.getString(R.string.error_noSymmetricEncryptionPacket));
|
||||
}
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingStreams, currentProgress, 100);
|
||||
clear = pbe.getDataStream(passPhrase.toCharArray(), new BouncyCastleProvider());
|
||||
encryptedData = pbe;
|
||||
currentProgress += 5;
|
||||
} else {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_findingKey, currentProgress, 100);
|
||||
PGPPublicKeyEncryptedData pbe = null;
|
||||
PGPSecretKey secretKey = null;
|
||||
@ -1763,7 +1729,6 @@ public class Apg {
|
||||
}
|
||||
|
||||
currentProgress += 5;
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_extractingKey, currentProgress, 100);
|
||||
PGPPrivateKey privateKey = null;
|
||||
try {
|
||||
@ -1776,7 +1741,6 @@ public class Apg {
|
||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||
}
|
||||
currentProgress += 5;
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_preparingStreams, currentProgress, 100);
|
||||
clear = pbe.getDataStream(privateKey, new BouncyCastleProvider());
|
||||
encryptedData = pbe;
|
||||
@ -1790,7 +1754,6 @@ public class Apg {
|
||||
int signatureIndex = -1;
|
||||
|
||||
if (dataChunk instanceof PGPCompressedData) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_decompressingData, currentProgress, 100);
|
||||
PGPObjectFactory fact =
|
||||
new PGPObjectFactory(((PGPCompressedData) dataChunk).getDataStream());
|
||||
@ -1800,7 +1763,6 @@ public class Apg {
|
||||
}
|
||||
|
||||
if (dataChunk instanceof PGPOnePassSignatureList) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_processingSignature, currentProgress, 100);
|
||||
returnData.putBoolean(EXTRA_SIGNATURE, true);
|
||||
PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
|
||||
@ -1838,7 +1800,6 @@ public class Apg {
|
||||
}
|
||||
|
||||
if (dataChunk instanceof PGPLiteralData) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_decrypting, currentProgress, 100);
|
||||
PGPLiteralData literalData = (PGPLiteralData) dataChunk;
|
||||
OutputStream out = outStream;
|
||||
@ -1875,12 +1836,10 @@ public class Apg {
|
||||
currentProgress = (int)(startProgress + (endProgress - startProgress) *
|
||||
(data.getStreamPosition() - startPos) / (data.getSize() - startPos));
|
||||
}
|
||||
if( progress != null )
|
||||
progress.setProgress(currentProgress, 100);
|
||||
}
|
||||
|
||||
if (signature != null) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_verifyingSignature, 90, 100);
|
||||
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
||||
PGPSignature messageSignature = (PGPSignature) signatureList.get(signatureIndex);
|
||||
@ -1894,7 +1853,6 @@ public class Apg {
|
||||
|
||||
// TODO: add integrity somewhere
|
||||
if (encryptedData.isIntegrityProtected()) {
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_verifyingIntegrity, 95, 100);
|
||||
if (encryptedData.verify()) {
|
||||
// passed
|
||||
@ -1905,7 +1863,6 @@ public class Apg {
|
||||
// no integrity check
|
||||
}
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
return returnData;
|
||||
}
|
||||
@ -1919,7 +1876,6 @@ public class Apg {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ArmoredInputStream aIn = new ArmoredInputStream(data.getInputStream());
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 0, 100);
|
||||
|
||||
// mostly taken from ClearSignedFileProcessor
|
||||
@ -1945,7 +1901,6 @@ public class Apg {
|
||||
|
||||
returnData.putBoolean(EXTRA_SIGNATURE, true);
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_processingSignature, 60, 100);
|
||||
PGPObjectFactory pgpFact = new PGPObjectFactory(aIn);
|
||||
|
||||
@ -1993,7 +1948,6 @@ public class Apg {
|
||||
|
||||
if (signature == null) {
|
||||
returnData.putBoolean(EXTRA_SIGNATURE_UNKNOWN, true);
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
return returnData;
|
||||
}
|
||||
@ -2020,7 +1974,6 @@ public class Apg {
|
||||
|
||||
returnData.putBoolean(EXTRA_SIGNATURE_SUCCESS, signature.verify());
|
||||
|
||||
if( progress != null )
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
return returnData;
|
||||
}
|
||||
@ -2279,7 +2232,6 @@ public class Apg {
|
||||
int pos = 0;
|
||||
String msg = context.getString(R.string.progress_deletingSecurely, file.getName());
|
||||
while (pos < length) {
|
||||
if( progress != null )
|
||||
progress.setProgress(msg, (int)(100 * pos / length), 100);
|
||||
random.nextBytes(data);
|
||||
raf.write(data);
|
||||
|
Loading…
Reference in New Issue
Block a user