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

Commit 616fe42f authored by Jayachandran C's avatar Jayachandran C Committed by Jayachandran Chinnakkannu
Browse files

Skip handling validation status for non default data connections

The non default data connections doesn't go through network validation
procedure but connectivity service report validation success always.
DcTracker incorrectly noted this as a good signal and later triggered
a recovery when bad network is reported for default data connection.
This causes unnecessary data stall recovery and causes lab test failure.

This CL adds a check to handle network validation events only from
data connections that goes through network validation.

Bug: 135292998
Bug: 144369179
Test: atest com.android.internal.telephony.dataconnection.DcTrackerTest
Change-Id: Iebe429f24fb16fd2748ac63adf6f875c4b398d7d
parent 6e6e56fc
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1329,6 +1329,16 @@ public class DataConnection extends StateMachine {
        return result;
    }

    /** @return {@code true} if validation is required, {@code false} otherwise. */
    public boolean isValidationRequired() {
        final NetworkCapabilities nc = getNetworkCapabilities();
        return nc != null
                && nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                && nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
                && nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED)
                && nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN);
    }

    /**
     * @return {@code True} if 464xlat should be skipped.
     */
+1 −1
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public class DcNetworkAgent extends NetworkAgent {
        DcTracker dct = mPhone.getDcTracker(mTransportType);
        if (dct != null) {
            Message msg = dct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                    status, 0, redirectUrl);
                    status, mDataConnection.getCid(), redirectUrl);
            msg.sendToTarget();
        }
    }
+8 −3
Original line number Diff line number Diff line
@@ -2920,10 +2920,11 @@ public class DcTracker extends Handler {
     *
     * @param status One of {@code NetworkAgent.VALID_NETWORK} or
     * {@code NetworkAgent.INVALID_NETWORK}.
     * @param cid context id {@code cid}
     * @param redirectUrl If the Internet probe was redirected, this
     * is the destination it was redirected to, otherwise {@code null}
     */
    private void onNetworkStatusChanged(int status, String redirectUrl) {
    private void onNetworkStatusChanged(int status, int cid, String redirectUrl) {
        if (!TextUtils.isEmpty(redirectUrl)) {
            Intent intent = new Intent(TelephonyIntents.ACTION_CARRIER_SIGNAL_REDIRECTED);
            intent.putExtra(TelephonyIntents.EXTRA_REDIRECTION_URL_KEY, redirectUrl);
@@ -2931,6 +2932,7 @@ public class DcTracker extends Handler {
            log("Notify carrier signal receivers with redirectUrl: " + redirectUrl);
        } else {
            final boolean isValid = status == NetworkAgent.VALID_NETWORK;
            final DataConnection dc = getDataConnectionByContextId(cid);
            if (!mDsRecoveryHandler.isRecoveryOnBadNetworkEnabled()) {
                if (DBG) log("Skip data stall recovery on network status change with in threshold");
                return;
@@ -2939,9 +2941,11 @@ public class DcTracker extends Handler {
                if (DBG) log("Skip data stall recovery on non WWAN");
                return;
            }
            if (dc != null && dc.isValidationRequired()) {
                mDsRecoveryHandler.processNetworkStatusChanged(isValid);
            }
        }
    }

    /**
     * Called when EVENT_DISCONNECT_DONE is received.
@@ -3583,8 +3587,9 @@ public class DcTracker extends Handler {

            case DctConstants.EVENT_NETWORK_STATUS_CHANGED:
                int status = msg.arg1;
                int cid = msg.arg2;
                String url = (String) msg.obj;
                onNetworkStatusChanged(status, url);
                onNetworkStatusChanged(status, cid, url);
                break;

            case DctConstants.EVENT_RADIO_AVAILABLE:
+9 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.telephony.data.DataCallResponse;
import android.telephony.data.DataProfile;
import android.telephony.emergency.EmergencyNumber;
@@ -1179,6 +1180,14 @@ public class SimulatedCommands extends BaseCommands
            }
        }

        // Store different cids to simulate concurrent IMS and default data calls
        if ((dataProfile.getSupportedApnTypesBitmask() & ApnSetting.TYPE_IMS)
            == ApnSetting.TYPE_IMS) {
            mSetupDataCallResult.cid = 0;
        } else {
            mSetupDataCallResult.cid = 1;
        }

        DataCallResponse response = RIL.convertDataCallResult(mSetupDataCallResult);
        if (mDcSuccess) {
            resultSuccess(result, response);
+10 −7
Original line number Diff line number Diff line
@@ -1597,16 +1597,17 @@ public class DcTrackerTest extends TelephonyTest {
                eq(AccessNetworkType.EUTRAN), dpCaptor.capture(),
                eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(),
                any(Message.class));
        waitForMs(200);
        verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);

        logd("Sending EVENT_NETWORK_STATUS_CHANGED");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                NetworkAgent.VALID_NETWORK, 0, null));
                NetworkAgent.VALID_NETWORK, 1, null));
        waitForMs(200);

        logd("Sending EVENT_NETWORK_STATUS_CHANGED");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                NetworkAgent.INVALID_NETWORK, 0, null));
                NetworkAgent.INVALID_NETWORK, 1, null));
        waitForMs(200);

        // Verify that its no-op when the new data stall detection feature is disabled
@@ -1638,16 +1639,17 @@ public class DcTrackerTest extends TelephonyTest {
                eq(AccessNetworkType.EUTRAN), dpCaptor.capture(),
                eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(),
                any(Message.class));
        waitForMs(200);
        verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);

        logd("Sending EVENT_NETWORK_STATUS_CHANGED");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                NetworkAgent.VALID_NETWORK, 0, null));
                NetworkAgent.VALID_NETWORK, 1, null));
        waitForMs(200);

        logd("Sending EVENT_NETWORK_STATUS_CHANGED");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                NetworkAgent.INVALID_NETWORK, 0, null));
                NetworkAgent.INVALID_NETWORK, 1, null));
        waitForMs(200);

        verify(mSimulatedCommandsVerifier, times(1)).getDataCallList(any(Message.class));
@@ -1680,11 +1682,12 @@ public class DcTrackerTest extends TelephonyTest {
                eq(AccessNetworkType.EUTRAN), dpCaptor.capture(),
                eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(),
                any(Message.class));
        waitForMs(200);
        verifyDataProfile(dpCaptor.getValue(), FAKE_APN1, 0, 21, 1, NETWORK_TYPE_LTE_BITMASK);

        logd("Sending EVENT_NETWORK_STATUS_CHANGED false");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                NetworkAgent.INVALID_NETWORK, 0, null));
                NetworkAgent.INVALID_NETWORK, 1, null));
        waitForMs(200);

        // expected tear down all DataConnections
@@ -1724,7 +1727,7 @@ public class DcTrackerTest extends TelephonyTest {

        logd("Sending EVENT_NETWORK_STATUS_CHANGED false");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                NetworkAgent.INVALID_NETWORK, 0, null));
                NetworkAgent.INVALID_NETWORK, 1, null));
        waitForMs(200);

        // expected to get preferred network type
@@ -1761,7 +1764,7 @@ public class DcTrackerTest extends TelephonyTest {

        logd("Sending EVENT_NETWORK_STATUS_CHANGED false");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_NETWORK_STATUS_CHANGED,
                NetworkAgent.INVALID_NETWORK, 0, null));
                NetworkAgent.INVALID_NETWORK, 1, null));
        waitForMs(200);

        // expected to get preferred network type