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

Commit 7c1e3704 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed data leak after emergency call

Fixed a regression introduced in ag/17492053 where we
allowed SUPL request during emergency call or ECBM. The
incorrect logic made data leak always repro'd by hangup
an emergency call and then turn off data. Even without a SUPL
request, the internet data remains on after data disabled
because the network was incorrected treated as SUPL network.

Fix: 233589320
Test: Basic testing + atest DataNetworkControllerTest
Change-Id: I576be6e89193df30799918e8ab009e1dc228d61b
parent 229cbaf2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2979,6 +2979,14 @@ public class DataNetwork extends StateMachine {
                        NetworkCapabilities.NET_CAPABILITY_NOT_VPN);
    }

    /**
     * @return {@code true} if this network was setup for SUPL during emergency call. {@code false}
     * otherwise.
     */
    public boolean isEmergencySupl() {
        return mDataAllowedReason == DataAllowedReason.EMERGENCY_SUPL;
    }

    /**
     * Get precise data connection state
     *
+1 −3
Original line number Diff line number Diff line
@@ -1716,9 +1716,7 @@ public class DataNetworkController extends Handler {
            // If there are reasons we should tear down the network, check if those are hard reasons
            // or soft reasons. In some scenarios, we can make exceptions if they are soft
            // disallowed reasons.
            if ((mPhone.isInEmergencyCall() || mPhone.isInEcm())
                    && dataNetwork.getNetworkCapabilities().hasCapability(
                            NetworkCapabilities.NET_CAPABILITY_SUPL)) {
            if ((mPhone.isInEmergencyCall() || mPhone.isInEcm()) && dataNetwork.isEmergencySupl()) {
                // Check if it's SUPL during emergency call.
                evaluation.addDataAllowedReason(DataAllowedReason.EMERGENCY_SUPL);
            } else if (!dataNetwork.getNetworkCapabilities().hasCapability(
+19 −0
Original line number Diff line number Diff line
@@ -2705,6 +2705,25 @@ public class DataNetworkControllerTest extends TelephonyTest {
        verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_MMS);
    }

    @Test
    public void testEmergencyCallDataDisabled() throws Exception {
        doReturn(true).when(mPhone).isInEmergencyCall();
        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_INTERNET));
        processAllMessages();

        verifyInternetConnected();

        // Data disabled
        mDataNetworkControllerUT.getDataSettingsManager().setDataEnabled(
                TelephonyManager.DATA_ENABLED_REASON_USER, false, mContext.getOpPackageName());
        processAllMessages();

        // Make sure internet is not connected. (Previously it has a bug due to incorrect logic
        // to determine it's for emergency SUPL).
        verifyAllDataDisconnected();
    }

    @Test
    public void testDataActivity() {
        doReturn(TelephonyManager.DATA_ACTIVITY_IN).when(mLinkBandwidthEstimator).getDataActivity();