From c446ba6e58edcd167ad881a237b84386f623f0a7 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 23 Jun 2020 12:10:20 +1000 Subject: [PATCH 1/5] Fix crash --- .../securesms/loki/protocol/SessionMetaProtocol.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt index 2276539323..6c2b73ffb1 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt @@ -97,8 +97,8 @@ object SessionMetaProtocol { * Should be invoked for the recipient's master device. */ @JvmStatic - fun shouldSendTypingIndicator(recipient: Recipient, context: Context): Boolean { - if (recipient.isGroupRecipient) { return false } + fun shouldSendTypingIndicator(recipient: Recipient?, context: Context): Boolean { + if (recipient == null || recipient.isGroupRecipient) { return false } val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient) return DatabaseFactory.getLokiThreadDatabase(context).getFriendRequestStatus(threadID) == LokiThreadFriendRequestStatus.FRIENDS } From 90a8a36486706f58bb9c7e3e35a2c8fdf82574f9 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 23 Jun 2020 12:13:27 +1000 Subject: [PATCH 2/5] Fix crash --- .../securesms/conversation/ConversationFragment.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java index 19c3295efa..52a5d8ff2e 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -428,9 +428,7 @@ public class ConversationFragment extends Fragment private MessageRecord getSelectedMessageRecord() { Set messageRecords = getListAdapter().getSelectedItems(); - - if (messageRecords.size() == 1) return messageRecords.iterator().next(); - else throw new AssertionError(); + return messageRecords.iterator().next(); } public void reload(Recipient recipient, long threadId) { From 2189729f45700908d8e5ff0108268cf9f5eeac34 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 23 Jun 2020 12:15:58 +1000 Subject: [PATCH 3/5] Fix crash --- src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java b/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java index 82b721c845..c8d0932ec5 100644 --- a/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java @@ -52,6 +52,8 @@ public class RotateSignedPreKeyJob extends BaseJob implements InjectableType { public void onRun() throws Exception { Log.i(TAG, "Rotating signed prekey..."); + if (!IdentityKeyUtil.hasIdentityKey(context)) { return; } + IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context); SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, identityKey, false); From e352b2284e381f9de04a6fd75040c8eed041c189 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 23 Jun 2020 12:17:49 +1000 Subject: [PATCH 4/5] Fix crash --- .../securesms/conversation/ConversationActivity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index b3446d3c85..30a208677e 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -1710,7 +1710,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity private void initializeResources() { if (recipient != null) recipient.removeListener(this); - recipient = Recipient.from(this, getIntent().getParcelableExtra(ADDRESS_EXTRA), true); + Address address = getIntent().getParcelableExtra(ADDRESS_EXTRA); + if (address == null) { finish(); return; } + recipient = Recipient.from(this, address, true); threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1); archived = getIntent().getBooleanExtra(IS_ARCHIVED_EXTRA, false); distributionType = getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT); From b8454f3db24001c2df5a98acb0cd78ef48e30bf9 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Tue, 23 Jun 2020 12:23:58 +1000 Subject: [PATCH 5/5] Fix crash --- .../securesms/groups/GroupMessageProcessor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index 463093b5ca..5dacafdd65 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -131,10 +131,12 @@ public class GroupMessageProcessor { String id = GroupUtil.getEncodedId(group); String userMasterDevice = TextSecurePreferences.getMasterHexEncodedPublicKey(context); + if (userMasterDevice == null) { userMasterDevice = TextSecurePreferences.getLocalNumber(context); } if (group.getGroupType() == SignalServiceGroup.GroupType.SIGNAL) { // Loki - Only update the group if the group admin sent the message String masterDevice = MultiDeviceProtocol.shared.getMasterDevice(content.getSender()); + if (masterDevice == null) { masterDevice = content.getSender(); } if (!groupRecord.getAdmins().contains(Address.fromSerialized(masterDevice))) { Log.d("Loki", "Received a group update message from a non-admin user for: " + id +"; ignoring."); return null; @@ -212,6 +214,7 @@ public class GroupMessageProcessor { @NonNull GroupRecord record) { String masterDevice = MultiDeviceProtocol.shared.getMasterDevice(content.getSender()); + if (masterDevice == null) { masterDevice = content.getSender(); } if (record.getMembers().contains(Address.fromSerialized(masterDevice))) { ApplicationContext.getInstance(context) .getJobManager() @@ -234,6 +237,7 @@ public class GroupMessageProcessor { builder.setType(GroupContext.Type.QUIT); String masterDevice = MultiDeviceProtocol.shared.getMasterDevice(content.getSender()); + if (masterDevice == null) { masterDevice = content.getSender(); } if (members.contains(Address.fromExternal(context, masterDevice))) { database.remove(id, Address.fromExternal(context, masterDevice)); if (outgoing) database.setActive(id, false); @@ -259,7 +263,7 @@ public class GroupMessageProcessor { try { if (outgoing) { MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase(context); - Address address = Address.fromExternal(context, GroupUtil.getEncodedId(group)); + Address address = Address.fromExternal(context, GroupUtil.getEncodedId(group)); Recipient recipient = Recipient.from(context, address, false); OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(recipient, storage, null, content.getTimestamp(), 0, null, Collections.emptyList(), Collections.emptyList()); long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipient);