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

Commit 998c9978 authored by Yashdev Singh's avatar Yashdev Singh
Browse files

Telephony: Add new api isMmsDataConnectivityPossible.

- New api for apps preemptive active.

Change-Id: Ic1c06ff2038d5500afc156aa5c0fbd79878f9a25
parent 2b30225d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1447,6 +1447,11 @@ public interface Phone {
     */
    boolean isDataConnectivityPossible();

    /**
     * Report on whether on-demand data connectivity is allowed.
     */
    boolean isOnDemandDataPossible(String apnType);

    /**
     * Report on whether data connectivity is allowed for an APN.
     */
+6 −0
Original line number Diff line number Diff line
@@ -1714,6 +1714,12 @@ public abstract class PhoneBase extends Handler implements Phone {
        return isDataConnectivityPossible(PhoneConstants.APN_TYPE_DEFAULT);
    }

    @Override
    public boolean isOnDemandDataPossible(String apnType) {
        return ((mDcTracker != null) &&
                (mDcTracker.isOnDemandDataPossible(apnType)));
    }

    @Override
    public boolean isDataConnectivityPossible(String apnType) {
        return ((mDcTracker != null) &&
+5 −0
Original line number Diff line number Diff line
@@ -1010,6 +1010,11 @@ public class PhoneProxy extends Handler implements Phone {
        return mActivePhone.isDataConnectivityPossible(PhoneConstants.APN_TYPE_DEFAULT);
    }

    @Override
    public boolean isOnDemandDataPossible(String apnType) {
        return mActivePhone.isOnDemandDataPossible(apnType);
    }

    @Override
    public boolean isDataConnectivityPossible(String apnType) {
        return mActivePhone.isDataConnectivityPossible(apnType);
+35 −14
Original line number Diff line number Diff line
@@ -751,6 +751,40 @@ public final class DcTracker extends DcTrackerBase {
        return (apnContext.getDcAc() != null);
    }

    @Override
    public boolean isOnDemandDataPossible(String apnType) {
        /*
         * Check if APN enabled
         * Check if MobileData is ON
         * Check if MobileData UI override present
         */

        boolean flag = false;
        ApnContext apnContext = mApnContexts.get(apnType);
        if (apnContext == null) {
            return false;
        }
        boolean apnContextIsEnabled = apnContext.isEnabled();

        DctConstants.State apnContextState = apnContext.getState();
        boolean apnTypePossible = !(apnContextIsEnabled &&
                (apnContextState == DctConstants.State.FAILED));

        boolean userDataEnabled = mUserDataEnabled;

        if (PhoneConstants.APN_TYPE_MMS.equals(apnType)) {
            boolean mobileDataOffOveride = mPhone.getContext().getResources().
                getBoolean(com.android.internal.R.bool.config_enable_mms_with_mobile_data_off);
            log("isOnDemandDataPossible MobileDataEnabled override = " + mobileDataOffOveride);

            userDataEnabled = (mUserDataEnabled || mobileDataOffOveride);
        }

        flag = apnTypePossible && userDataEnabled;
        log("isOnDemandDataPossible, possible =" + flag + ", apnContext = " + apnContext);
        return flag;
    }

    @Override
    public boolean isDataPossible(String apnType) {
        ApnContext apnContext = mApnContexts.get(apnType);
@@ -2013,20 +2047,7 @@ public final class DcTracker extends DcTrackerBase {
                }
            } else if (met) {
                apnContext.setReason(Phone.REASON_DATA_DISABLED);
                // If ConnectivityService has disabled this network, stop trying to bring
                // it up, but do not tear it down - ConnectivityService will do that
                // directly by talking with the DataConnection.
                //
                // This doesn't apply to DUN, however.  Those connections have special
                // requirements from carriers and we need stop using them when the dun
                // request goes away.  This applies to both CDMA and GSM because they both
                // can declare the DUN APN sharable by default traffic, thus still satisfying
                // those requests and not torn down organically.
                if (apnContext.getApnType() == PhoneConstants.APN_TYPE_DUN && teardownForDun()) {
                    cleanup = true;
                } else {
                    cleanup = false;
                }

            } else {
                apnContext.setReason(Phone.REASON_DATA_DEPENDENCY_UNMET);
            }
+1 −0
Original line number Diff line number Diff line
@@ -765,6 +765,7 @@ public abstract class DcTrackerBase extends Handler {
    protected abstract void onCleanUpConnection(boolean tearDown, int apnId, String reason);
    protected abstract void onCleanUpAllConnections(String cause);
    public abstract boolean isDataPossible(String apnType);
    public abstract boolean isOnDemandDataPossible(String apnType);
    protected abstract boolean onUpdateIcc();
    protected abstract void completeConnection(ApnContext apnContext);
    public abstract void setDataAllowed(boolean enable, Message response);