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

Commit e6ef5b84 authored by João Ventura's avatar João Ventura
Browse files

Framework: Fixes mms automatic retrieval (2/2)

Currently, in the framework, mobile data connections using APN's can only be
made when the user has explicitly switched on mobile data connections.
This patch allows to automatically open connections to APN_TYPE_MMS mobile
networks. It only opens connections in roaming if the user has selected the
option in Settings.

This allows for the automatically download of mms.

Part 1 in Ibfcbcec8

Patchset 1: Initial patch
Patchset 2: Moved logic to a canSetupData(ApnContext) method
Patchset 3: Checks for system-wide properties if can retrieve mms automatically

Change-Id: I824c7b48d8d534f372e9eccb05fd7e4db226be92
parent 3c6dbc3d
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -181,6 +181,18 @@ public interface TelephonyProperties
     */
    static final String PROPERTY_SMS_SEND = "telephony.sms.send";

    /**
     * Set to false to disable MMS automatic retrieval of content,
     * default is true
     */
    static final String PROPERTY_MMS_AUTO_RETRIEVAL = "persist.sys.mms_auto_retrieval";

    /**
     * Set to false to disable MMS automatic retrieval during roaming,
     * default is false
     */
    static final String PROPERTY_MMS_AUTO_RETRIEVAL_ON_ROAMING = "persist.sys.mms_auto_on_roaming";

    /**
     * Set to true to indicate a test CSIM card is used in the device.
     * This property is for testing purpose only. This should not be defined
+38 −3
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RetryManager;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.util.AsyncChannel;

import java.io.FileDescriptor;
@@ -757,8 +758,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {

        boolean desiredPowerState = mPhone.getServiceStateTracker().getDesiredPowerState();

        if ((apnContext.getState() == State.IDLE || apnContext.getState() == State.SCANNING) &&
                isDataAllowed(apnContext) && getAnyDataEnabled() && !isEmergency()) {
        if (canSetupData(apnContext)) {

            if (apnContext.getState() == State.IDLE) {
                ArrayList<ApnSetting> waitingApns = buildWaitingApns(apnContext.getApnType());
@@ -793,6 +793,41 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }
    }

    /**
     * Report on whether data connectivity can be setup for any APN.
     * APN_TYPE_MMS connectivity can always be setup, except on roaming with data disabled
     * @param apnContext The apnContext
     * @return boolean
     */
    private boolean canSetupData(ApnContext apnContext) {
        if (apnContext.getState() != State.IDLE && apnContext.getState() != State.SCANNING) {
            return false;
        }

        if (isDataAllowed(apnContext) && getAnyDataEnabled() && !isEmergency()) {
            return true;
        }

        boolean mmsAutoRetrieval = SystemProperties.getBoolean(
                TelephonyProperties.PROPERTY_MMS_AUTO_RETRIEVAL, true);
        boolean mmsRetrievalRoaming = SystemProperties.getBoolean(
                TelephonyProperties.PROPERTY_MMS_AUTO_RETRIEVAL_ON_ROAMING, false);

        // Allow automatic Mms connections if user has enabled it system-wide
        if (mmsAutoRetrieval && apnContext.getApnType().equals(Phone.APN_TYPE_MMS)) {
            /* don't allow MMS connections on roaming if data roaming is disabled (in Settings
             * and in the Mms application) */
            TelephonyManager tm = (TelephonyManager)
                    mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE);
            if (tm.isNetworkRoaming() && !mPhone.getDataRoamingEnabled() && !mmsRetrievalRoaming)
                return false;

            return true;
        }

        return false;
    }

    @Override
    // Disabled apn's still need avail/unavail notificiations - send them out
    protected void notifyOffApnsOfAvailability(String reason) {