Merge pull request #239 from loki-project/crashes

Fix Common Crashes
This commit is contained in:
Niels Andriesse 2020-06-23 12:27:34 +10:00 committed by GitHub
commit df24a6d8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 7 deletions

View File

@ -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);

View File

@ -428,9 +428,7 @@ public class ConversationFragment extends Fragment
private MessageRecord getSelectedMessageRecord() {
Set<MessageRecord> 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) {

View File

@ -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);

View File

@ -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);

View File

@ -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
}