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

Commit ec9ee1cc authored by Kai Shi's avatar Kai Shi Committed by Automerger Merge Worker
Browse files

Merge "Bug fix of bandwidth estimator overflow" into tm-qpr-dev am: 138bc9a6 am: 3b59bf6d

parents 132e186f 3b59bf6d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -715,7 +715,7 @@ public class LinkBandwidthEstimator extends Handler {
            int filterInKbps = mBwSampleValid ? mBwSampleKbps : avgKbps;

            long currTimeMs = mTelephonyFacade.getElapsedSinceBootMillis();
            int timeDeltaSec = (int) (currTimeMs - mBwSampleValidTimeMs) / 1000;
            int timeDeltaSec = (int) ((currTimeMs - mBwSampleValidTimeMs) / 1000);

            // If the operation condition changes significantly since the last update
            // or the sample has higher BW, use a faster filter. Otherwise, use a slow filter
+26 −0
Original line number Diff line number Diff line
@@ -467,6 +467,32 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest {
        verifyUpdateBandwidth(-1, 19_597);
    }

    @Test
    public void testNoOverflowAfterLargeTimeGap() throws Exception {
        mLBE.obtainMessage(MSG_SCREEN_STATE_CHANGED, true).sendToTarget();
        processAllMessages();

        for (int i = 0; i < BW_STATS_COUNT_THRESHOLD + 2; i++) {
            addTxBytes(10_000L);
            addRxBytes(500_000L);
            if (i == BW_STATS_COUNT_THRESHOLD) {
                addElapsedTime(26 * 24 * 3_600_000L);
                moveTimeForward(26 * 24 * 3_600_000L);
            } else {
                addElapsedTime(5_100);
                moveTimeForward(5_100);
            }
            processAllMessages();
            mLBE.obtainMessage(MSG_MODEM_ACTIVITY_RETURNED, new ModemActivityInfo(
                    i * 5_100L, 0, 0, TX_TIME_2_MS, i * RX_TIME_2_MS)).sendToTarget();
            processAllMessages();
        }

        verify(mTelephonyManager, times(BW_STATS_COUNT_THRESHOLD + 2))
                .requestModemActivityInfo(any(), any());
        verifyUpdateBandwidth(-1, 19_531);
    }

    @Test
    public void testAbnormalTrafficCountTriggerLessBwUpdate() throws Exception {
        mLBE.obtainMessage(MSG_SCREEN_STATE_CHANGED, true).sendToTarget();