deal with non-existent user ids during import (#994)
This commit is contained in:
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
@@ -287,7 +288,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
|
||||
// if there was no user id flagged as primary, use the first one
|
||||
if (mPrimaryUserId == null) {
|
||||
mPrimaryUserId = mUserIds.get(0);
|
||||
mPrimaryUserId = context.getString(R.string.user_id_none);
|
||||
}
|
||||
|
||||
mKeyId = key.getKeyId();
|
||||
|
||||
@@ -186,12 +186,14 @@ public class UncachedPublicKey {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns primary user id if existing. If not, return first encountered user id.
|
||||
* Returns primary user id if existing. If not, return first encountered user id. If there
|
||||
* is no user id, return null (this can only happen for not yet canonicalized keys during import)
|
||||
*/
|
||||
public String getPrimaryUserIdWithFallback() {
|
||||
String userId = getPrimaryUserId();
|
||||
if (userId == null) {
|
||||
userId = (String) mPublicKey.getUserIDs().next();
|
||||
Iterator<String> it = mPublicKey.getUserIDs();
|
||||
userId = it.hasNext() ? it.next() : null;
|
||||
}
|
||||
return userId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user