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

Commit 4bdffb3c authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Fixed data leak after emergency call" into tm-dev

parents b8a0c775 7c1e3704
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
@@ -1721,9 +1721,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();