From 83fc9d796f7e69e04971502754b50ff0809e88b5 Mon Sep 17 00:00:00 2001 From: Adithya Abraham Philip Date: Sat, 20 Jun 2015 06:37:00 +0530 Subject: [PATCH] don't check for proxy if offline import --- .../operations/ImportExportOperation.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java index 89ccd89d9..ab6ec40f3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java @@ -641,21 +641,28 @@ public class ImportExportOperation extends BaseOperation { public ImportKeyResult execute(ImportKeyringParcel input, CryptoInputParcel cryptoInput) { Proxy proxy = null; - if (cryptoInput.getParcelableProxy() == null) { - // if a proxy is not specified, we retrieve from preferences - Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(mContext).getProxyPrefs(); + if (!isOfflineImport(input)) { + if (cryptoInput.getParcelableProxy() == null) { + // if a proxy is not specified, we retrieve from preferences + Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(mContext).getProxyPrefs(); - if (proxyPrefs.torEnabled && !OrbotHelper.isOrbotInstalledAndRunning(mContext)) { - // is it okay to pass null for log? - return new ImportKeyResult(null, RequiredInputParcel.createRequiredOrbotEnable()); + if (proxyPrefs.torEnabled && !OrbotHelper.isOrbotInstalledAndRunning(mContext)) { + // is it okay to pass null for log? + return new ImportKeyResult(null, RequiredInputParcel.createRequiredOrbotEnable()); + } + } else { + proxy = cryptoInput.getParcelableProxy().getProxy(); } - } else { - proxy = cryptoInput.getParcelableProxy().getProxy(); } return importKeys(input.mKeyList, input.mKeyserver, proxy); } + // TODO: Verify if this is sufficient to determine offline import + private boolean isOfflineImport(ImportKeyringParcel importParcel) { + return importParcel.mKeyList == null; + } + public ImportKeyResult importKeys(ArrayList keyList, String keyServer, Proxy proxy) { ImportKeyResult result = null;