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