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

Commit f51deb94 authored by Sarah Chin's avatar Sarah Chin
Browse files

Remove dynamic unmetered when capabilities are static unmetered

Static unmetered only when APN unmetered by carrier config
Tear down and set up connections on carrier config change to ensure data
connections don't switch from unmetered -> metered

Test: atest DataConnectionTest
Bug: 153118339
Change-Id: I309f0a62d3b5173b38cc2253ca44482a37644d51
Merged-In: I309f0a62d3b5173b38cc2253ca44482a37644d51
parent 75c77f6a
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -1309,7 +1309,6 @@ public class DataConnection extends StateMachine {
    public NetworkCapabilities getNetworkCapabilities() {
        NetworkCapabilities result = new NetworkCapabilities();
        result.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
        boolean areAllApnsUnmetered = false;

        if (mApnSetting != null) {
            final String[] types = ApnSetting.getApnTypesStringFromBitmask(
@@ -1384,10 +1383,8 @@ public class DataConnection extends StateMachine {
            // DataConnection has the immutable NOT_METERED capability only if all APNs in the
            // APN setting are unmetered according to carrier config METERED_APN_TYPES_STRINGS.
            // All other cases should use the dynamic TEMPORARILY_NOT_METERED capability instead.
            if (!ApnSettingUtils.isMetered(mApnSetting, mPhone)) {
                result.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
                areAllApnsUnmetered = true;
            }
            result.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED,
                    !ApnSettingUtils.isMetered(mApnSetting, mPhone));

            if (result.deduceRestrictedCapability()) {
                result.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
@@ -1413,14 +1410,12 @@ public class DataConnection extends StateMachine {
            result.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED);
        }

        // Mark TEMPORARILY_NOT_METERED in the following cases,
        // Mark TEMPORARILY_NOT_METERED in the following cases:
        // 1. The non-restricted data is intended for unmetered use only.
        // 2. DcTracker set an unmetered override due to network/location (eg. 5G).
        // 3. SubscriptionManager set an unmetered override as requested by policy.
        // 4. All attached APN contexts for this DataConnection are unmetered
        if ((mUnmeteredUseOnly && !mRestrictedNetworkOverride) || mUnmeteredOverride
                || (mSubscriptionOverride & SUBSCRIPTION_OVERRIDE_UNMETERED) != 0
                || areAllApnsUnmetered) {
                || (mSubscriptionOverride & SUBSCRIPTION_OVERRIDE_UNMETERED) != 0) {
            result.addCapability(NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED);
        } else {
            result.removeCapability(NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED);
+1 −0
Original line number Diff line number Diff line
@@ -2304,6 +2304,7 @@ public class DcTracker extends Handler {
            setDataProfilesAsNeeded();
            setInitialAttachApn();
            sortApnContextByPriority();
            cleanUpConnectionsOnUpdatedApns(true, Phone.REASON_CARRIER_CHANGE);
            setupDataOnAllConnectableApns(Phone.REASON_CARRIER_CHANGE, RetryFailures.ALWAYS);
        } else {
            log("onCarrierConfigChanged: SIM is not loaded yet.");
+0 −1
Original line number Diff line number Diff line
@@ -634,7 +634,6 @@ public class DataConnectionTest extends TelephonyTest {
        testConnectEvent();

        assertTrue(getNetworkCapabilities().hasCapability(NET_CAPABILITY_NOT_METERED));
        assertTrue(getNetworkCapabilities().hasCapability(NET_CAPABILITY_TEMPORARILY_NOT_METERED));
    }

    @Test