mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Use group state paging always.
This commit is contained in:
@@ -199,12 +199,7 @@ public final class GroupsV2StateProcessor {
|
||||
|
||||
if (inputGroupState == null) {
|
||||
try {
|
||||
if (FeatureFlags.groupsV2UpdatePaging()) {
|
||||
return updateLocalGroupFromServerPaged(revision, localState, timestamp);
|
||||
} else {
|
||||
boolean latestRevisionOnly = revision == LATEST && (localState == null || localState.getRevision() == GroupsV2StateProcessor.RESTORE_PLACEHOLDER_REVISION);
|
||||
inputGroupState = queryServer(localState, latestRevisionOnly);
|
||||
}
|
||||
} catch (GroupNotAMemberException e) {
|
||||
if (localState != null && signedGroupChange != null) {
|
||||
try {
|
||||
@@ -386,7 +381,8 @@ public final class GroupsV2StateProcessor {
|
||||
throws IOException, GroupNotAMemberException, GroupDoesNotExistException
|
||||
{
|
||||
try {
|
||||
return groupsV2Api.getGroupHistory(groupSecretParams, revision, groupsV2Authorization.getAuthorizationForToday(Recipient.self().requireAci(), groupSecretParams))
|
||||
return groupsV2Api.getGroupHistoryPage(groupSecretParams, revision, groupsV2Authorization.getAuthorizationForToday(Recipient.self().requireAci(), groupSecretParams))
|
||||
.getResults()
|
||||
.get(0)
|
||||
.getGroup()
|
||||
.orNull();
|
||||
@@ -569,58 +565,6 @@ public final class GroupsV2StateProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull GlobalGroupState queryServer(@Nullable DecryptedGroup localState, boolean latestOnly)
|
||||
throws IOException, GroupNotAMemberException
|
||||
{
|
||||
ACI selfAci = Recipient.self().requireAci();
|
||||
DecryptedGroup latestServerGroup;
|
||||
List<ServerGroupLogEntry> history;
|
||||
|
||||
try {
|
||||
latestServerGroup = groupsV2Api.getGroup(groupSecretParams, groupsV2Authorization.getAuthorizationForToday(selfAci, groupSecretParams));
|
||||
} catch (NotInGroupException | GroupNotFoundException e) {
|
||||
throw new GroupNotAMemberException(e);
|
||||
} catch (VerificationFailedException | InvalidGroupStateException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
if (latestOnly || !GroupProtoUtil.isMember(selfAci.uuid(), latestServerGroup.getMembersList())) {
|
||||
history = Collections.singletonList(new ServerGroupLogEntry(latestServerGroup, null));
|
||||
} else {
|
||||
int revisionWeWereAdded = GroupProtoUtil.findRevisionWeWereAdded(latestServerGroup, selfAci.uuid());
|
||||
int logsNeededFrom = localState != null ? Math.max(localState.getRevision(), revisionWeWereAdded) : revisionWeWereAdded;
|
||||
|
||||
history = getFullMemberHistory(selfAci, logsNeededFrom);
|
||||
}
|
||||
|
||||
return new GlobalGroupState(localState, history);
|
||||
}
|
||||
|
||||
private List<ServerGroupLogEntry> getFullMemberHistory(@NonNull ACI selfAci, int logsNeededFromRevision) throws IOException {
|
||||
try {
|
||||
Collection<DecryptedGroupHistoryEntry> groupStatesFromRevision = groupsV2Api.getGroupHistory(groupSecretParams, logsNeededFromRevision, groupsV2Authorization.getAuthorizationForToday(selfAci, groupSecretParams));
|
||||
ArrayList<ServerGroupLogEntry> history = new ArrayList<>(groupStatesFromRevision.size());
|
||||
boolean ignoreServerChanges = SignalStore.internalValues().gv2IgnoreServerChanges();
|
||||
|
||||
if (ignoreServerChanges) {
|
||||
Log.w(TAG, "Server change logs are ignored by setting");
|
||||
}
|
||||
|
||||
for (DecryptedGroupHistoryEntry entry : groupStatesFromRevision) {
|
||||
DecryptedGroup group = entry.getGroup().orNull();
|
||||
DecryptedGroupChange change = ignoreServerChanges ? null : entry.getChange().orNull();
|
||||
|
||||
if (group != null || change != null) {
|
||||
history.add(new ServerGroupLogEntry(group, change));
|
||||
}
|
||||
}
|
||||
|
||||
return history;
|
||||
} catch (InvalidGroupStateException | VerificationFailedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private GlobalGroupState getFullMemberHistoryPage(DecryptedGroup localState, @NonNull ACI selfAci, int logsNeededFromRevision) throws IOException {
|
||||
try {
|
||||
GroupHistoryPage groupHistoryPage = groupsV2Api.getGroupHistoryPage(groupSecretParams, logsNeededFromRevision, groupsV2Authorization.getAuthorizationForToday(selfAci, groupSecretParams));
|
||||
|
||||
@@ -89,7 +89,6 @@ public final class FeatureFlags {
|
||||
private static final String DONOR_BADGES_DISPLAY = "android.donorBadges.display.4";
|
||||
private static final String CDSH = "android.cdsh";
|
||||
private static final String VOICE_NOTE_RECORDING_V2 = "android.voiceNoteRecordingV2.2";
|
||||
private static final String GROUPS_V2_UPDATE_PAGING = "android.groupsv2.updatePaging";
|
||||
private static final String HARDWARE_AEC_MODELS = "android.calling.hardwareAecModels";
|
||||
private static final String FORCE_DEFAULT_AEC = "android.calling.forceDefaultAec";
|
||||
|
||||
@@ -134,7 +133,6 @@ public final class FeatureFlags {
|
||||
DONOR_BADGES_DISPLAY,
|
||||
CHANGE_NUMBER_ENABLED,
|
||||
VOICE_NOTE_RECORDING_V2,
|
||||
GROUPS_V2_UPDATE_PAGING,
|
||||
HARDWARE_AEC_MODELS,
|
||||
FORCE_DEFAULT_AEC
|
||||
);
|
||||
@@ -192,7 +190,6 @@ public final class FeatureFlags {
|
||||
DONOR_BADGES_DISPLAY,
|
||||
DONATE_MEGAPHONE,
|
||||
VOICE_NOTE_RECORDING_V2,
|
||||
GROUPS_V2_UPDATE_PAGING,
|
||||
FORCE_DEFAULT_AEC
|
||||
);
|
||||
|
||||
@@ -443,11 +440,6 @@ public final class FeatureFlags {
|
||||
return getBoolean(VOICE_NOTE_RECORDING_V2, false);
|
||||
}
|
||||
|
||||
/** Whether or not to use the proper paging when updating group state. */
|
||||
public static boolean groupsV2UpdatePaging() {
|
||||
return getBoolean(GROUPS_V2_UPDATE_PAGING, false);
|
||||
}
|
||||
|
||||
/** A comma-separated list of models that should use hardware AEC for calling. */
|
||||
public static @NonNull String hardwareAecModels() {
|
||||
return getString(HARDWARE_AEC_MODELS, "");
|
||||
|
||||
@@ -95,37 +95,6 @@ public final class GroupsV2Api {
|
||||
.decryptGroup(group);
|
||||
}
|
||||
|
||||
public List<DecryptedGroupHistoryEntry> getGroupHistory(GroupSecretParams groupSecretParams,
|
||||
int fromRevision,
|
||||
GroupsV2AuthorizationString authorization)
|
||||
throws IOException, InvalidGroupStateException, VerificationFailedException
|
||||
{
|
||||
List<GroupChanges.GroupChangeState> changesList = new LinkedList<>();
|
||||
PushServiceSocket.GroupHistory group;
|
||||
|
||||
do {
|
||||
group = socket.getGroupsV2GroupHistory(fromRevision, authorization);
|
||||
|
||||
changesList.addAll(group.getGroupChanges().getGroupChangesList());
|
||||
|
||||
if (group.hasMore()) {
|
||||
fromRevision = group.getNextPageStartGroupRevision();
|
||||
}
|
||||
} while (group.hasMore());
|
||||
|
||||
ArrayList<DecryptedGroupHistoryEntry> result = new ArrayList<>(changesList.size());
|
||||
GroupsV2Operations.GroupOperations groupOperations = groupsOperations.forGroup(groupSecretParams);
|
||||
|
||||
for (GroupChanges.GroupChangeState change : changesList) {
|
||||
Optional<DecryptedGroup> decryptedGroup = change.hasGroupState () ? Optional.of(groupOperations.decryptGroup(change.getGroupState())) : Optional.absent();
|
||||
Optional<DecryptedGroupChange> decryptedChange = change.hasGroupChange() ? groupOperations.decryptChange(change.getGroupChange(), false) : Optional.absent();
|
||||
|
||||
result.add(new DecryptedGroupHistoryEntry(decryptedGroup, decryptedChange));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public GroupHistoryPage getGroupHistoryPage(GroupSecretParams groupSecretParams,
|
||||
int fromRevision,
|
||||
GroupsV2AuthorizationString authorization)
|
||||
|
||||
Reference in New Issue
Block a user