Get rid of more places where URIs are used for loading

This commit is contained in:
Vincent Breitmoser
2018-06-25 17:38:26 +02:00
parent 1425f34321
commit 4416ddf11c
15 changed files with 86 additions and 243 deletions

View File

@@ -627,10 +627,7 @@ public class OpenPgpService extends Service {
}
try {
// try to find key, throws NotFoundException if not in db!
CanonicalizedPublicKeyRing keyRing =
mKeyRepository.getCanonicalizedPublicKeyRing(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(masterKeyId));
CanonicalizedPublicKeyRing keyRing = mKeyRepository.getCanonicalizedPublicKeyRing(masterKeyId);
Intent result = new Intent();
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);

View File

@@ -33,7 +33,6 @@ import org.sufficientlysecure.keychain.provider.ApiAppDao;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.remote.ApiPermissionHelper;
import org.sufficientlysecure.keychain.remote.ApiPermissionHelper.WrongPackageCertificateException;
import timber.log.Timber;
@@ -118,9 +117,11 @@ class RequestKeyPermissionPresenter {
CachedPublicKeyRing publicFallbackRing = null;
for (long candidateSubKeyId : subKeyIds) {
try {
CachedPublicKeyRing cachedPublicKeyRing = keyRepository.getCachedPublicKeyRing(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(candidateSubKeyId)
);
Long masterKeyId = keyRepository.getMasterKeyIdBySubkeyId(candidateSubKeyId);
if (masterKeyId == null) {
continue;
}
CachedPublicKeyRing cachedPublicKeyRing = keyRepository.getCachedPublicKeyRing(masterKeyId);
SecretKeyType secretKeyType = cachedPublicKeyRing.getSecretKeyType(candidateSubKeyId);
if (secretKeyType.isUsable()) {
@@ -129,7 +130,7 @@ class RequestKeyPermissionPresenter {
if (publicFallbackRing == null) {
publicFallbackRing = cachedPublicKeyRing;
}
} catch (PgpKeyNotFoundException | NotFoundException e) {
} catch (NotFoundException e) {
// no matter
}
}