From 694a5de2c33db3550c3c3a1d4ee9e4793dd741fe Mon Sep 17 00:00:00 2001 From: Marek Sebera Date: Tue, 26 Dec 2017 14:07:51 +0100 Subject: [PATCH] Send m-notifyresp-ind (NotifyRespInd) for retrieved MMS on Lollipop API --- .../mms/IncomingLollipopMmsConnection.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java b/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java index 608ac2f739..8a2c34066d 100644 --- a/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java +++ b/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java @@ -26,10 +26,15 @@ import android.support.annotation.Nullable; import android.telephony.SmsManager; import android.util.Log; +import com.google.android.mms.InvalidHeaderValueException; +import com.google.android.mms.pdu_alt.NotifyRespInd; +import com.google.android.mms.pdu_alt.PduComposer; +import com.google.android.mms.pdu_alt.PduHeaders; import com.google.android.mms.pdu_alt.PduParser; import com.google.android.mms.pdu_alt.RetrieveConf; import org.thoughtcrime.securesms.providers.MmsBodyProvider; +import org.thoughtcrime.securesms.transport.UndeliverableMessageException; import org.thoughtcrime.securesms.util.Util; import java.io.ByteArrayOutputStream; @@ -89,7 +94,9 @@ public class IncomingLollipopMmsConnection extends LollipopMmsConnection impleme Log.w(TAG, baos.size() + "-byte response: ");// + Hex.dump(baos.toByteArray())); - return (RetrieveConf) new PduParser(baos.toByteArray()).parse(); + RetrieveConf retrieved = (RetrieveConf) new PduParser(baos.toByteArray()).parse(); + sendRetrievedAcknowledgement(transactionId, retrieved.getMmsVersion(), subscriptionId); + return retrieved; } catch (IOException | TimeoutException e) { Log.w(TAG, e); throw new MmsException(e); @@ -97,4 +104,15 @@ public class IncomingLollipopMmsConnection extends LollipopMmsConnection impleme endTransaction(); } } + + private void sendRetrievedAcknowledgement(byte[] transactionId, int mmsVersion, int subscriptionId) { + try { + NotifyRespInd retrieveResponse = new NotifyRespInd(mmsVersion, transactionId, PduHeaders.STATUS_RETRIEVED); + new OutgoingLollipopMmsConnection(getContext()).send(new PduComposer(getContext(), retrieveResponse).make(), subscriptionId); + } catch (UndeliverableMessageException e) { + Log.w(TAG, e); + } catch (InvalidHeaderValueException e) { + Log.w(TAG, e); + } + } }