From 2924a0993665e70896b2b21bb9e844b871c41af7 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 13 Nov 2019 10:42:37 -0500 Subject: [PATCH] Don't run UuidMigration if not registered. --- .../thoughtcrime/securesms/migrations/UuidMigrationJob.java | 4 +++- .../thoughtcrime/securesms/recipients/LiveRecipientCache.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/migrations/UuidMigrationJob.java b/src/org/thoughtcrime/securesms/migrations/UuidMigrationJob.java index 0a40699cf5..1ee62307ff 100644 --- a/src/org/thoughtcrime/securesms/migrations/UuidMigrationJob.java +++ b/src/org/thoughtcrime/securesms/migrations/UuidMigrationJob.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.migrations; import android.content.Context; +import android.text.TextUtils; import androidx.annotation.NonNull; @@ -52,8 +53,9 @@ public class UuidMigrationJob extends MigrationJob { @Override void performMigration() throws Exception { - if (!TextSecurePreferences.isPushRegistered(context)) { + if (!TextSecurePreferences.isPushRegistered(context) || TextUtils.isEmpty(TextSecurePreferences.getLocalNumber(context))) { Log.w(TAG, "Not registered! Skipping migration, as it wouldn't do anything."); + return; } fetchOwnUuid(context); diff --git a/src/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java b/src/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java index 3c51b71dff..e640bf89d2 100644 --- a/src/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java +++ b/src/org/thoughtcrime/securesms/recipients/LiveRecipientCache.java @@ -85,8 +85,10 @@ public final class LiveRecipientCache { if (localUuid != null) { localRecipientId = recipientDatabase.getByUuid(localUuid).or(recipientDatabase.getByE164(localE164)).orNull(); - } else { + } else if (localE164 != null) { localRecipientId = recipientDatabase.getByE164(localE164).orNull(); + } else { + throw new AssertionError("Tried to call getSelf() before local data was set!"); } if (localRecipientId == null) {