replace calls to getGenericData with getCachedPublicKeyRing equivalents

This commit is contained in:
Vincent Breitmoser
2017-02-20 18:17:15 +01:00
parent 0277ba1afa
commit c2b9af077a
7 changed files with 42 additions and 39 deletions

View File

@@ -25,6 +25,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.provider.DatabaseInteractor.NotFoundException;
@@ -237,4 +238,12 @@ public class CachedPublicKeyRing extends KeyRing {
return SecretKeyType.fromNum(((Long) data).intValue());
}
public byte[] getEncoded() throws PgpKeyNotFoundException {
try {
return (byte[]) mDatabaseInteractor.getGenericData(mUri, KeyRingData.KEY_RING_DATA,
DatabaseInteractor.FIELD_TYPE_BLOB);
} catch(DatabaseReadWriteInteractor.NotFoundException e) {
throw new PgpKeyNotFoundException(e);
}
}
}

View File

@@ -69,7 +69,7 @@ public class DatabaseInteractor {
mLog = new OperationLog();
}
public Object getGenericData(Uri uri, String column, int type) throws NotFoundException {
Object getGenericData(Uri uri, String column, int type) throws NotFoundException {
Object result = getGenericData(uri, new String[]{column}, new int[]{type}, null).get(column);
if (result == null) {
throw new NotFoundException();
@@ -77,17 +77,17 @@ public class DatabaseInteractor {
return result;
}
public Object getGenericData(Uri uri, String column, int type, String selection)
Object getGenericData(Uri uri, String column, int type, String selection)
throws NotFoundException {
return getGenericData(uri, new String[]{column}, new int[]{type}, selection).get(column);
}
public HashMap<String, Object> getGenericData(Uri uri, String[] proj, int[] types)
private HashMap<String, Object> getGenericData(Uri uri, String[] proj, int[] types)
throws NotFoundException {
return getGenericData(uri, proj, types, null);
}
public HashMap<String, Object> getGenericData(Uri uri, String[] proj, int[] types, String selection)
private HashMap<String, Object> getGenericData(Uri uri, String[] proj, int[] types, String selection)
throws NotFoundException {
Cursor cursor = mContentResolver.query(uri, proj, selection, null, null);