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

Commit fa6ca2ee authored by Kai Shi's avatar Kai Shi
Browse files

More updates in link bandwidth estimator

1) Add per carrier, TAC, RAT and signal level grouping.
2) Add smoothing filter.
3) Pass the BW update to default data connection when there is
significant BW change while BW source is bandwidth_estimator.
4) Add threshold values for low BW 2G and 3G modes.
5) Add dump() to dump internal states and local logs.

Bug: 177942435
Bug: 176814680
Test: atest -c FrameworksTelephonyTests:com.android.internal.telephony
Test: manual test in 2G/3G/4G networks
Change-Id: Ifc346cd445f43b368e5d825c8baf0f38eb9a7f10
parent 0e148e59
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -4749,6 +4749,13 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return Collections.emptyList();
        return Collections.emptyList();
    }
    }


    /**
     * Return link bandwidth estimator
     */
    public LinkBandwidthEstimator getLinkBandwidthEstimator() {
        return mLinkBandwidthEstimator;
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("Phone: subId=" + getSubId());
        pw.println("Phone: subId=" + getSubId());
        pw.println(" mPhoneId=" + mPhoneId);
        pw.println(" mPhoneId=" + mPhoneId);
@@ -4925,6 +4932,12 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            pw.println("++++++++++++++++++++++++++++++++");
            pw.println("++++++++++++++++++++++++++++++++");
        }
        }


        if (getLinkBandwidthEstimator() != null) {
            pw.println("LinkBandwidthEstimator:");
            getLinkBandwidthEstimator().dump(fd, pw, args);
            pw.println("++++++++++++++++++++++++++++++++");
        }

        pw.println("Phone Local Log: ");
        pw.println("Phone Local Log: ");
        if (mLocalLog != null) {
        if (mLocalLog != null) {
            try {
            try {
+54 −16
Original line number Original line Diff line number Diff line
@@ -365,7 +365,8 @@ public class DataConnection extends StateMachine {
    static final int EVENT_START_HANDOVER_ON_TARGET = BASE + 36;
    static final int EVENT_START_HANDOVER_ON_TARGET = BASE + 36;
    static final int EVENT_ALLOCATE_PDU_SESSION_ID = BASE + 37;
    static final int EVENT_ALLOCATE_PDU_SESSION_ID = BASE + 37;
    static final int EVENT_RELEASE_PDU_SESSION_ID = BASE + 38;
    static final int EVENT_RELEASE_PDU_SESSION_ID = BASE + 38;
    private static final int CMD_TO_STRING_COUNT = EVENT_RELEASE_PDU_SESSION_ID - BASE + 1;
    static final int EVENT_LINK_BANDWIDTH_ESTIMATOR_UPDATE = BASE + 39;
    private static final int CMD_TO_STRING_COUNT = EVENT_LINK_BANDWIDTH_ESTIMATOR_UPDATE - BASE + 1;


    private static String[] sCmdToString = new String[CMD_TO_STRING_COUNT];
    private static String[] sCmdToString = new String[CMD_TO_STRING_COUNT];
    static {
    static {
@@ -415,6 +416,8 @@ public class DataConnection extends StateMachine {
        sCmdToString[EVENT_START_HANDOVER_ON_TARGET - BASE] = "EVENT_START_HANDOVER_ON_TARGET";
        sCmdToString[EVENT_START_HANDOVER_ON_TARGET - BASE] = "EVENT_START_HANDOVER_ON_TARGET";
        sCmdToString[EVENT_ALLOCATE_PDU_SESSION_ID - BASE] = "EVENT_ALLOCATE_PDU_SESSION_ID";
        sCmdToString[EVENT_ALLOCATE_PDU_SESSION_ID - BASE] = "EVENT_ALLOCATE_PDU_SESSION_ID";
        sCmdToString[EVENT_RELEASE_PDU_SESSION_ID - BASE] = "EVENT_RELEASE_PDU_SESSION_ID";
        sCmdToString[EVENT_RELEASE_PDU_SESSION_ID - BASE] = "EVENT_RELEASE_PDU_SESSION_ID";
        sCmdToString[EVENT_LINK_BANDWIDTH_ESTIMATOR_UPDATE - BASE] =
                "EVENT_LINK_BANDWIDTH_ESTIMATOR_UPDATE";
    }
    }
    // Convert cmd to string or null if unknown
    // Convert cmd to string or null if unknown
    static String cmdToString(int cmd) {
    static String cmdToString(int cmd) {
@@ -1506,7 +1509,31 @@ public class DataConnection extends StateMachine {
                uplinkUpdated = true;
                uplinkUpdated = true;
            }
            }
        }
        }

        if (!downlinkUpdated || !uplinkUpdated) {
        if (!downlinkUpdated || !uplinkUpdated) {
            fallBackToCarrierConfigValues(downlinkUpdated, uplinkUpdated);
        }

        if (mNetworkAgent != null) {
            mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(), DataConnection.this);
        }
    }

    private void updateLinkBandwidthsFromBandwidthEstimator(int uplinkBandwidthKbps,
            int downlinkBandwidthKbps) {
        if (DBG) {
            log("updateLinkBandwidthsFromBandwidthEstimator, UL= "
                    + uplinkBandwidthKbps + " DL= " + downlinkBandwidthKbps);
        }
        mDownlinkBandwidth = downlinkBandwidthKbps;
        mUplinkBandwidth = uplinkBandwidthKbps;

        if (mNetworkAgent != null) {
            mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(), DataConnection.this);
        }
    }

    private void fallBackToCarrierConfigValues(boolean downlinkUpdated, boolean uplinkUpdated) {
        String ratName = ServiceState.rilRadioTechnologyToString(mRilRat);
        String ratName = ServiceState.rilRadioTechnologyToString(mRilRat);
        if (mRilRat == ServiceState.RIL_RADIO_TECHNOLOGY_LTE && isNRConnected()) {
        if (mRilRat == ServiceState.RIL_RADIO_TECHNOLOGY_LTE && isNRConnected()) {
            ratName = mPhone.getServiceState().getNrFrequencyRange()
            ratName = mPhone.getServiceState().getNrFrequencyRange()
@@ -1523,9 +1550,11 @@ public class DataConnection extends StateMachine {
            }
            }
        }
        }
    }
    }
        if (mNetworkAgent != null) {

            mNetworkAgent.sendNetworkCapabilities(getNetworkCapabilities(), DataConnection.this);
    /** Update Tx and Rx link bandwidth estimation values */
        }
    public void updateLinkBandwidthEstimation(int uplinkBandwidthKbps, int downlinkBandwidthKbps) {
        sendMessage(DataConnection.EVENT_LINK_BANDWIDTH_ESTIMATOR_UPDATE,
                new Pair<Integer, Integer>(uplinkBandwidthKbps, downlinkBandwidthKbps));
    }
    }


    private boolean isBandwidthSourceKey(String source) {
    private boolean isBandwidthSourceKey(String source) {
@@ -2970,6 +2999,15 @@ public class DataConnection extends StateMachine {
                    retVal = HANDLED;
                    retVal = HANDLED;
                    break;
                    break;
                }
                }
                case EVENT_LINK_BANDWIDTH_ESTIMATOR_UPDATE: {
                    Pair<Integer, Integer> pair = (Pair<Integer, Integer>) msg.obj;
                    if (isBandwidthSourceKey(
                            DctConstants.BANDWIDTH_SOURCE_BANDWIDTH_ESTIMATOR_KEY)) {
                        updateLinkBandwidthsFromBandwidthEstimator(pair.first, pair.second);
                    }
                    retVal = HANDLED;
                    break;
                }
                case EVENT_REEVALUATE_RESTRICTED_STATE: {
                case EVENT_REEVALUATE_RESTRICTED_STATE: {
                    // If the network was restricted, and now it does not need to be restricted
                    // If the network was restricted, and now it does not need to be restricted
                    // anymore, we should add the NET_CAPABILITY_NOT_RESTRICTED capability.
                    // anymore, we should add the NET_CAPABILITY_NOT_RESTRICTED capability.
+4 −0
Original line number Original line Diff line number Diff line
@@ -4099,6 +4099,10 @@ public class DcTracker extends Handler {
        for (DataConnection dc : mDataConnections.values()) {
        for (DataConnection dc : mDataConnections.values()) {
            dc.sendMessage(DataConnection.EVENT_CARRIER_CONFIG_LINK_BANDWIDTHS_CHANGED);
            dc.sendMessage(DataConnection.EVENT_CARRIER_CONFIG_LINK_BANDWIDTHS_CHANGED);
        }
        }
        if (mPhone.getLinkBandwidthEstimator() != null) {
            mPhone.getLinkBandwidthEstimator().sendMessage(obtainMessage(
                    LinkBandwidthEstimator.MSG_CARRIER_CONFIG_LINK_BANDWIDTHS_CHANGED));
        }
    }
    }


    /**
    /**
+642 −73

File changed.

Preview size limit exceeded, changes collapsed.

+1 −0
Original line number Original line Diff line number Diff line
@@ -561,6 +561,7 @@ public abstract class TelephonyTest {
        doReturn(mSmsStats).when(mPhone).getSmsStats();
        doReturn(mSmsStats).when(mPhone).getSmsStats();
        doReturn(mImsStats).when(mImsPhone).getImsStats();
        doReturn(mImsStats).when(mImsPhone).getImsStats();
        mIccSmsInterfaceManager.mDispatchersController = mSmsDispatchersController;
        mIccSmsInterfaceManager.mDispatchersController = mSmsDispatchersController;
        doReturn(mLinkBandwidthEstimator).when(mPhone).getLinkBandwidthEstimator();


        //mUiccController
        //mUiccController
        doReturn(mUiccCardApplication3gpp).when(mUiccController).getUiccCardApplication(anyInt(),
        doReturn(mUiccCardApplication3gpp).when(mUiccController).getUiccCardApplication(anyInt(),
Loading