From 9dd3e50ebd3bf257c90ceb90741c7f3b0e84a423 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Sat, 8 Sep 2018 10:08:22 -0700 Subject: [PATCH] Don't set subscriptionId for quick-reply push messages. This could cause us to think push messages were actually sent with a SIM. We also now prevent rendering SIM info on push messages in the conversation view. Fixes #8176 --- .../securesms/components/ConversationItemFooter.java | 2 +- .../securesms/notifications/RemoteReplyReceiver.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java b/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java index f3457875fe..b88d3d4ac8 100644 --- a/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java +++ b/src/org/thoughtcrime/securesms/components/ConversationItemFooter.java @@ -106,7 +106,7 @@ public class ConversationItemFooter extends LinearLayout { private void presentSimInfo(@NonNull MessageRecord messageRecord) { SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(getContext()); - if (messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || subscriptionManager.getActiveSubscriptionInfoList().size() < 2) { + if (messageRecord.isPush() || messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || subscriptionManager.getActiveSubscriptionInfoList().size() < 2) { simView.setVisibility(View.GONE); } else { Optional subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId()); diff --git a/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java b/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java index bad8ab5ce8..e82e2d177c 100644 --- a/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java @@ -28,10 +28,13 @@ import android.support.v4.app.RemoteInput; import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo; +import org.thoughtcrime.securesms.database.RecipientDatabase; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.sms.MessageSender; +import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage; import org.thoughtcrime.securesms.sms.OutgoingTextMessage; +import org.thoughtcrime.securesms.util.TextSecurePreferences; import java.util.Collections; import java.util.LinkedList; @@ -71,6 +74,9 @@ public class RemoteReplyReceiver extends BroadcastReceiver { if (recipient.isGroupRecipient()) { OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<>(), System.currentTimeMillis(), subscriptionId, expiresIn, 0, null, Collections.emptyList()); threadId = MessageSender.send(context, reply, -1, false, null); + } else if (TextSecurePreferences.isPushRegistered(context) && recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) { + OutgoingEncryptedMessage reply = new OutgoingEncryptedMessage(recipient, responseText.toString(), expiresIn); + threadId = MessageSender.send(context, reply, -1, false, null); } else { OutgoingTextMessage reply = new OutgoingTextMessage(recipient, responseText.toString(), expiresIn, subscriptionId); threadId = MessageSender.send(context, reply, -1, false, null);