From 99c0c2ff4c4c55ca3456e768841c24308bd69e27 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 7 Aug 2020 18:31:42 -0400 Subject: [PATCH] Fix crash when opening debuglogs during registration. --- .../logsubmit/LogSectionCapabilities.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java index 7c9629518..9c49dc37a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java +++ b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionCapabilities.java @@ -6,6 +6,7 @@ import androidx.annotation.NonNull; import org.thoughtcrime.securesms.AppCapabilities; import org.thoughtcrime.securesms.recipients.Recipient; +import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.signalservice.api.profiles.SignalServiceProfile; public final class LogSectionCapabilities implements LogSection { @@ -17,16 +18,21 @@ public final class LogSectionCapabilities implements LogSection { @Override public @NonNull CharSequence getContent(@NonNull Context context) { - Recipient self = Recipient.self(); - if (!self.isRegistered()) { + if (!TextSecurePreferences.isPushRegistered(context)) { return "Unregistered"; - } else { - SignalServiceProfile.Capabilities capabilities = AppCapabilities.getCapabilities(false); - - return new StringBuilder().append("Local device UUID : ").append(capabilities.isUuid()).append("\n") - .append("Global UUID : ").append(self.getUuidCapability()).append("\n") - .append("Local device GV2 : ").append(capabilities.isGv2()).append("\n") - .append("Global GV2 : ").append(self.getGroupsV2Capability()).append("\n"); } + + if (TextSecurePreferences.getLocalNumber(context) == null || TextSecurePreferences.getLocalUuid(context) == null) { + return "Self not yet available!"; + } + + Recipient self = Recipient.self(); + + SignalServiceProfile.Capabilities capabilities = AppCapabilities.getCapabilities(false); + + return new StringBuilder().append("Local device UUID : ").append(capabilities.isUuid()).append("\n") + .append("Global UUID : ").append(self.getUuidCapability()).append("\n") + .append("Local device GV2 : ").append(capabilities.isGv2()).append("\n") + .append("Global GV2 : ").append(self.getGroupsV2Capability()).append("\n"); } }