mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-02 05:22:18 -05:00
Fix import of keyring with pub+sec key with same key id
This commit is contained in:
parent
d2998ea80d
commit
a45aaa2277
@ -131,20 +131,17 @@ public class CloudImportService extends Service implements Progressable {
|
|||||||
mSecret += result.mSecret;
|
mSecret += result.mSecret;
|
||||||
|
|
||||||
long[] masterKeyIds = result.getImportedMasterKeyIds();
|
long[] masterKeyIds = result.getImportedMasterKeyIds();
|
||||||
for (int i = 0; i < masterKeyIds.length; i++) {
|
for (long masterKeyId : masterKeyIds) {
|
||||||
mImportedMasterKeyIds.add(masterKeyIds[i]);
|
mImportedMasterKeyIds.add(masterKeyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if any key import has been cancelled, set result type to cancelled
|
// if any key import has been cancelled, set result type to cancelled
|
||||||
// resultType is added to in getConsolidatedKayImport to account for remaining factors
|
// resultType is added to in getConsolidatedKayImport to account for remaining factors
|
||||||
mResultType |= result.getResult() & ImportKeyResult.RESULT_CANCELLED;
|
mResultType |= result.getResult() & ImportKeyResult.RESULT_CANCELLED;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns accumulated result of all imports so far
|
* returns accumulated result of all imports so far
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public ImportKeyResult getConsolidatedImportKeyResult() {
|
public ImportKeyResult getConsolidatedImportKeyResult() {
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
|||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||||
import org.sufficientlysecure.keychain.service.CloudImportService;
|
import org.sufficientlysecure.keychain.service.CloudImportService;
|
||||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
||||||
@ -345,22 +346,8 @@ public class ImportKeysActivity extends BaseNfcActivity {
|
|||||||
mListFragment.loadNew(loaderState);
|
mListFragment.loadNew(loaderState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void handleMessage(Message message) {
|
||||||
* Import keys with mImportData
|
if (message.arg1 == ServiceProgressHandler.MessageStatus.OKAY.ordinal()) {
|
||||||
*/
|
|
||||||
public void importKeys() {
|
|
||||||
// Message is received after importing is done in CloudImportService
|
|
||||||
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
|
|
||||||
this,
|
|
||||||
getString(R.string.progress_importing),
|
|
||||||
ProgressDialog.STYLE_HORIZONTAL,
|
|
||||||
true,
|
|
||||||
ProgressDialogFragment.ServiceType.CLOUD_IMPORT) {
|
|
||||||
public void handleMessage(Message message) {
|
|
||||||
// handle messages by standard KeychainIntentServiceHandler first
|
|
||||||
super.handleMessage(message);
|
|
||||||
|
|
||||||
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
|
|
||||||
// get returned data bundle
|
// get returned data bundle
|
||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
if (returnData == null) {
|
if (returnData == null) {
|
||||||
@ -391,14 +378,34 @@ public class ImportKeysActivity extends BaseNfcActivity {
|
|||||||
.show((ViewGroup) findViewById(R.id.import_snackbar));
|
.show((ViewGroup) findViewById(R.id.import_snackbar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import keys with mImportData
|
||||||
|
*/
|
||||||
|
public void importKeys() {
|
||||||
ImportKeysListFragment.LoaderState ls = mListFragment.getLoaderState();
|
ImportKeysListFragment.LoaderState ls = mListFragment.getLoaderState();
|
||||||
if (ls instanceof ImportKeysListFragment.BytesLoaderState) {
|
if (ls instanceof ImportKeysListFragment.BytesLoaderState) {
|
||||||
Log.d(Constants.TAG, "importKeys started");
|
Log.d(Constants.TAG, "importKeys started");
|
||||||
|
|
||||||
|
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
|
||||||
|
this,
|
||||||
|
getString(R.string.progress_importing),
|
||||||
|
ProgressDialog.STYLE_HORIZONTAL,
|
||||||
|
true,
|
||||||
|
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
|
||||||
|
public void handleMessage(Message message) {
|
||||||
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
|
super.handleMessage(message);
|
||||||
|
|
||||||
|
ImportKeysActivity.this.handleMessage(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: Currently not using CloudImport here due to https://github.com/open-keychain/open-keychain/issues/1221
|
||||||
// Send all information needed to service to import key in other thread
|
// Send all information needed to service to import key in other thread
|
||||||
Intent intent = new Intent(this, CloudImportService.class);
|
Intent intent = new Intent(this, KeychainIntentService.class);
|
||||||
|
|
||||||
|
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING);
|
||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
@ -416,14 +423,14 @@ public class ImportKeysActivity extends BaseNfcActivity {
|
|||||||
new ParcelableFileCache<>(this, "key_import.pcl");
|
new ParcelableFileCache<>(this, "key_import.pcl");
|
||||||
cache.writeCache(selectedEntries);
|
cache.writeCache(selectedEntries);
|
||||||
|
|
||||||
intent.putExtra(CloudImportService.EXTRA_DATA, data);
|
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
// Create a new Messenger for the communication back
|
// Create a new Messenger for the communication back
|
||||||
Messenger messenger = new Messenger(saveHandler);
|
Messenger messenger = new Messenger(serviceHandler);
|
||||||
intent.putExtra(CloudImportService.EXTRA_MESSENGER, messenger);
|
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
|
||||||
|
|
||||||
// show progress dialog
|
// show progress dialog
|
||||||
saveHandler.showProgressDialog(this);
|
serviceHandler.showProgressDialog(this);
|
||||||
|
|
||||||
// start service with intent
|
// start service with intent
|
||||||
startService(intent);
|
startService(intent);
|
||||||
@ -435,6 +442,20 @@ public class ImportKeysActivity extends BaseNfcActivity {
|
|||||||
} else if (ls instanceof ImportKeysListFragment.CloudLoaderState) {
|
} else if (ls instanceof ImportKeysListFragment.CloudLoaderState) {
|
||||||
ImportKeysListFragment.CloudLoaderState sls = (ImportKeysListFragment.CloudLoaderState) ls;
|
ImportKeysListFragment.CloudLoaderState sls = (ImportKeysListFragment.CloudLoaderState) ls;
|
||||||
|
|
||||||
|
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
|
||||||
|
this,
|
||||||
|
getString(R.string.progress_importing),
|
||||||
|
ProgressDialog.STYLE_HORIZONTAL,
|
||||||
|
true,
|
||||||
|
ProgressDialogFragment.ServiceType.CLOUD_IMPORT) {
|
||||||
|
public void handleMessage(Message message) {
|
||||||
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
|
super.handleMessage(message);
|
||||||
|
|
||||||
|
ImportKeysActivity.this.handleMessage(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Send all information needed to service to query keys in other thread
|
// Send all information needed to service to query keys in other thread
|
||||||
Intent intent = new Intent(this, CloudImportService.class);
|
Intent intent = new Intent(this, CloudImportService.class);
|
||||||
|
|
||||||
@ -459,11 +480,11 @@ public class ImportKeysActivity extends BaseNfcActivity {
|
|||||||
intent.putExtra(CloudImportService.EXTRA_DATA, data);
|
intent.putExtra(CloudImportService.EXTRA_DATA, data);
|
||||||
|
|
||||||
// Create a new Messenger for the communication back
|
// Create a new Messenger for the communication back
|
||||||
Messenger messenger = new Messenger(saveHandler);
|
Messenger messenger = new Messenger(serviceHandler);
|
||||||
intent.putExtra(CloudImportService.EXTRA_MESSENGER, messenger);
|
intent.putExtra(CloudImportService.EXTRA_MESSENGER, messenger);
|
||||||
|
|
||||||
// show progress dialog
|
// show progress dialog
|
||||||
saveHandler.showProgressDialog(this);
|
serviceHandler.showProgressDialog(this);
|
||||||
|
|
||||||
// start service with intent
|
// start service with intent
|
||||||
startService(intent);
|
startService(intent);
|
||||||
|
Loading…
Reference in New Issue
Block a user