incorporate feedback

This commit is contained in:
Vincent Breitmoser
2017-01-04 12:11:13 +01:00
parent 2ed485fd12
commit 27670d55e8

View File

@@ -143,31 +143,35 @@ public class OpenPgpService extends Service {
// try to find the key for this specific email // try to find the key for this specific email
Uri uri = KeyRings.buildUnifiedKeyRingsFindByEmailUri(email); Uri uri = KeyRings.buildUnifiedKeyRingsFindByEmailUri(email);
Cursor cursor = getContentResolver().query(uri, KEY_SEARCH_PROJECTION, KEY_SEARCH_WHERE, null, null); Cursor cursor = getContentResolver().query(uri, KEY_SEARCH_PROJECTION, KEY_SEARCH_WHERE, null, null);
if (cursor == null) {
throw new IllegalStateException("Internal error, received null cursor!");
}
try { try {
// result should be one entry containing the key id // result should be one entry containing the key id
if (cursor != null && cursor.moveToFirst()) { if (cursor.moveToFirst()) {
long id = cursor.getLong(cursor.getColumnIndex(KeyRings.MASTER_KEY_ID)); long id = cursor.getLong(cursor.getColumnIndex(KeyRings.MASTER_KEY_ID));
keyIds.add(id); keyIds.add(id);
// another entry for this email -> two keys with the same email inside user id
if (!cursor.isLast()) {
Log.d(Constants.TAG, "more than one user id with the same email");
duplicateEmails.add(email);
// also pre-select
while (cursor.moveToNext()) {
long duplicateId = cursor.getLong(cursor.getColumnIndex(KeyRings.MASTER_KEY_ID));
keyIds.add(duplicateId);
}
}
} else { } else {
missingEmails.add(email); missingEmails.add(email);
Log.d(Constants.TAG, "user id missing"); Log.d(Constants.TAG, "user id missing");
} }
// another entry for this email -> two keys with the same email inside user id
if (cursor != null && cursor.moveToNext()) {
duplicateEmails.add(email);
// also pre-select
long id = cursor.getLong(cursor.getColumnIndex(KeyRings.MASTER_KEY_ID));
keyIds.add(id);
Log.d(Constants.TAG, "more than one user id with the same email");
}
} finally { } finally {
if (cursor != null) {
cursor.close(); cursor.close();
} }
} }
} }
}
boolean hasMissingUserIds = !missingEmails.isEmpty(); boolean hasMissingUserIds = !missingEmails.isEmpty();
boolean hasDuplicateUserIds = !duplicateEmails.isEmpty(); boolean hasDuplicateUserIds = !duplicateEmails.isEmpty();