mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Send m-notifyresp-ind after retrieving MMS
This commit is contained in:
parent
a057b628eb
commit
81107a98eb
@ -174,7 +174,7 @@ public class MmsCommunication {
|
|||||||
|
|
||||||
protected static byte[] parseResponse(HttpEntity entity) throws IOException {
|
protected static byte[] parseResponse(HttpEntity entity) throws IOException {
|
||||||
if (entity == null || entity.getContentLength() == 0)
|
if (entity == null || entity.getContentLength() == 0)
|
||||||
throw new IOException("Null response");
|
return null;
|
||||||
|
|
||||||
if (entity.getContentLength() < 0)
|
if (entity.getContentLength() < 0)
|
||||||
throw new IOException("Unknown content length!");
|
throw new IOException("Unknown content length!");
|
||||||
|
@ -36,7 +36,7 @@ import java.net.URISyntaxException;
|
|||||||
public class MmsDownloadHelper extends MmsCommunication {
|
public class MmsDownloadHelper extends MmsCommunication {
|
||||||
|
|
||||||
private static byte[] makeRequest(Context context, MmsConnectionParameters connectionParameters, String url)
|
private static byte[] makeRequest(Context context, MmsConnectionParameters connectionParameters, String url)
|
||||||
throws ClientProtocolException, IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
AndroidHttpClient client = null;
|
AndroidHttpClient client = null;
|
||||||
|
|
||||||
@ -82,6 +82,10 @@ public class MmsDownloadHelper extends MmsCommunication {
|
|||||||
|
|
||||||
byte[] pdu = makeRequest(context, connectionParameters, url);
|
byte[] pdu = makeRequest(context, connectionParameters, url);
|
||||||
|
|
||||||
|
if (pdu == null) {
|
||||||
|
throw new IOException("Retrieved null PDU!");
|
||||||
|
}
|
||||||
|
|
||||||
RetrieveConf retrieved = (RetrieveConf)new PduParser(pdu).parse();
|
RetrieveConf retrieved = (RetrieveConf)new PduParser(pdu).parse();
|
||||||
|
|
||||||
if (retrieved == null) {
|
if (retrieved == null) {
|
||||||
|
@ -54,7 +54,6 @@ public class MmsSendHelper extends MmsCommunication {
|
|||||||
request.setEntity(entity);
|
request.setEntity(entity);
|
||||||
request.setParams(client.getParams());
|
request.setParams(client.getParams());
|
||||||
request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
|
request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
|
||||||
// request.addHeader("x-wap-profile", "http://www.htcmms.com.tw/Android/Common/nexusone/ua-profile.xml");
|
|
||||||
request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
|
request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
|
||||||
HttpResponse response = client.execute(target, request);
|
HttpResponse response = client.execute(target, request);
|
||||||
StatusLine status = response.getStatusLine();
|
StatusLine status = response.getStatusLine();
|
||||||
@ -72,16 +71,35 @@ public class MmsSendHelper extends MmsCommunication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendNotificationReceived(Context context, byte[] mms, String apn,
|
||||||
|
boolean usingMmsRadio, boolean useProxyIfAvailable)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
sendBytes(context, mms, apn, usingMmsRadio, useProxyIfAvailable);
|
||||||
|
}
|
||||||
|
|
||||||
public static SendConf sendMms(Context context, byte[] mms, String apn,
|
public static SendConf sendMms(Context context, byte[] mms, String apn,
|
||||||
boolean usingMmsRadio, boolean useProxyIfAvailable)
|
boolean usingMmsRadio, boolean useProxyIfAvailable)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
byte[] response = sendBytes(context, mms, apn, usingMmsRadio, useProxyIfAvailable);
|
||||||
|
|
||||||
|
if (response == null) {
|
||||||
|
throw new IOException("Got null response!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (SendConf) new PduParser(response).parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] sendBytes(Context context, byte[] mms, String apn,
|
||||||
|
boolean usingMmsRadio, boolean useProxyIfAvailable)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
Log.w("MmsSender", "Sending MMS of length: " + mms.length);
|
Log.w("MmsSender", "Sending MMS of length: " + mms.length);
|
||||||
try {
|
try {
|
||||||
MmsConnectionParameters parameters = getMmsConnectionParameters(context, apn, useProxyIfAvailable);
|
MmsConnectionParameters parameters = getMmsConnectionParameters(context, apn, useProxyIfAvailable);
|
||||||
checkRouteToHost(context, parameters, parameters.getMmsc(), usingMmsRadio);
|
checkRouteToHost(context, parameters, parameters.getMmsc(), usingMmsRadio);
|
||||||
byte[] response = makePost(context, parameters, mms);
|
return makePost(context, parameters, mms);
|
||||||
return (SendConf) new PduParser(response).parse();
|
|
||||||
} catch (ApnUnavailableException aue) {
|
} catch (ApnUnavailableException aue) {
|
||||||
Log.w("MmsSender", aue);
|
Log.w("MmsSender", aue);
|
||||||
throw new IOException("Failed to get MMSC information...");
|
throw new IOException("Failed to get MMSC information...");
|
||||||
|
@ -28,10 +28,15 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
import org.thoughtcrime.securesms.mms.MmsDownloadHelper;
|
import org.thoughtcrime.securesms.mms.MmsDownloadHelper;
|
||||||
|
import org.thoughtcrime.securesms.mms.MmsSendHelper;
|
||||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||||
import org.thoughtcrime.securesms.protocol.WirePrefix;
|
import org.thoughtcrime.securesms.protocol.WirePrefix;
|
||||||
|
|
||||||
|
import ws.com.google.android.mms.InvalidHeaderValueException;
|
||||||
import ws.com.google.android.mms.MmsException;
|
import ws.com.google.android.mms.MmsException;
|
||||||
|
import ws.com.google.android.mms.pdu.NotifyRespInd;
|
||||||
|
import ws.com.google.android.mms.pdu.PduComposer;
|
||||||
|
import ws.com.google.android.mms.pdu.PduHeaders;
|
||||||
import ws.com.google.android.mms.pdu.RetrieveConf;
|
import ws.com.google.android.mms.pdu.RetrieveConf;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -100,9 +105,7 @@ public class MmsDownloader extends MmscProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
storeRetrievedMms(mmsDatabase, item, retrieved);
|
storeRetrievedMms(mmsDatabase, item, retrieved);
|
||||||
|
sendRetrievedAcknowledgement(item);
|
||||||
// NotifyRespInd notifyResponse = new NotifyRespInd(PduHeaders.CURRENT_MMS_VERSION, item.getTransactionId(), PduHeaders.STATUS_RETRIEVED);
|
|
||||||
// MmsSendHelper.sendMms(context, new PduComposer(context, notifyResponse).make());
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.w("MmsDownloader", e);
|
Log.w("MmsDownloader", e);
|
||||||
@ -147,6 +150,22 @@ public class MmsDownloader extends MmscProcessor {
|
|||||||
MessageNotifier.updateNotification(context, item.getMasterSecret(), messageAndThreadId.second);
|
MessageNotifier.updateNotification(context, item.getMasterSecret(), messageAndThreadId.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendRetrievedAcknowledgement(DownloadItem item) {
|
||||||
|
try {
|
||||||
|
NotifyRespInd notifyResponse = new NotifyRespInd(PduHeaders.CURRENT_MMS_VERSION,
|
||||||
|
item.getTransactionId(),
|
||||||
|
PduHeaders.STATUS_RETRIEVED);
|
||||||
|
|
||||||
|
MmsSendHelper.sendNotificationReceived(context, new PduComposer(context, notifyResponse).make(),
|
||||||
|
getApnInformation(), item.useMmsRadioMode(),
|
||||||
|
item.proxyRequestIfPossible());
|
||||||
|
} catch (InvalidHeaderValueException e) {
|
||||||
|
Log.w("MmsDownloader", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w("MmsDownloader", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void handleConnectivityChange() {
|
protected void handleConnectivityChange() {
|
||||||
LinkedList<DownloadItem> downloadItems = (LinkedList<DownloadItem>)pendingMessages.clone();
|
LinkedList<DownloadItem> downloadItems = (LinkedList<DownloadItem>)pendingMessages.clone();
|
||||||
|
|
||||||
|
@ -110,8 +110,6 @@ public class SmsListener extends BroadcastReceiver {
|
|||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
String messageBody = getSmsMessageBodyFromIntent(intent);
|
String messageBody = getSmsMessageBodyFromIntent(intent);
|
||||||
|
|
||||||
Log.w("SmsListener", "Checking challenge: " + messageBody);
|
|
||||||
|
|
||||||
if (messageBody == null)
|
if (messageBody == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user