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

Commit 5292d0e2 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Support requesting restricted default

Fixes a bug where if we had a restricted request up when data became
unrestricted (either user or carrier enabled data) we wouldn't get a
general purpose, unrestricted connection.

bug:28567303
Change-Id: Ib10f495e705c3a1a1bd283d84ba8353485c672fe
parent 5523cc4c
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -890,6 +890,7 @@ public class DcTracker extends Handler {
                }

                if (enabled) {
                    teardownRestrictedMeteredConnections();
                    onTrySetupData(Phone.REASON_DATA_ENABLED);
                } else {
                    onCleanUpAllConnections(Phone.REASON_DATA_SPECIFIC_DISABLED);
@@ -898,9 +899,32 @@ public class DcTracker extends Handler {
        }
    }

    /**
     * Handle reverting restricted networks back to unrestricted.
     * If we're changing user data to enabled and this makes data
     * truely enabled (not disabled by other factors) we need to
     * tear down any metered apn type that was enabled anyway by
     * a privileged request.  This allows us to reconnect
     * to it in an unrestricted way.
     */
    private void teardownRestrictedMeteredConnections() {
        if (isDataEnabled(true)) {
            for (ApnContext apnContext : mApnContexts.values()) {
                if (apnContext.isConnectedOrConnecting() &&
                        apnContext.getApnSetting().isMetered(mPhone.getContext(),
                        mPhone.getSubId(), mPhone.getServiceState().getDataRoaming())) {
                    if (DBG) log("tearing down restricted metered net: " + apnContext);
                    apnContext.setReason(Phone.REASON_DATA_ENABLED);
                    cleanUpConnection(true, apnContext);
                }
            }
        }
    }

    private void onDeviceProvisionedChange() {
        if (getDataEnabled()) {
            mUserDataEnabled = true;
            teardownRestrictedMeteredConnections();
            onTrySetupData(Phone.REASON_DATA_ENABLED);
        } else {
            mUserDataEnabled = false;
@@ -2360,6 +2384,7 @@ public class DcTracker extends Handler {
                // Tear down all metered apns
                cleanUpAllConnections(true, Phone.REASON_CARRIER_ACTION_DISABLE_METERED_APN);
            } else {
                teardownRestrictedMeteredConnections();
                setupDataOnConnectableApns(Phone.REASON_DATA_ENABLED);
            }
        }
@@ -2409,6 +2434,7 @@ public class DcTracker extends Handler {
                sPolicyDataEnabled = enabled;
                if (prevEnabled != getAnyDataEnabled()) {
                    if (!prevEnabled) {
                        teardownRestrictedMeteredConnections();
                        onTrySetupData(Phone.REASON_DATA_ENABLED);
                    } else {
                        onCleanUpAllConnections(Phone.REASON_DATA_SPECIFIC_DISABLED);