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

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

Merge "Fixed delay IMS tear down" into tm-dev

parents 9c8f6e98 5cfb1dfc
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public class DataNetwork extends StateMachine {
                    TEAR_DOWN_REASON_DATA_PROFILE_NOT_PREFERRED,
                    TEAR_DOWN_REASON_NOT_ALLOWED_BY_POLICY,
                    TEAR_DOWN_REASON_ILLEGAL_STATE,
                    TEAR_DOWN_ONLY_ALLOWED_SINGLE_NETWORK,
                    TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK,
            })
    public @interface TearDownReason {}

@@ -359,7 +359,7 @@ public class DataNetwork extends StateMachine {
    public static final int TEAR_DOWN_REASON_ILLEGAL_STATE = 28;

    /** Data network tear down due to only allowed single network. */
    public static final int TEAR_DOWN_ONLY_ALLOWED_SINGLE_NETWORK = 29;
    public static final int TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK = 29;

    @IntDef(prefix = {"BANDWIDTH_SOURCE_"},
            value = {
@@ -1175,10 +1175,24 @@ public class DataNetwork extends StateMachine {
                        log("Ignore tear down request because network is being torn down.");
                        break;
                    }

                    int tearDownReason = msg.arg1;
                    // If the tear down request is from upper layer, for example, IMS service
                    // releases network request, we don't need to delay. The purpose of the delay
                    // is to have IMS service have time to perform IMS de-registration, so if this
                    // request is from IMS service itself, that means IMS service is already aware
                    // of the tear down. So there is no need to delay in this case.
                    if (tearDownReason != TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED
                            && shouldDelayTearDown()) {
                        logl("Delay IMS tear down until call ends. reason="
                                + tearDownReasonToString(tearDownReason));
                        break;
                    }

                    removeMessages(EVENT_TEAR_DOWN_NETWORK);
                    removeDeferredMessages(EVENT_TEAR_DOWN_NETWORK);
                    transitionTo(mDisconnectingState);
                    onTearDown(msg.arg1);
                    onTearDown(tearDownReason);
                    break;
                case EVENT_BANDWIDTH_ESTIMATE_FROM_MODEM_CHANGED:
                    AsyncResult ar = (AsyncResult) msg.obj;
@@ -2255,10 +2269,6 @@ public class DataNetwork extends StateMachine {

    private void onTearDown(@TearDownReason int reason) {
        logl("onTearDown: reason=" + tearDownReasonToString(reason));
        if (shouldDelayTearDown()) {
            logl("onTearDown: Delay IMS tear down until call ends.");
            return;
        }

        // track frequent networkUnwanted call of IMS and INTERNET
        if ((isConnected())
@@ -2277,7 +2287,8 @@ public class DataNetwork extends StateMachine {
    }

    /**
     * @return {@code true} if this tear down should be delayed on this data network.
     * @return {@code true} if this tear down should be delayed until call ends on this data
     * network. For now this is specific to IMS network only.
     */
    public boolean shouldDelayTearDown() {
        return mDataConfigManager.isImsDelayTearDownEnabled()
@@ -2976,8 +2987,8 @@ public class DataNetwork extends StateMachine {
                return "TEAR_DOWN_REASON_NOT_ALLOWED_BY_POLICY";
            case TEAR_DOWN_REASON_ILLEGAL_STATE:
                return "TEAR_DOWN_REASON_ILLEGAL_STATE";
            case TEAR_DOWN_ONLY_ALLOWED_SINGLE_NETWORK:
                return "TEAR_DOWN_ONLY_ALLOWED_SINGLE_NETWORK";
            case TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK:
                return "TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK";
            default:
                return "UNKNOWN(" + reason + ")";
        }
+1 −1
Original line number Diff line number Diff line
@@ -1889,7 +1889,7 @@ public class DataNetworkController extends Handler {
                case VOPS_NOT_SUPPORTED:
                    return DataNetwork.TEAR_DOWN_REASON_VOPS_NOT_SUPPORTED;
                case ONLY_ALLOWED_SINGLE_NETWORK:
                    return DataNetwork.TEAR_DOWN_ONLY_ALLOWED_SINGLE_NETWORK;
                    return DataNetwork.TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK;
            }
        }
        return 0;
+31 −0
Original line number Diff line number Diff line
@@ -2111,6 +2111,37 @@ public class DataNetworkControllerTest extends TelephonyTest {
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS);
    }

    @Test
    public void testDelayImsTearDownCsRequestsToTearDown() throws Exception {
        mCarrierConfig.putBoolean(CarrierConfigManager.KEY_DELAY_IMS_TEAR_DOWN_UNTIL_CALL_END_BOOL,
                true);
        TelephonyNetworkRequest networkRequest = createNetworkRequest(
                NetworkCapabilities.NET_CAPABILITY_IMS);
        mDataNetworkControllerUT.addNetworkRequest(networkRequest);
        processAllMessages();

        // Call is ongoing
        doReturn(PhoneConstants.State.OFFHOOK).when(mCT).getState();
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS);
        verifyConnectedNetworkHasDataProfile(mImsDataProfile);
        List<DataNetwork> dataNetworks = getDataNetworks();
        assertThat(dataNetworks).hasSize(1);
        dataNetworks.get(0).tearDown(DataNetwork.TEAR_DOWN_REASON_RAT_NOT_ALLOWED);
        processAllMessages();

        // Make sure IMS network is still connected.
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS);
        verifyConnectedNetworkHasDataProfile(mImsDataProfile);

        // Now connectivity service requests to tear down the data network.
        mDataNetworkControllerUT.removeNetworkRequest(networkRequest);
        dataNetworks.get(0).tearDown(DataNetwork.TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED);
        processAllMessages();

        // All data (including IMS) should be torn down.
        verifyAllDataDisconnected();
    }

    @Test
    public void testVoPStoNonVoPSDelayImsTearDown() throws Exception {
        mCarrierConfig.putBoolean(CarrierConfigManager.KEY_DELAY_IMS_TEAR_DOWN_UNTIL_CALL_END_BOOL,