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

Commit 0a4417e9 authored by Pengquan Meng's avatar Pengquan Meng
Browse files

Add 5G TCP buffer size

This add a default 5G TCP buffer size for 5G Non-Standalone.

Bug: 116171636
Test: Build
Merged-In: Ie98fc6cd0f51710820ff8a25ad74faf5d80c7f2d
Change-Id: Ie98fc6cd0f51710820ff8a25ad74faf5d80c7f2d
(cherry picked from commit b88fefd0)
parent 27b093b7
Loading
Loading
Loading
Loading
+36 −7
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ import android.os.SystemProperties;
import android.provider.Telephony;
import android.provider.Telephony;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.AccessNetworkConstants.TransportType;
import android.telephony.DataFailCause;
import android.telephony.DataFailCause;
import android.telephony.NetworkRegistrationState;
import android.telephony.Rlog;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
@@ -110,6 +111,9 @@ public class DataConnection extends StateMachine {


    private static final String NETWORK_TYPE = "MOBILE";
    private static final String NETWORK_TYPE = "MOBILE";


    private static final String RAT_NAME_5G = "nr";
    private static final String RAT_NAME_EVDO = "evdo";

    // The data connection providing default Internet connection will have a higher score of 50.
    // The data connection providing default Internet connection will have a higher score of 50.
    // Other connections will have a slightly lower score of 45. The intention is other connections
    // Other connections will have a slightly lower score of 45. The intention is other connections
    // will not cause ConnectivityService to tear down default internet connection. For example,
    // will not cause ConnectivityService to tear down default internet connection. For example,
@@ -882,6 +886,11 @@ public class DataConnection extends StateMachine {
        return true;
        return true;
    }
    }


    /**
     * TCP buffer size config based on the ril technology. There are 6 parameters
     * read_min, read_default, read_max, write_min, write_default, write_max in the TCP buffer
     * config string and they are separated by a comma. The unit of these parameters is byte.
     */
    private static final String TCP_BUFFER_SIZES_GPRS = "4092,8760,48000,4096,8760,48000";
    private static final String TCP_BUFFER_SIZES_GPRS = "4092,8760,48000,4096,8760,48000";
    private static final String TCP_BUFFER_SIZES_EDGE = "4093,26280,70800,4096,16384,70800";
    private static final String TCP_BUFFER_SIZES_EDGE = "4093,26280,70800,4096,16384,70800";
    private static final String TCP_BUFFER_SIZES_UMTS = "58254,349525,1048576,58254,349525,1048576";
    private static final String TCP_BUFFER_SIZES_UMTS = "58254,349525,1048576,58254,349525,1048576";
@@ -892,7 +901,10 @@ public class DataConnection extends StateMachine {
    private static final String TCP_BUFFER_SIZES_HSPA = "40778,244668,734003,16777,100663,301990";
    private static final String TCP_BUFFER_SIZES_HSPA = "40778,244668,734003,16777,100663,301990";
    private static final String TCP_BUFFER_SIZES_LTE =
    private static final String TCP_BUFFER_SIZES_LTE =
            "524288,1048576,2097152,262144,524288,1048576";
            "524288,1048576,2097152,262144,524288,1048576";
    private static final String TCP_BUFFER_SIZES_HSPAP= "122334,734003,2202010,32040,192239,576717";
    private static final String TCP_BUFFER_SIZES_HSPAP =
            "122334,734003,2202010,32040,192239,576717";
    private static final String TCP_BUFFER_SIZES_NR =
            "2097152,6291456,16777216,512000,2097152,8388608";


    private void updateTcpBufferSizes(int rilRat) {
    private void updateTcpBufferSizes(int rilRat) {
        String sizes = null;
        String sizes = null;
@@ -907,7 +919,13 @@ public class DataConnection extends StateMachine {
        if (rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0 ||
        if (rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0 ||
                rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A ||
                rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A ||
                rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B) {
                rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B) {
            ratName = "evdo";
            ratName = RAT_NAME_EVDO;
        }

        // NR 5G Non-Standalone use LTE cell as the primary cell, the ril technology is LTE in this
        // case. We use NR 5G TCP buffer size when connected to NR 5G Non-Standalone network.
        if (rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_LTE && isNRConnected()) {
            ratName = RAT_NAME_5G;
        }
        }


        // in the form: "ratname:rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max"
        // in the form: "ratname:rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max"
@@ -955,7 +973,12 @@ public class DataConnection extends StateMachine {
                    break;
                    break;
                case ServiceState.RIL_RADIO_TECHNOLOGY_LTE:
                case ServiceState.RIL_RADIO_TECHNOLOGY_LTE:
                case ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA:
                case ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA:
                    // Use NR 5G TCP buffer size when connected to NR 5G Non-Standalone network.
                    if (isNRConnected()) {
                        sizes = TCP_BUFFER_SIZES_NR;
                    } else {
                        sizes = TCP_BUFFER_SIZES_LTE;
                        sizes = TCP_BUFFER_SIZES_LTE;
                    }
                    break;
                    break;
                case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP:
                case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP:
                    sizes = TCP_BUFFER_SIZES_HSPAP;
                    sizes = TCP_BUFFER_SIZES_HSPAP;
@@ -2794,6 +2817,12 @@ public class DataConnection extends StateMachine {
        return "{" + toStringSimple() + " mApnContexts=" + mApnContexts + "}";
        return "{" + toStringSimple() + " mApnContexts=" + mApnContexts + "}";
    }
    }


    /** Check if the device is connected to NR 5G Non-Standalone network. */
    private boolean isNRConnected() {
        return mPhone.getServiceState().getNrStatus()
                == NetworkRegistrationState.NR_STATUS_CONNECTED;
    }

    private void dumpToLog() {
    private void dumpToLog() {
        dump(null, new PrintWriter(new StringWriter(0)) {
        dump(null, new PrintWriter(new StringWriter(0)) {
            @Override
            @Override