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

Commit 443b0ae9 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Exclude DUN from data-disabled override.

Don't use DUN's restricted status to override the user, carrier
or netpolicy control over metered networks.  This should be fixed
better in the future, but this targeted fix should be good for now.

bug:30120613
Change-Id: I38217b6537cc66b4d678fb82d7fa95388d5a5d6c
parent c73180f2
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -450,9 +450,14 @@ public class ApnContext {
        }
    }

    public boolean hasNoRestrictedRequests() {
    public boolean hasNoRestrictedRequests(boolean excludeDun) {
        synchronized (mRefCountLock) {
            for (NetworkRequest nr : mNetworkRequests) {
                if (excludeDun &&
                        nr.networkCapabilities.hasCapability(
                        NetworkCapabilities.NET_CAPABILITY_DUN)) {
                    continue;
                }
                if (nr.networkCapabilities.hasCapability(
                        NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) == false) {
                    return false;
+5 −2
Original line number Diff line number Diff line
@@ -860,7 +860,7 @@ public class DataConnection extends StateMachine {
        // first, if we have no restricted requests, this override can stay FALSE:
        boolean noRestrictedRequests = true;
        for (ApnContext apnContext : mApnContexts.keySet()) {
            noRestrictedRequests &= apnContext.hasNoRestrictedRequests();
            noRestrictedRequests &= apnContext.hasNoRestrictedRequests(true /* exclude DUN */);
        }
        if (noRestrictedRequests) {
            return;
@@ -948,6 +948,8 @@ public class DataConnection extends StateMachine {
        }
        if (mRestrictedNetworkOverride) {
            result.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
            // don't use dun on restriction-overriden networks.
            result.removeCapability(NetworkCapabilities.NET_CAPABILITY_DUN);
        }

        int up = 14;
@@ -2055,7 +2057,8 @@ public class DataConnection extends StateMachine {
                + " mLastFailCause=" + mLastFailCause
                + " mTag=" + mTag
                + " mLinkProperties=" + mLinkProperties
                + " linkCapabilities=" + makeNetworkCapabilities();
                + " linkCapabilities=" + makeNetworkCapabilities()
                + " mRestrictedNetworkOverride=" + mRestrictedNetworkOverride;
    }

    @Override
+3 −1
Original line number Diff line number Diff line
@@ -1514,10 +1514,12 @@ public class DcTracker extends Handler {
        // request for the network.
        // TODO - may want restricted requests to only apply to carrier-limited data access
        //        rather than applying to user limited as well.
        // Exclude DUN for the purposes of the override until we get finer grained
        // intention in NetworkRequests
        boolean checkUserDataEnabled =
                ApnSetting.isMeteredApnType(apnContext.getApnType(), mPhone.getContext(),
                        mPhone.getSubId(), mPhone.getServiceState().getDataRoaming()) &&
                apnContext.hasNoRestrictedRequests();
                apnContext.hasNoRestrictedRequests(true /*exclude DUN */);

        DataAllowFailReason failureReason = new DataAllowFailReason();