some fixes for last updated times
This commit is contained in:
parent
57a4cecbfb
commit
03cbc36e23
|
@ -41,6 +41,7 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeyRepository.NotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
|
||||
import org.sufficientlysecure.keychain.provider.LastUpdateInteractor;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||
import org.sufficientlysecure.keychain.service.ContactSyncAdapterService;
|
||||
|
@ -61,10 +62,13 @@ import org.sufficientlysecure.keychain.util.Passphrase;
|
|||
* @see CertifyActionsParcel
|
||||
*/
|
||||
public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParcel> {
|
||||
private final LastUpdateInteractor lastUpdateInteractor;
|
||||
|
||||
public CertifyOperation(Context context, KeyWritableRepository databaseInteractor, Progressable progressable, AtomicBoolean
|
||||
cancelled) {
|
||||
super(context, databaseInteractor, progressable, cancelled);
|
||||
|
||||
this.lastUpdateInteractor = LastUpdateInteractor.create(context);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -230,6 +234,8 @@ public class CertifyOperation extends BaseReadWriteOperation<CertifyActionsParce
|
|||
log.add(uploadResult, 2);
|
||||
|
||||
if (uploadResult.success()) {
|
||||
lastUpdateInteractor.renewKeyLastUpdatedTime(certifiedKey.getMasterKeyId(), true);
|
||||
|
||||
uploadOk += 1;
|
||||
} else {
|
||||
uploadError += 1;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.ContentProviderOperation;
|
||||
|
@ -85,23 +84,27 @@ public class KeyWritableRepository extends KeyRepository {
|
|||
private static final int MAX_CACHED_KEY_SIZE = 1024 * 50;
|
||||
|
||||
private final Context mContext;
|
||||
private final LastUpdateInteractor lastUpdateInteractor;
|
||||
|
||||
public static KeyWritableRepository create(Context context) {
|
||||
LocalPublicKeyStorage localPublicKeyStorage = LocalPublicKeyStorage.getInstance(context);
|
||||
LastUpdateInteractor lastUpdateInteractor = LastUpdateInteractor.create(context);
|
||||
|
||||
return new KeyWritableRepository(context, localPublicKeyStorage);
|
||||
return new KeyWritableRepository(context, localPublicKeyStorage, lastUpdateInteractor);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
KeyWritableRepository(Context context, LocalPublicKeyStorage localPublicKeyStorage) {
|
||||
this(context, localPublicKeyStorage, new OperationLog(), 0);
|
||||
KeyWritableRepository(Context context, LocalPublicKeyStorage localPublicKeyStorage,
|
||||
LastUpdateInteractor lastUpdateInteractor) {
|
||||
this(context, localPublicKeyStorage, lastUpdateInteractor, new OperationLog(), 0);
|
||||
}
|
||||
|
||||
private KeyWritableRepository(
|
||||
Context context, LocalPublicKeyStorage localPublicKeyStorage, OperationLog log, int indent) {
|
||||
private KeyWritableRepository(Context context, LocalPublicKeyStorage localPublicKeyStorage,
|
||||
LastUpdateInteractor lastUpdateInteractor, OperationLog log, int indent) {
|
||||
super(context.getContentResolver(), localPublicKeyStorage, log, indent);
|
||||
|
||||
mContext = context;
|
||||
this.lastUpdateInteractor = lastUpdateInteractor;
|
||||
}
|
||||
|
||||
private LongSparseArray<CanonicalizedPublicKey> getTrustedMasterKeys() {
|
||||
|
@ -560,9 +563,14 @@ public class KeyWritableRepository extends KeyRepository {
|
|||
return null;
|
||||
}
|
||||
|
||||
Boolean seenOnKeyservers = lastUpdateInteractor.getSeenOnKeyservers(masterKeyId);
|
||||
|
||||
ContentValues lastUpdatedEntry = new ContentValues(2);
|
||||
lastUpdatedEntry.put(UpdatedKeys.MASTER_KEY_ID, masterKeyId);
|
||||
lastUpdatedEntry.put(UpdatedKeys.LAST_UPDATED, lastUpdateTime);
|
||||
if (seenOnKeyservers != null){
|
||||
lastUpdatedEntry.put(UpdatedKeys.SEEN_ON_KEYSERVERS, seenOnKeyservers);
|
||||
}
|
||||
return ContentProviderOperation
|
||||
.newInsert(UpdatedKeys.CONTENT_URI)
|
||||
.withValues(lastUpdatedEntry)
|
||||
|
|
|
@ -26,7 +26,7 @@ public class LastUpdateInteractor {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
private Boolean getSeenOnKeyservers(long masterKeyId) {
|
||||
public Boolean getSeenOnKeyservers(long masterKeyId) {
|
||||
Cursor cursor = contentResolver.query(
|
||||
UpdatedKeys.CONTENT_URI,
|
||||
new String[] { UpdatedKeys.SEEN_ON_KEYSERVERS },
|
||||
|
|
|
@ -243,7 +243,8 @@ public class InteropTest {
|
|||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(verify.getMasterKeyId()) : null;
|
||||
|
||||
KeyWritableRepository helper = new KeyWritableRepository(RuntimeEnvironment.application,
|
||||
LocalPublicKeyStorage.getInstance(RuntimeEnvironment.application)) {
|
||||
LocalPublicKeyStorage.getInstance(RuntimeEnvironment.application),
|
||||
LastUpdateInteractor.create(RuntimeEnvironment.application)) {
|
||||
|
||||
@Override
|
||||
public CachedPublicKeyRing getCachedPublicKeyRing(Uri queryUri) throws PgpKeyNotFoundException {
|
||||
|
|
Loading…
Reference in a new issue