summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2016-05-12 12:33:19 (GMT)
committer Dominik Schürmann <dominik@dominikschuermann.de>2016-05-12 12:33:19 (GMT)
commit664386afece0cfb4d6db214e786406b5ad632da7 (patch)
tree173e834747ff22fedd0d46b55872cd2cebc53bcc
parent5b87b648559b9c6e8dd8096da38cf712e696e4c0 (diff)
downloadopen-keychain-664386afece0cfb4d6db214e786406b5ad632da7.zip
open-keychain-664386afece0cfb4d6db214e786406b5ad632da7.tar.gz
open-keychain-664386afece0cfb4d6db214e786406b5ad632da7.tar.bz2
Revert "Remove non-encrypted backuping"
This reverts commit 5b87b648559b9c6e8dd8096da38cf712e696e4c0.
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java45
1 files changed, 31 insertions, 14 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java
index 1e6de9c..0ea7e7e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BackupOperation.java
@@ -18,6 +18,20 @@
package org.sufficientlysecure.keychain.operations;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Locale;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
@@ -49,17 +63,6 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.util.InputData;
import org.sufficientlysecure.keychain.util.Log;
-import java.io.BufferedOutputStream;
-import java.io.DataOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Locale;
-import java.util.concurrent.atomic.AtomicBoolean;
/**
* An operation class which implements high level backup
@@ -73,7 +76,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
- private static final String[] PROJECTION = new String[]{
+ private static final String[] PROJECTION = new String[] {
KeyRings.MASTER_KEY_ID,
KeyRings.PUBKEY_DATA,
KeyRings.PRIVKEY_DATA,
@@ -112,10 +115,18 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
try {
+ boolean nonEncryptedOutput = cryptoInput == null;
+
Uri plainUri = null;
OutputStream plainOut;
- plainUri = TemporaryFileProvider.createFile(mContext);
- plainOut = mContext.getContentResolver().openOutputStream(plainUri);
+ if (nonEncryptedOutput && backupInput.mOutputUri == null) {
+ plainOut = outputStream;
+ } else if (nonEncryptedOutput) {
+ plainOut = mContext.getContentResolver().openOutputStream(backupInput.mOutputUri);
+ } else {
+ plainUri = TemporaryFileProvider.createFile(mContext);
+ plainOut = mContext.getContentResolver().openOutputStream(plainUri);
+ }
int exportedDataSize;
@@ -131,6 +142,12 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
// if there was an error, it will be in the log so we just have to return
return new ExportResult(ExportResult.RESULT_ERROR, log);
}
+
+ if (nonEncryptedOutput) {
+ // log.add(LogType.MSG_EXPORT_NO_ENCRYPT, 1);
+ log.add(LogType.MSG_BACKUP_SUCCESS, 1);
+ return new ExportResult(ExportResult.RESULT_OK, log);
+ }
}
PgpSignEncryptOperation pseOp = new PgpSignEncryptOperation(mContext, mProviderHelper, mProgressable, mCancelled);