kopia lustrzana https://github.com/ryukoposting/Signal-Android
Remove uuidOnlyContacts feature flag.
rodzic
4e55d2d941
commit
870cee5707
|
@ -307,7 +307,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActivity implement
|
|||
byte[] localId;
|
||||
byte[] remoteId;
|
||||
|
||||
if (FeatureFlags.uuidOnlyContacts() && recipient.resolve().getUuid().isPresent()) {
|
||||
if (FeatureFlags.cds() && recipient.resolve().getUuid().isPresent()) {
|
||||
Log.i(TAG, "Using UUID (version 2).");
|
||||
version = 2;
|
||||
localId = UuidUtil.toByteArray(TextSecurePreferences.getLocalUuid(requireContext()));
|
||||
|
|
|
@ -689,13 +689,13 @@ public class RecipientDatabase extends Database {
|
|||
|
||||
try {
|
||||
for (SignalContactRecord insert : contactInserts) {
|
||||
ContentValues values = validateContactValuesForInsert(getValuesForStorageContact(insert, true));
|
||||
ContentValues values = getValuesForStorageContact(insert, true);
|
||||
long id = db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_IGNORE);
|
||||
|
||||
RecipientId recipientId;
|
||||
|
||||
if (id < 0) {
|
||||
values = validateContactValuesForInsert(getValuesForStorageContact(insert, false));
|
||||
values = getValuesForStorageContact(insert, false);
|
||||
Log.w(TAG, "Failed to insert! It's likely that these were newly-registered users that were missed in the merge. Doing an update instead.");
|
||||
|
||||
if (insert.getAddress().getNumber().isPresent()) {
|
||||
|
@ -2145,17 +2145,6 @@ public class RecipientDatabase extends Database {
|
|||
}
|
||||
}
|
||||
|
||||
private static ContentValues validateContactValuesForInsert(ContentValues values) {
|
||||
if (!FeatureFlags.uuidOnlyContacts() &&
|
||||
values.getAsString(UUID) != null &&
|
||||
values.getAsString(PHONE) == null)
|
||||
{
|
||||
throw new UuidRecipientError();
|
||||
} else {
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges one UUID recipient with an E164 recipient. It is assumed that the E164 recipient does
|
||||
* *not* have a UUID.
|
||||
|
|
|
@ -245,22 +245,7 @@ public class Recipient {
|
|||
|
||||
if (UuidUtil.isUuid(identifier)) {
|
||||
UUID uuid = UuidUtil.parseOrThrow(identifier);
|
||||
|
||||
if (FeatureFlags.uuidOnlyContacts()) {
|
||||
id = db.getOrInsertFromUuid(uuid);
|
||||
} else {
|
||||
Optional<RecipientId> possibleId = db.getByUuid(uuid);
|
||||
|
||||
if (possibleId.isPresent()) {
|
||||
id = possibleId.get();
|
||||
} else {
|
||||
if (!FeatureFlags.uuidOnlyContacts() && FeatureFlags.groupsV2()) {
|
||||
throw new RuntimeException(new UuidRecipientError());
|
||||
} else {
|
||||
throw new UuidRecipientError();
|
||||
}
|
||||
}
|
||||
}
|
||||
id = db.getOrInsertFromUuid(uuid);
|
||||
} else if (GroupId.isEncodedGroup(identifier)) {
|
||||
id = db.getOrInsertFromGroupId(GroupId.parseOrThrow(identifier));
|
||||
} else if (NumberUtil.isValidEmail(identifier)) {
|
||||
|
@ -728,7 +713,7 @@ public class Recipient {
|
|||
if (FeatureFlags.usernames()) {
|
||||
return true;
|
||||
} else {
|
||||
return FeatureFlags.uuidOnlyContacts() && uuidCapability == Capability.SUPPORTED;
|
||||
return uuidCapability == Capability.SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ public final class StorageSyncHelper {
|
|||
public static @NonNull MergeResult resolveConflict(@NonNull Collection<SignalStorageRecord> remoteOnlyRecords,
|
||||
@NonNull Collection<SignalStorageRecord> localOnlyRecords)
|
||||
{
|
||||
List<SignalContactRecord> remoteOnlyContacts = Stream.of(remoteOnlyRecords).filter(r -> r.getContact().isPresent() && isValidContact(r.getContact().get())).map(r -> r.getContact().get()).toList();
|
||||
List<SignalContactRecord> remoteOnlyContacts = Stream.of(remoteOnlyRecords).filter(r -> r.getContact().isPresent()).map(r -> r.getContact().get()).toList();
|
||||
List<SignalContactRecord> localOnlyContacts = Stream.of(localOnlyRecords).filter(r -> r.getContact().isPresent()).map(r -> r.getContact().get()).toList();
|
||||
|
||||
List<SignalGroupV1Record> remoteOnlyGroupV1 = Stream.of(remoteOnlyRecords).filter(r -> r.getGroupV1().isPresent()).map(r -> r.getGroupV1().get()).toList();
|
||||
|
@ -241,7 +241,7 @@ public final class StorageSyncHelper {
|
|||
List<SignalGroupV2Record> remoteOnlyGroupV2 = Stream.of(remoteOnlyRecords).filter(r -> r.getGroupV2().isPresent()).map(r -> r.getGroupV2().get()).toList();
|
||||
List<SignalGroupV2Record> localOnlyGroupV2 = Stream.of(localOnlyRecords).filter(r -> r.getGroupV2().isPresent()).map(r -> r.getGroupV2().get()).toList();
|
||||
|
||||
List<SignalStorageRecord> remoteOnlyUnknowns = Stream.of(remoteOnlyRecords).filter(r -> r.isUnknown() || (r.getContact().isPresent() && !isValidContact(r.getContact().get()))).toList();
|
||||
List<SignalStorageRecord> remoteOnlyUnknowns = Stream.of(remoteOnlyRecords).filter(SignalStorageRecord::isUnknown).toList();
|
||||
List<SignalStorageRecord> localOnlyUnknowns = Stream.of(localOnlyRecords).filter(SignalStorageRecord::isUnknown).toList();
|
||||
|
||||
List<SignalAccountRecord> remoteOnlyAccount = Stream.of(remoteOnlyRecords).filter(r -> r.getAccount().isPresent()).map(r -> r.getAccount().get()).toList();
|
||||
|
@ -440,10 +440,6 @@ public final class StorageSyncHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isValidContact(@NonNull SignalContactRecord contact) {
|
||||
return FeatureFlags.uuidOnlyContacts() || contact.getAddress().getNumber().isPresent();
|
||||
}
|
||||
|
||||
public static final class KeyDifferenceResult {
|
||||
private final List<StorageId> remoteOnlyKeys;
|
||||
private final List<StorageId> localOnlyKeys;
|
||||
|
|
|
@ -48,7 +48,6 @@ public final class FeatureFlags {
|
|||
|
||||
private static final long FETCH_INTERVAL = TimeUnit.HOURS.toMillis(0);
|
||||
|
||||
private static final String UUIDS = "android.uuids";
|
||||
private static final String USERNAMES = "android.usernames";
|
||||
private static final String ATTACHMENTS_V3 = "android.attachmentsV3.2";
|
||||
private static final String REMOTE_DELETE = "android.remoteDelete";
|
||||
|
@ -169,16 +168,9 @@ public final class FeatureFlags {
|
|||
Log.i(TAG, "[Disk] After : " + result.getDisk().toString());
|
||||
}
|
||||
|
||||
/** Whether or not we allow UUID-only contacts. */
|
||||
public static synchronized boolean uuidOnlyContacts() {
|
||||
return getBoolean(UUIDS, false);
|
||||
}
|
||||
|
||||
/** Creating usernames, sending messages by username. Requires {@link #uuidOnlyContacts()}. */
|
||||
public static synchronized boolean usernames() {
|
||||
boolean value = getBoolean(USERNAMES, false);
|
||||
if (value && !uuidOnlyContacts()) throw new MissingFlagRequirementError();
|
||||
return value;
|
||||
return getBoolean(USERNAMES, false);
|
||||
}
|
||||
|
||||
/** Whether or not we use the attachments v3 form. */
|
||||
|
|
|
@ -244,8 +244,6 @@ public final class StorageSyncHelperTest {
|
|||
|
||||
@Test
|
||||
public void resolveConflict_complex() {
|
||||
when(FeatureFlags.uuidOnlyContacts()).thenReturn(true);
|
||||
|
||||
SignalContactRecord remote1 = contact(1, UUID_A, null, "a");
|
||||
SignalContactRecord local1 = contact(2, UUID_A, E164_A, "a");
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue