Some cleanup in user id loading

This commit is contained in:
Vincent Breitmoser
2018-06-22 13:24:41 +02:00
parent 921431b05f
commit cf0b659e78
9 changed files with 130 additions and 585 deletions

View File

@@ -33,8 +33,10 @@ class AbstractDao {
<T> List<T> mapAllRows(SupportSQLiteQuery query, Mapper<T> mapper) {
ArrayList<T> result = new ArrayList<>();
try (Cursor cursor = getReadableDb().query(query)) {
T item = mapper.map(cursor);
result.add(item);
while (cursor.moveToNext()) {
T item = mapper.map(cursor);
result.add(item);
}
}
return result;
}

View File

@@ -229,18 +229,6 @@ public class KeychainContract {
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
.appendPath(BASE_KEY_RINGS).build();
/**
* Use if multiple items get returned
*/
public static final String CONTENT_TYPE
= "vnd.android.cursor.dir/vnd.org.sufficientlysecure.keychain.provider.user_ids";
/**
* Use if a single item is returned
*/
public static final String CONTENT_ITEM_TYPE
= "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.provider.user_ids";
public static Uri buildUserIdsUri() {
return CONTENT_URI.buildUpon().appendPath(PATH_USER_IDS).build();
}
@@ -248,10 +236,6 @@ public class KeychainContract {
public static Uri buildUserIdsUri(long masterKeyId) {
return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_USER_IDS).build();
}
public static Uri buildUserIdsUri(Uri uri) {
return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_USER_IDS).build();
}
}
public static class Certs implements CertsColumns, BaseColumns {

View File

@@ -177,9 +177,6 @@ public class KeychainProvider extends ContentProvider implements SimpleContentRe
case KEY_RING_KEYS:
return Keys.CONTENT_TYPE;
case KEY_RING_USER_IDS:
return UserPackets.CONTENT_TYPE;
case KEY_SIGNATURES:
return KeySignatures.CONTENT_TYPE;
@@ -466,8 +463,7 @@ public class KeychainProvider extends ContentProvider implements SimpleContentRe
break;
}
case KEY_RINGS_USER_IDS:
case KEY_RING_USER_IDS: {
case KEY_RINGS_USER_IDS: {
HashMap<String, String> projectionMap = new HashMap<>();
projectionMap.put(UserPackets._ID, Tables.USER_PACKETS + ".oid AS _id");
projectionMap.put(UserPackets.MASTER_KEY_ID, Tables.USER_PACKETS + "." + UserPackets.MASTER_KEY_ID);
@@ -497,13 +493,6 @@ public class KeychainProvider extends ContentProvider implements SimpleContentRe
qb.appendWhere(Tables.USER_PACKETS + "." + UserPackets.TYPE + " IS NULL");
// If we are searching for a particular keyring's ids, add where
if (match == KEY_RING_USER_IDS) {
qb.appendWhere(" AND ");
qb.appendWhere(Tables.USER_PACKETS + "." + UserPackets.MASTER_KEY_ID + " = ");
qb.appendWhereEscapeString(uri.getPathSegments().get(1));
}
if (TextUtils.isEmpty(sortOrder)) {
sortOrder = Tables.USER_PACKETS + "." + UserPackets.MASTER_KEY_ID + " ASC"
+ "," + Tables.USER_PACKETS + "." + UserPackets.RANK + " ASC";