Send m-notifyresp-ind (NotifyRespInd) for retrieved MMS on Lollipop API

This commit is contained in:
Marek Sebera 2017-12-26 14:07:51 +01:00 committed by Moxie Marlinspike
parent feee09cd28
commit 694a5de2c3

View File

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