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

Commit 76c5a947 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Don't tear down a network unnecessarily.

If conditions ease so restricted networks are now allowed don't
just assume every up network needs to be torn down.  Instead
check and see if it's marked restricted (or not, not-restricted)
first.

bug:30490689
Change-Id: Ib19d45979f6f9e0b605a3e5b39f569a01d30d42b
parent 68d7118d
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -909,6 +909,17 @@ public class DcTracker extends Handler {
                if (apnContext.isConnectedOrConnecting() &&
                if (apnContext.isConnectedOrConnecting() &&
                        apnContext.getApnSetting().isMetered(mPhone.getContext(),
                        apnContext.getApnSetting().isMetered(mPhone.getContext(),
                        mPhone.getSubId(), mPhone.getServiceState().getDataRoaming())) {
                        mPhone.getSubId(), mPhone.getServiceState().getDataRoaming())) {

                    final DcAsyncChannel dataConnectionAc = apnContext.getDcAc();
                    if (dataConnectionAc != null) {
                        final NetworkCapabilities nc =
                                dataConnectionAc.getNetworkCapabilitiesSync();
                        if (nc != null && nc.hasCapability(NetworkCapabilities.
                              NET_CAPABILITY_NOT_RESTRICTED)) {
                            if (DBG) log("not tearing down unrestricted metered net:" + apnContext);
                            continue;
                        }
                    }
                    if (DBG) log("tearing down restricted metered net: " + apnContext);
                    if (DBG) log("tearing down restricted metered net: " + apnContext);
                    apnContext.setReason(Phone.REASON_DATA_ENABLED);
                    apnContext.setReason(Phone.REASON_DATA_ENABLED);
                    cleanUpConnection(true, apnContext);
                    cleanUpConnection(true, apnContext);