mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 16:07:30 +00:00
Fix for NPE on empty MMS PDU
This commit is contained in:
parent
62cad05acb
commit
b805c4db4e
@ -71,20 +71,20 @@ public class MmsDownloader extends MmscProcessor {
|
|||||||
getApnInformation());
|
getApnInformation());
|
||||||
RetrieveConf retrieved = (RetrieveConf)new PduParser(pdu).parse();
|
RetrieveConf retrieved = (RetrieveConf)new PduParser(pdu).parse();
|
||||||
|
|
||||||
|
if (retrieved == null)
|
||||||
|
throw new IOException("Bad retrieved PDU");
|
||||||
|
|
||||||
for (int i=0;i<retrieved.getBody().getPartsNum();i++) {
|
for (int i=0;i<retrieved.getBody().getPartsNum();i++) {
|
||||||
Log.w("MmsDownloader", "Sent MMS part of content-type: " + new String(retrieved.getBody().getPart(i).getContentType()));
|
Log.w("MmsDownloader", "Sent MMS part of content-type: " +
|
||||||
|
new String(retrieved.getBody().getPart(i).getContentType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retrieved == null)
|
|
||||||
throw new IOException("Bad retrieved PDU");
|
|
||||||
|
|
||||||
|
|
||||||
if (retrieved.getSubject() != null && WirePrefix.isEncryptedMmsSubject(retrieved.getSubject().getString())) {
|
if (retrieved.getSubject() != null && WirePrefix.isEncryptedMmsSubject(retrieved.getSubject().getString())) {
|
||||||
long messageId = mmsDatabase.insertSecureMessageReceived(retrieved, item.getContentLocation(), item.getThreadId());
|
long messageId = mmsDatabase.insertSecureMessageReceived(retrieved, item.getContentLocation(), item.getThreadId());
|
||||||
if (item.getMasterSecret() != null)
|
if (item.getMasterSecret() != null)
|
||||||
DecryptingQueue.scheduleDecryption(context, item.getMasterSecret(), messageId, item.getThreadId(), retrieved);
|
DecryptingQueue.scheduleDecryption(context, item.getMasterSecret(), messageId, item.getThreadId(), retrieved);
|
||||||
} else {
|
} else {
|
||||||
mmsDatabase.insertMessageReceived(retrieved, item.getContentLocation(), item.getThreadId());
|
mmsDatabase.insertMessageReceived(retrieved, item.getContentLocation(), item.getThreadId());
|
||||||
}
|
}
|
||||||
|
|
||||||
mmsDatabase.delete(item.getMessageId());
|
mmsDatabase.delete(item.getMessageId());
|
||||||
@ -93,7 +93,7 @@ public class MmsDownloader extends MmscProcessor {
|
|||||||
// MmsSendHelper.sendMms(context, new PduComposer(context, notifyResponse).make());
|
// MmsSendHelper.sendMms(context, new PduComposer(context, notifyResponse).make());
|
||||||
|
|
||||||
if (this.pendingMessages.isEmpty())
|
if (this.pendingMessages.isEmpty())
|
||||||
finishConnectivity();
|
finishConnectivity();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
DatabaseFactory.getMmsDatabase(context).markDownloadState(item.getMessageId(), MmsDatabase.Types.DOWNLOAD_SOFT_FAILURE);
|
DatabaseFactory.getMmsDatabase(context).markDownloadState(item.getMessageId(), MmsDatabase.Types.DOWNLOAD_SOFT_FAILURE);
|
||||||
@ -109,10 +109,10 @@ public class MmsDownloader extends MmscProcessor {
|
|||||||
protected void handleConnectivityChange() {
|
protected void handleConnectivityChange() {
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
if (!isConnectivityPossible() && !pendingMessages.isEmpty()) {
|
if (!isConnectivityPossible() && !pendingMessages.isEmpty()) {
|
||||||
DatabaseFactory.getMmsDatabase(context).markDownloadState(pendingMessages.remove().getMessageId(), MmsDatabase.Types.DOWNLOAD_NO_CONNECTIVITY);
|
DatabaseFactory.getMmsDatabase(context).markDownloadState(pendingMessages.remove().getMessageId(), MmsDatabase.Types.DOWNLOAD_NO_CONNECTIVITY);
|
||||||
toastHandler.makeToast("No connectivity available for MMS download, try again later...");
|
toastHandler.makeToast("No connectivity available for MMS download, try again later...");
|
||||||
Log.w("MmsDownloadService", "Unable to download MMS, please try again later.");
|
Log.w("MmsDownloadService", "Unable to download MMS, please try again later.");
|
||||||
finishConnectivity();
|
finishConnectivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -125,10 +125,10 @@ public class MmsDownloader extends MmscProcessor {
|
|||||||
public void process(MasterSecret masterSecret, Intent intent) {
|
public void process(MasterSecret masterSecret, Intent intent) {
|
||||||
if (intent.getAction().equals(SendReceiveService.DOWNLOAD_MMS_ACTION)) {
|
if (intent.getAction().equals(SendReceiveService.DOWNLOAD_MMS_ACTION)) {
|
||||||
DownloadItem item = new DownloadItem(intent.getLongExtra("message_id", -1),
|
DownloadItem item = new DownloadItem(intent.getLongExtra("message_id", -1),
|
||||||
intent.getLongExtra("thread_id", -1),
|
intent.getLongExtra("thread_id", -1),
|
||||||
intent.getStringExtra("content_location"),
|
intent.getStringExtra("content_location"),
|
||||||
intent.getByteArrayExtra("transaction_id"),
|
intent.getByteArrayExtra("transaction_id"),
|
||||||
masterSecret);
|
masterSecret);
|
||||||
|
|
||||||
handleDownloadMms(item);
|
handleDownloadMms(item);
|
||||||
} else if (intent.getAction().equals(SendReceiveService.DOWNLOAD_MMS_CONNECTIVITY_ACTION)) {
|
} else if (intent.getAction().equals(SendReceiveService.DOWNLOAD_MMS_CONNECTIVITY_ACTION)) {
|
||||||
@ -174,9 +174,7 @@ public class MmsDownloader extends MmscProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getConnectivityAction() {
|
protected String getConnectivityAction() {
|
||||||
return SendReceiveService.DOWNLOAD_MMS_CONNECTIVITY_ACTION;
|
return SendReceiveService.DOWNLOAD_MMS_CONNECTIVITY_ACTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user