From 8178c4eb0db7f1d9a56855f9c94f4e642536a8c4 Mon Sep 17 00:00:00 2001 From: Adithya Abraham Philip Date: Fri, 19 Jun 2015 19:09:51 +0530 Subject: [PATCH] shifted multi-threading logic to ImportExportOperation from KeychainService --- .../operations/ImportExportOperation.java | 253 ++++++++++++++++-- .../keychain/provider/ProviderHelper.java | 4 +- .../keychain/service/KeychainService.java | 252 +---------------- 3 files changed, 245 insertions(+), 264 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 6234c0c9c..c83cea885 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java @@ -30,12 +30,9 @@ import org.sufficientlysecure.keychain.keyimport.KeybaseKeyserver; import org.sufficientlysecure.keychain.keyimport.Keyserver; import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException; import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; -import org.sufficientlysecure.keychain.operations.results.ConsolidateResult; -import org.sufficientlysecure.keychain.operations.results.ExportResult; -import org.sufficientlysecure.keychain.operations.results.ImportKeyResult; +import org.sufficientlysecure.keychain.operations.results.*; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; -import org.sufficientlysecure.keychain.operations.results.SaveKeyringResult; import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing; import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing; import org.sufficientlysecure.keychain.pgp.Progressable; @@ -44,12 +41,10 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.service.ContactSyncAdapterService; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.FileHelper; -import org.sufficientlysecure.keychain.util.Log; -import org.sufficientlysecure.keychain.util.ParcelableFileCache; +import org.sufficientlysecure.keychain.util.*; import org.sufficientlysecure.keychain.util.ParcelableFileCache.IteratorWithSize; -import org.sufficientlysecure.keychain.util.ProgressScaler; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; @@ -60,8 +55,10 @@ import java.io.IOException; import java.io.OutputStream; import java.net.Proxy; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -143,24 +140,40 @@ public class ImportExportOperation extends BaseOperation { } } - public ImportKeyResult importKeyRings(List entries, String keyServerUri, Proxy proxy) { + // Overloaded functions for using progressable supplied in constructor during import + public ImportKeyResult serialKeyRingImport(Iterator entries, int num, String keyServerUri, + Proxy proxy) { + return serialKeyRingImport(entries, num, keyServerUri, proxy, mProgressable); + } + + public ImportKeyResult serialKeyRingImport(List entries, String keyServerUri, Proxy proxy) { Iterator it = entries.iterator(); int numEntries = entries.size(); - return importKeyRings(it, numEntries, keyServerUri, proxy); + return serialKeyRingImport(it, numEntries, keyServerUri, proxy, mProgressable); } - public ImportKeyResult importKeyRings(ParcelableFileCache cache, String keyServerUri, - Proxy proxy) { + public ImportKeyResult serialKeyRingImport(List entries, String keyServerUri, Proxy proxy, + Progressable progressable) { + + Iterator it = entries.iterator(); + int numEntries = entries.size(); + + return serialKeyRingImport(it, numEntries, keyServerUri, proxy, progressable); + + } + + public ImportKeyResult serialKeyRingImport(ParcelableFileCache cache, String keyServerUri, + Proxy proxy) { // get entries from cached file try { IteratorWithSize it = cache.readCache(); int numEntries = it.getSize(); - return importKeyRings(it, numEntries, keyServerUri, proxy); + return serialKeyRingImport(it, numEntries, keyServerUri, proxy, mProgressable); } catch (IOException e) { // Special treatment here, we need a lot @@ -180,10 +193,12 @@ public class ImportExportOperation extends BaseOperation { * @param entries keys to import * @param num number of keys to import * @param keyServerUri contains uri of keyserver to import from, if it is an import from cloud + * @param progressable Allows multi-threaded import to supply a progressable that ignores the progress of a single + * key being imported * @return */ - public ImportKeyResult importKeyRings(Iterator entries, int num, String keyServerUri, - Proxy proxy) { + public ImportKeyResult serialKeyRingImport(Iterator entries, int num, String keyServerUri, + Proxy proxy, Progressable progressable) { updateProgress(R.string.progress_importing, 0, 100); OperationLog log = new OperationLog(); @@ -321,11 +336,11 @@ public class ImportExportOperation extends BaseOperation { mProviderHelper.clearLog(); if (key.isSecret()) { result = mProviderHelper.saveSecretKeyRing(key, - new ProgressScaler(mProgressable, (int) (position * progSteps), (int) ((position + 1) * + new ProgressScaler(progressable, (int) (position * progSteps), (int) ((position + 1) * progSteps), 100)); } else { result = mProviderHelper.savePublicKeyRing(key, - new ProgressScaler(mProgressable, (int) (position * progSteps), (int) ((position + 1) * + new ProgressScaler(progressable, (int) (position * progSteps), (int) ((position + 1) * progSteps), 100)); } if (!result.success()) { @@ -354,7 +369,7 @@ public class ImportExportOperation extends BaseOperation { // Special: consolidate on secret key import (cannot be cancelled!) if (secret > 0) { setPreventCancel(); - ConsolidateResult result = mProviderHelper.consolidateDatabaseStep1(mProgressable); + ConsolidateResult result = mProviderHelper.consolidateDatabaseStep1(progressable); log.add(result, 1); } @@ -607,4 +622,206 @@ public class ImportExportOperation extends BaseOperation { } + public ImportKeyResult importKeys(ArrayList keyList, String keyServer, Context context) { + Preferences.ProxyPrefs proxyPrefs = Preferences.getPreferences(context).getProxyPrefs(); + + Proxy proxy = proxyPrefs.parcelableProxy.getProxy(); + + ImportKeyResult result = null; + + if (keyList == null) {// import from file, do serially + ParcelableFileCache cache = new ParcelableFileCache<>(context, "key_import.pcl"); + + result = serialKeyRingImport(cache, keyServer, proxy); + } else { + // if there is more than one key with the same fingerprint, we do a serial import to prevent + // https://github.com/open-keychain/open-keychain/issues/1221 + HashSet keyFingerprintSet = new HashSet<>(); + for (int i = 0; i < keyList.size(); i++) { + keyFingerprintSet.add(keyList.get(i).mExpectedFingerprint); + } + if (keyFingerprintSet.size() == keyList.size()) { + // all keys have unique fingerprints + result = multiThreadedKeyImport(keyList.iterator(), keyList.size(), keyServer, proxy); + } else { + result = serialKeyRingImport(keyList, keyServer, proxy); + } + } + + ContactSyncAdapterService.requestSync(); + return result; + } + + private ImportKeyResult multiThreadedKeyImport(Iterator keyListIterator, int totKeys, + final String keyServer, final Proxy proxy) { + Log.d(Constants.TAG, "Multi-threaded key import starting"); + if (keyListIterator != null) { + KeyImportAccumulator accumulator = new KeyImportAccumulator(totKeys, mProgressable); + + final Progressable ignoreProgressable = new Progressable() { + @Override + public void setProgress(String message, int current, int total) { + + } + + @Override + public void setProgress(int resourceId, int current, int total) { + + } + + @Override + public void setProgress(int current, int total) { + + } + + @Override + public void setPreventCancel() { + + } + }; + + + final int maxThreads = 200; + ExecutorService importExecutor = new ThreadPoolExecutor(0, maxThreads, + 30L, TimeUnit.SECONDS, + new SynchronousQueue()); + + ExecutorCompletionService importCompletionService = + new ExecutorCompletionService(importExecutor); + + while (keyListIterator.hasNext()) { // submit all key rings to be imported + + final ParcelableKeyRing pkRing = keyListIterator.next(); + + Callable importOperationCallable = new Callable() { + + @Override + public ImportKeyResult call() { + + ArrayList list = new ArrayList<>(); + list.add(pkRing); + + return serialKeyRingImport(list, keyServer, proxy, ignoreProgressable); + } + }; + + importCompletionService.submit(importOperationCallable); + } + + while (!accumulator.isImportFinished()) { // accumulate the results of each import + try { + accumulator.accumulateKeyImport(importCompletionService.take().get()); + } catch (InterruptedException | ExecutionException e) { + Log.e(Constants.TAG, "A key could not be imported during multi-threaded import", e); + // do nothing? + if (e instanceof ExecutionException) { + // Since serialKeyRingImport does not throw any exceptions, this is what would have happened if + // we were importing the key on this thread + throw new RuntimeException(); + } + } + } + return accumulator.getConsolidatedResult(); + } + return null; // TODO: Decide if we should just crash instead of returning null + } + + /** + * Used to accumulate the results of individual key imports + */ + private class KeyImportAccumulator { + private OperationResult.OperationLog mImportLog = new OperationResult.OperationLog(); + Progressable mProgressable; + private int mTotalKeys; + private int mImportedKeys = 0; + ArrayList mImportedMasterKeyIds = new ArrayList(); + private int mBadKeys = 0; + private int mNewKeys = 0; + private int mUpdatedKeys = 0; + private int mSecret = 0; + private int mResultType = 0; + + /** + * Accumulates keyring imports and updates the progressable whenever a new key is imported. + * Also sets the progress to 0 on instantiation. + * + * @param totalKeys total number of keys to be imported + * @param externalProgressable the external progressable to be updated every time a key is imported + */ + public KeyImportAccumulator(int totalKeys, Progressable externalProgressable) { + mTotalKeys = totalKeys; + mProgressable = externalProgressable; + mProgressable.setProgress(0, totalKeys); + } + + public int getTotalKeys() { + return mTotalKeys; + } + + public int getImportedKeys() { + return mImportedKeys; + } + + public synchronized void accumulateKeyImport(ImportKeyResult result) { + mImportedKeys++; + + mProgressable.setProgress(mImportedKeys, mTotalKeys); + + mImportLog.addAll(result.getLog().toList());//accumulates log + mBadKeys += result.mBadKeys; + mNewKeys += result.mNewKeys; + mUpdatedKeys += result.mUpdatedKeys; + mSecret += result.mSecret; + + long[] masterKeyIds = result.getImportedMasterKeyIds(); + for (long masterKeyId : masterKeyIds) { + mImportedMasterKeyIds.add(masterKeyId); + } + + // if any key import has been cancelled, set result type to cancelled + // resultType is added to in getConsolidatedKayImport to account for remaining factors + mResultType |= result.getResult() & ImportKeyResult.RESULT_CANCELLED; + } + + /** + * returns accumulated result of all imports so far + */ + public ImportKeyResult getConsolidatedResult() { + + // adding required information to mResultType + // special case,no keys requested for import + if (mBadKeys == 0 && mNewKeys == 0 && mUpdatedKeys == 0) { + mResultType = ImportKeyResult.RESULT_FAIL_NOTHING; + } else { + if (mNewKeys > 0) { + mResultType |= ImportKeyResult.RESULT_OK_NEWKEYS; + } + if (mUpdatedKeys > 0) { + mResultType |= ImportKeyResult.RESULT_OK_UPDATED; + } + if (mBadKeys > 0) { + mResultType |= ImportKeyResult.RESULT_WITH_ERRORS; + if (mNewKeys == 0 && mUpdatedKeys == 0) { + mResultType |= ImportKeyResult.RESULT_ERROR; + } + } + if (mImportLog.containsWarnings()) { + mResultType |= ImportKeyResult.RESULT_WARNINGS; + } + } + + long masterKeyIds[] = new long[mImportedMasterKeyIds.size()]; + for (int i = 0; i < masterKeyIds.length; i++) { + masterKeyIds[i] = mImportedMasterKeyIds.get(i); + } + + return new ImportKeyResult(mResultType, mImportLog, mNewKeys, mUpdatedKeys, mBadKeys, + mSecret, masterKeyIds); + } + + public boolean isImportFinished() { + return mTotalKeys == mImportedKeys; + } + } + } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 98b6c99d9..a9cf172fa 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -1252,7 +1252,7 @@ public class ProviderHelper { ImportKeyResult result = new ImportExportOperation(mContext, this, new ProgressFixedScaler(progress, 10, 25, 100, R.string.progress_con_reimport)) - .importKeyRings(itSecrets, numSecrets, null, null); + .serialKeyRingImport(itSecrets, numSecrets, null, null); log.add(result, indent); } else { log.add(LogType.MSG_CON_REIMPORT_SECRET_SKIP, indent); @@ -1280,7 +1280,7 @@ public class ProviderHelper { ImportKeyResult result = new ImportExportOperation(mContext, this, new ProgressFixedScaler(progress, 25, 99, 100, R.string.progress_con_reimport)) - .importKeyRings(itPublics, numPublics, null, null); + .serialKeyRingImport(itPublics, numPublics, null, null); log.add(result, indent); } else { log.add(LogType.MSG_CON_REIMPORT_PUBLIC_SKIP, indent); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java index f31a0faae..b36d31be0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainService.java @@ -58,19 +58,12 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; import org.sufficientlysecure.keychain.service.ServiceProgressHandler.MessageStatus; import org.sufficientlysecure.keychain.util.Log; -import org.sufficientlysecure.keychain.util.ParcelableFileCache; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.net.Proxy; import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import de.measite.minidns.Client; @@ -80,7 +73,6 @@ import de.measite.minidns.Record; import de.measite.minidns.record.Data; import de.measite.minidns.record.TXT; import org.sufficientlysecure.keychain.util.ParcelableProxy; -import org.sufficientlysecure.keychain.util.Preferences; /** * This Service contains all important long lasting operations for OpenKeychain. It receives Intents with @@ -156,9 +148,6 @@ public class KeychainService extends Service implements Progressable { // this attribute can possibly merged with the one above? not sure... private AtomicBoolean mActionCanceled = new AtomicBoolean(false); - - private KeyImportAccumulator mKeyImportAccumulator; - @Override public IBinder onBind(Intent intent) { return null; @@ -401,25 +390,14 @@ public class KeychainService extends Service implements Progressable { // Input String keyServer = data.getString(IMPORT_KEY_SERVER); ArrayList keyList = data.getParcelableArrayList(IMPORT_KEY_LIST); - Proxy proxy = getProxyFromBundle(data); - // either keyList or cache must be null, no guarantees otherwise - if (keyList == null) {// import from file, do serially - serialKeyImport(null, keyServer, providerHelper, proxy); - } else { - // if there is more than one key with the same fingerprint, we do a serial import to prevent - // https://github.com/open-keychain/open-keychain/issues/1221 - HashSet keyFingerprintSet = new HashSet<>(); - for (int i = 0; i < keyList.size(); i++) { - keyFingerprintSet.add(keyList.get(i).mExpectedFingerprint); - } - if (keyFingerprintSet.size() == keyList.size()) { - // all keys have unique fingerprints - multiThreadedKeyImport(keyList.iterator(), keyList.size(), keyServer, proxy); - } else { - serialKeyImport(keyList, keyServer, providerHelper, proxy); - } - } + ImportExportOperation importExportOperation = new ImportExportOperation(KeychainService.this, + providerHelper, KeychainService.this, mActionCanceled); + + ImportKeyResult result = + importExportOperation.importKeys(keyList, keyServer, KeychainService.this); + + sendMessageToHandler(MessageStatus.OKAY, result); break; } @@ -450,10 +428,7 @@ public class KeychainService extends Service implements Progressable { break; } } - if (!intent.getAction().equals(ACTION_IMPORT_KEYRING)) { - // import keyring handles stopping service on its own - stopSelf(); - } + stopSelf(); } }; @@ -568,215 +543,4 @@ public class KeychainService extends Service implements Progressable { public void setPreventCancel() { sendMessageToHandler(MessageStatus.PREVENT_CANCEL); } - - public void serialKeyImport(ArrayList keyList, final String keyServer, - ProviderHelper providerHelper, Proxy proxy) { - Log.d(Constants.TAG, "serial key import starting"); - ParcelableFileCache cache = - new ParcelableFileCache<>(KeychainService.this, "key_import.pcl"); - - // Operation - ImportExportOperation importExportOperation = new ImportExportOperation( - KeychainService.this, providerHelper, KeychainService.this, - mActionCanceled); - // Either list or cache must be null, no guarantees otherwise. - ImportKeyResult result = keyList != null - ? importExportOperation.importKeyRings(keyList, keyServer, proxy) - : importExportOperation.importKeyRings(cache, keyServer, proxy); - - ContactSyncAdapterService.requestSync(); - // Result - sendMessageToHandler(MessageStatus.OKAY, result); - - stopSelf(); - } - - public void multiThreadedKeyImport(Iterator keyListIterator, int totKeys, final String - keyServer, final Proxy proxy) { - Log.d(Constants.TAG, "Multi-threaded key import starting"); - if (keyListIterator != null) { - mKeyImportAccumulator = new KeyImportAccumulator(totKeys, KeychainService.this); - setProgress(0, totKeys); - - final int maxThreads = 200; - ExecutorService importExecutor = new ThreadPoolExecutor(0, maxThreads, - 30L, TimeUnit.SECONDS, - new SynchronousQueue()); - - while (keyListIterator.hasNext()) { - - final ParcelableKeyRing pkRing = keyListIterator.next(); - - Runnable importOperationRunnable = new Runnable() { - - @Override - public void run() { - ImportKeyResult result = null; - try { - ImportExportOperation importExportOperation = new ImportExportOperation( - KeychainService.this, - new ProviderHelper(KeychainService.this), - mKeyImportAccumulator.getImportProgressable(), - mActionCanceled); - - ArrayList list = new ArrayList<>(); - list.add(pkRing); - - result = importExportOperation.importKeyRings(list, - keyServer, proxy); - } finally { - // in the off-chance that importKeyRings does something to crash the - // thread before it can call singleKeyRingImportCompleted, our imported - // key count will go wrong. This will cause the service to never die, - // and the progress dialog to stay displayed. The finally block was - // originally meant to ensure singleKeyRingImportCompleted was called, - // and checks for null were to be introduced, but in such a scenario, - // knowing an uncaught error exists in importKeyRings is more important. - - // if a null gets passed, something wrong is happening. We want a crash. - - mKeyImportAccumulator.singleKeyRingImportCompleted(result); - } - } - }; - - importExecutor.execute(importOperationRunnable); - } - } - } - - /** - * Used to accumulate the results of individual key imports - */ - private class KeyImportAccumulator { - private OperationResult.OperationLog mImportLog = new OperationResult.OperationLog(); - private int mTotalKeys; - private int mImportedKeys = 0; - private Progressable mInternalProgressable; - ArrayList mImportedMasterKeyIds = new ArrayList(); - private int mBadKeys = 0; - private int mNewKeys = 0; - private int mUpdatedKeys = 0; - private int mSecret = 0; - private int mResultType = 0; - - /** - * meant to be used with a service due to stopSelf() in singleKeyRingImportCompleted. Remove this if - * generalising. - * - * @param totalKeys total number of keys to be imported - * @param externalProgressable the external progressable to be updated every time a key is imported - */ - public KeyImportAccumulator(int totalKeys, Progressable externalProgressable) { - mTotalKeys = totalKeys; - // ignore updates from ImportExportOperation for now - mInternalProgressable = new Progressable() { - @Override - public void setProgress(String message, int current, int total) { - - } - - @Override - public void setProgress(int resourceId, int current, int total) { - - } - - @Override - public void setProgress(int current, int total) { - - } - - @Override - public void setPreventCancel() { - - } - }; - } - - private synchronized void singleKeyRingImportCompleted(ImportKeyResult result) { - // increase imported key count and accumulate log and bad, new etc. key counts from result - mKeyImportAccumulator.accumulateKeyImport(result); - - setProgress(mKeyImportAccumulator.getImportedKeys(), mKeyImportAccumulator.getTotalKeys()); - - if (mKeyImportAccumulator.isImportFinished()) { - ContactSyncAdapterService.requestSync(); - - sendMessageToHandler(ServiceProgressHandler.MessageStatus.OKAY, - mKeyImportAccumulator.getConsolidatedImportKeyResult()); - - stopSelf();//we're done here - } - } - - public Progressable getImportProgressable() { - return mInternalProgressable; - } - - public int getTotalKeys() { - return mTotalKeys; - } - - public int getImportedKeys() { - return mImportedKeys; - } - - public synchronized void accumulateKeyImport(ImportKeyResult result) { - mImportedKeys++; - mImportLog.addAll(result.getLog().toList());//accumulates log - mBadKeys += result.mBadKeys; - mNewKeys += result.mNewKeys; - mUpdatedKeys += result.mUpdatedKeys; - mSecret += result.mSecret; - - long[] masterKeyIds = result.getImportedMasterKeyIds(); - for (long masterKeyId : masterKeyIds) { - mImportedMasterKeyIds.add(masterKeyId); - } - - // if any key import has been cancelled, set result type to cancelled - // resultType is added to in getConsolidatedKayImport to account for remaining factors - mResultType |= result.getResult() & ImportKeyResult.RESULT_CANCELLED; - } - - /** - * returns accumulated result of all imports so far - */ - public ImportKeyResult getConsolidatedImportKeyResult() { - - // adding required information to mResultType - // special case,no keys requested for import - if (mBadKeys == 0 && mNewKeys == 0 && mUpdatedKeys == 0) { - mResultType = ImportKeyResult.RESULT_FAIL_NOTHING; - } else { - if (mNewKeys > 0) { - mResultType |= ImportKeyResult.RESULT_OK_NEWKEYS; - } - if (mUpdatedKeys > 0) { - mResultType |= ImportKeyResult.RESULT_OK_UPDATED; - } - if (mBadKeys > 0) { - mResultType |= ImportKeyResult.RESULT_WITH_ERRORS; - if (mNewKeys == 0 && mUpdatedKeys == 0) { - mResultType |= ImportKeyResult.RESULT_ERROR; - } - } - if (mImportLog.containsWarnings()) { - mResultType |= ImportKeyResult.RESULT_WARNINGS; - } - } - - long masterKeyIds[] = new long[mImportedMasterKeyIds.size()]; - for (int i = 0; i < masterKeyIds.length; i++) { - masterKeyIds[i] = mImportedMasterKeyIds.get(i); - } - - return new ImportKeyResult(mResultType, mImportLog, mNewKeys, mUpdatedKeys, mBadKeys, - mSecret, masterKeyIds); - } - - public boolean isImportFinished() { - return mTotalKeys == mImportedKeys; - } - } }