Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f10c8ac7 authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

Merge branch '7071-main-mms_duplicate' into 'main'

message: Implement getMmscInfoForReceptionAck properly

See merge request e/os/Message!75
parents 87989233 07b0724a
Loading
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -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<CommonAsyncTask> responseTasks = new ArrayList<>();