Fix illegal state exception during backup restore of unamed groups.

fork-5.53.8
Cody Henthorne 2022-08-08 10:37:27 -04:00 zatwierdzone przez Alex Hart
rodzic f7dce21246
commit 1547ec2067
2 zmienionych plików z 24 dodań i 1 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ import android.database.Cursor;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.signal.core.util.ThreadUtil;
import org.signal.core.util.concurrent.SignalExecutors;
@ -176,6 +177,28 @@ public final class LiveRecipientCache {
return getLive(selfId).resolve();
}
/** Can safely get self id. If used during early registration (backup), will return null as we don't know self yet. */
@Nullable RecipientId getSelfId() {
RecipientId selfId;
synchronized (localRecipientId) {
selfId = localRecipientId.get();
}
if (selfId != null) {
return selfId;
}
ACI localAci = SignalStore.account().getAci();
String localE164 = SignalStore.account().getE164();
if (localAci == null && localE164 == null) {
return null;
} else {
return getSelf().getId();
}
}
@AnyThread
public void warmUp() {
if (warmedUp.getAndSet(true)) {

Wyświetl plik

@ -489,7 +489,7 @@ public class Recipient {
public @Nullable String getGroupName(@NonNull Context context) {
if (groupId != null && Util.isEmpty(this.groupName)) {
RecipientId selfId = Recipient.self().getId();
RecipientId selfId = ApplicationDependencies.getRecipientCache().getSelfId();
List<Recipient> others = participantIds.stream()
.filter(id -> !id.equals(selfId))
.limit(MAX_MEMBER_NAMES)