Added ascii armor option to the backup api

This commit is contained in:
Hari
2017-01-29 22:14:54 +05:30
parent 146833916b
commit 28bf1a37a1
5 changed files with 19 additions and 16 deletions

View File

@@ -174,7 +174,7 @@ public class BackupOperation extends BaseOperation<BackupKeyringParcel> {
PgpSignEncryptData data = new PgpSignEncryptData();
data.setSymmetricPassphrase(cryptoInput.getPassphrase());
data.setEnableAsciiArmorOutput(true);
data.setEnableAsciiArmorOutput(backupInput.mEnableAsciiArmorOutput);
data.setAddBackupHeader(true);
PgpSignEncryptInputParcel inputParcel = new PgpSignEncryptInputParcel(data);

View File

@@ -615,6 +615,7 @@ public class OpenPgpService extends Service {
try {
long[] masterKeyIds = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS);
boolean backupSecret = data.getBooleanExtra(OpenPgpApi.EXTRA_BACKUP_SECRET, false);
boolean enableAsciiArmorOutput = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
if (inputParcel == null) {
@@ -626,7 +627,7 @@ public class OpenPgpService extends Service {
// after user interaction with RemoteBackupActivity,
// the backup code is cached in CryptoInputParcelCacheService, now we can proceed
BackupKeyringParcel input = new BackupKeyringParcel(masterKeyIds, backupSecret, true, null);
BackupKeyringParcel input = new BackupKeyringParcel(masterKeyIds, backupSecret, true, enableAsciiArmorOutput, null);
BackupOperation op = new BackupOperation(this, mProviderHelper, null);
ExportResult pgpResult = op.execute(input, inputParcel, outputStream);

View File

@@ -23,22 +23,22 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import org.sufficientlysecure.keychain.util.Passphrase;
public class BackupKeyringParcel implements Parcelable {
public Uri mCanonicalizedPublicKeyringUri;
public final boolean mExportSecret;
public final boolean mIsEncrypted;
public final boolean mEnableAsciiArmorOutput;
public final long mMasterKeyIds[];
public final Uri mOutputUri;
public BackupKeyringParcel(long[] masterKeyIds, boolean exportSecret, boolean isEncrypted, Uri outputUri) {
public BackupKeyringParcel(long[] masterKeyIds, boolean exportSecret, boolean isEncrypted, boolean enableAsciiArmorOutput, Uri outputUri) {
mMasterKeyIds = masterKeyIds;
mExportSecret = exportSecret;
mOutputUri = outputUri;
mIsEncrypted = isEncrypted;
mEnableAsciiArmorOutput = enableAsciiArmorOutput;
}
protected BackupKeyringParcel(Parcel in) {
@@ -47,6 +47,7 @@ public class BackupKeyringParcel implements Parcelable {
mOutputUri = (Uri) in.readValue(Uri.class.getClassLoader());
mMasterKeyIds = in.createLongArray();
mIsEncrypted = in.readInt() != 0;
mEnableAsciiArmorOutput = in.readInt() != 0;
}
@Override
@@ -61,6 +62,7 @@ public class BackupKeyringParcel implements Parcelable {
dest.writeValue(mOutputUri);
dest.writeLongArray(mMasterKeyIds);
dest.writeInt(mIsEncrypted ? 1 : 0);
dest.writeInt(mEnableAsciiArmorOutput ? 1 : 0);
}
public static final Parcelable.Creator<BackupKeyringParcel> CREATOR = new Parcelable.Creator<BackupKeyringParcel>() {

View File

@@ -605,7 +605,7 @@ public class BackupCodeFragment extends CryptoOperationFragment<BackupKeyringPar
@Nullable
@Override
public BackupKeyringParcel createOperationInput() {
return new BackupKeyringParcel(mMasterKeyIds, mExportSecret, true, mCachedBackupUri);
return new BackupKeyringParcel(mMasterKeyIds, mExportSecret, true, true, mCachedBackupUri);
}
@Override