From 07b0724a559e3c2339197c4b85fdb2706fb9edd0 Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Mon, 9 Oct 2023 14:33:06 +0530 Subject: [PATCH] message: Implement getMmscInfoForReceptionAck properly --- .../send_message/MmsReceivedReceiver.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/android-smsmms/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java b/android-smsmms/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java index b8da3699a..9660ab218 100755 --- a/android-smsmms/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java +++ b/android-smsmms/src/main/java/com/klinker/android/send_message/MmsReceivedReceiver.java @@ -19,8 +19,10 @@ package com.klinker.android.send_message; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.net.Uri; import android.os.AsyncTask; +import android.preference.PreferenceManager; import android.provider.Telephony; import android.telephony.SmsManager; import com.android.mms.service_alt.DownloadRequest; @@ -65,13 +67,15 @@ public class MmsReceivedReceiver extends BroadcastReceiver { private static final ExecutorService RECEIVE_NOTIFICATION_EXECUTOR = Executors.newSingleThreadExecutor(); - public MmscInformation getMmscInfoForReceptionAck() { - // Override this and provide the MMSC to send the ACK to. - // some carriers will download duplicate MMS messages without this ACK. When using the - // system sending method, apparently Google does not do this for us. Not sure why. - // You might have to have users manually enter their APN settings if you cannot get them - // from the system somehow. + public MmscInformation getMmscInfoForReceptionAck(Context context) { + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + String mmsc_url = sharedPrefs.getString("mmsc_url", ""); + String mmsc_proxy = sharedPrefs.getString("mms_proxy", ""); + String mmsc_port = sharedPrefs.getString("mms_port", ""); + if (!mmsc_url.isEmpty() && !mmsc_proxy.isEmpty() && !mmsc_port.isEmpty()) { + return new MmscInformation(mmsc_url, mmsc_proxy, Integer.parseInt(mmsc_port)); + } return null; } @@ -326,7 +330,7 @@ public class MmsReceivedReceiver extends BroadcastReceiver { return null; } - if (getMmscInfoForReceptionAck() == null) { + if (getMmscInfoForReceptionAck(context) == null) { Timber.v("No MMSC information set, so no notification tasks will be able to complete"); return null; } @@ -341,7 +345,7 @@ public class MmsReceivedReceiver extends BroadcastReceiver { try { final NotificationInd ind = getNotificationInd(context, intent); - final MmscInformation mmsc = getMmscInfoForReceptionAck(); + final MmscInformation mmsc = getMmscInfoForReceptionAck(context); final TransactionSettings transactionSettings = new TransactionSettings(mmsc.mmscUrl, mmsc.mmsProxy, mmsc.proxyPort); final List responseTasks = new ArrayList<>(); -- GitLab