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

Commit d202805b authored by Kai Shi's avatar Kai Shi Committed by Android (Google) Code Review
Browse files

Merge "Update AVG_BW_TO_LOW_BW_RATIO" into sc-dev

parents f683f877 070511b4
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -90,7 +90,7 @@ public class LinkBandwidthEstimator extends Handler {
    private static final int MODEM_POLL_MIN_INTERVAL_MS = 5_000;
    private static final int MODEM_POLL_MIN_INTERVAL_MS = 5_000;
    private static final int TRAFFIC_MODEM_POLL_BYTE_RATIO = 8;
    private static final int TRAFFIC_MODEM_POLL_BYTE_RATIO = 8;
    private static final int TRAFFIC_POLL_BYTE_THRESHOLD_MAX = 20_000;
    private static final int TRAFFIC_POLL_BYTE_THRESHOLD_MAX = 20_000;
    private static final int BYTE_DELTA_ACC_THRESHOLD_MAX_KB = 5_000;
    private static final int BYTE_DELTA_ACC_THRESHOLD_MAX_KB = 4_000;
    private static final int MODEM_POLL_TIME_DELTA_MAX_MS = 15_000;
    private static final int MODEM_POLL_TIME_DELTA_MAX_MS = 15_000;
    private static final int FILTER_UPDATE_MAX_INTERVAL_MS = 5_100;
    private static final int FILTER_UPDATE_MAX_INTERVAL_MS = 5_100;
    // BW samples with Tx or Rx time below the following value is ignored.
    // BW samples with Tx or Rx time below the following value is ignored.
@@ -124,7 +124,8 @@ public class LinkBandwidthEstimator extends Handler {
    private static final int[][] BYTE_DELTA_THRESHOLD_KB =
    private static final int[][] BYTE_DELTA_THRESHOLD_KB =
            {{200, 300, 400, 600, 1000}, {400, 600, 800, 1000, 1000}};
            {{200, 300, 400, 600, 1000}, {400, 600, 800, 1000, 1000}};
    // Used to derive byte count threshold from avg BW
    // Used to derive byte count threshold from avg BW
    private static final int AVG_BW_TO_LOW_BW_RATIO = 4;
    private static final int LOW_BW_TO_AVG_BW_RATIO_NUM = 3;
    private static final int LOW_BW_TO_AVG_BW_RATIO_DEN = 8;
    private static final int BYTE_DELTA_THRESHOLD_MIN_KB = 10;
    private static final int BYTE_DELTA_THRESHOLD_MIN_KB = 10;
    private static final int MAX_ERROR_PERCENT = 100 * 100;
    private static final int MAX_ERROR_PERCENT = 100 * 100;
    private static final String[] AVG_BW_PER_RAT = {
    private static final String[] AVG_BW_PER_RAT = {
@@ -570,6 +571,7 @@ public class LinkBandwidthEstimator extends Handler {
        }
        }


        private void updateBandwidthSample(long bytesDelta, long timeDeltaMs) {
        private void updateBandwidthSample(long bytesDelta, long timeDeltaMs) {
            updateByteCountThr();
            if (bytesDelta < mByteDeltaAccThr) {
            if (bytesDelta < mByteDeltaAccThr) {
                return;
                return;
            }
            }
@@ -698,7 +700,8 @@ public class LinkBandwidthEstimator extends Handler {


        // Calculate a byte count threshold for the given avg BW and observation window size
        // Calculate a byte count threshold for the given avg BW and observation window size
        private int calculateByteCountThreshold(int avgBwKbps, int durationMs) {
        private int calculateByteCountThreshold(int avgBwKbps, int durationMs) {
            return avgBwKbps / 8 * durationMs / AVG_BW_TO_LOW_BW_RATIO;
            int avgBytes = avgBwKbps / 8 * durationMs;
            return avgBytes * LOW_BW_TO_AVG_BW_RATIO_NUM / LOW_BW_TO_AVG_BW_RATIO_DEN;
        }
        }


        public boolean hasLargeBwChange() {
        public boolean hasLargeBwChange() {
+6 −7
Original line number Original line Diff line number Diff line
@@ -455,12 +455,12 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest {
        assertEquals(900_000L * 8 * 1000 / 200 / 1024 * (BW_STATS_COUNT_THRESHOLD - 1),
        assertEquals(900_000L * 8 * 1000 / 200 / 1024 * (BW_STATS_COUNT_THRESHOLD - 1),
                network.getValue(LINK_RX, 1));
                network.getValue(LINK_RX, 1));
        network = mLBE.lookupNetwork("310260", 367, "LTE");
        network = mLBE.lookupNetwork("310260", 367, "LTE");
        assertEquals(2, network.getCount(LINK_RX, 1));
        assertEquals(1, network.getCount(LINK_RX, 1));
        assertEquals(1_000_000L * 8 * 1000 / 200 / 1024 * 2,
        assertEquals(1_000_000L * 8 * 1000 / 200 / 1024,
                network.getValue(LINK_RX, 1));
                network.getValue(LINK_RX, 1));
        network = mLBE.lookupNetwork("310260", UNKNOWN_TAC, "LTE");
        network = mLBE.lookupNetwork("310260", UNKNOWN_TAC, "LTE");
        assertEquals(BW_STATS_COUNT_THRESHOLD * 3 / 2 - 1, network.getCount(LINK_RX, 1));
        assertEquals(BW_STATS_COUNT_THRESHOLD * 3 / 2 - 2, network.getCount(LINK_RX, 1));
        assertEquals(218_748, network.getValue(LINK_RX, 1));
        assertEquals(179_686, network.getValue(LINK_RX, 1));
        verify(mDataConnection, times(2)).updateLinkBandwidthEstimation(eq(-1), eq(-1));
        verify(mDataConnection, times(2)).updateLinkBandwidthEstimation(eq(-1), eq(-1));
    }
    }


@@ -527,7 +527,7 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest {
        processAllMessages();
        processAllMessages();
        for (int i = 0; i < BW_STATS_COUNT_THRESHOLD + 5; i++) {
        for (int i = 0; i < BW_STATS_COUNT_THRESHOLD + 5; i++) {
            addTxBytes(12_000L);
            addTxBytes(12_000L);
            addRxBytes(12_000L);
            addRxBytes(24_000L);
            addElapsedTime(5_100);
            addElapsedTime(5_100);
            moveTimeForward(5_100);
            moveTimeForward(5_100);
            processAllMessages();
            processAllMessages();
@@ -540,8 +540,7 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest {


        assertEquals(0, network.getCount(LINK_TX, 1));
        assertEquals(0, network.getCount(LINK_TX, 1));
        assertEquals(BW_STATS_COUNT_THRESHOLD + 4, network.getCount(LINK_RX, 1));
        assertEquals(BW_STATS_COUNT_THRESHOLD + 4, network.getCount(LINK_RX, 1));
        assertEquals(12_000L * 8 / 1024 * (BW_STATS_COUNT_THRESHOLD + 4),
        assertEquals(24_000L * 8 / 1024 * (BW_STATS_COUNT_THRESHOLD + 4),
                network.getValue(LINK_RX, 1));
                network.getValue(LINK_RX, 1));
        verify(mDataConnection, times(1)).updateLinkBandwidthEstimation(eq(-1), eq(92));
    }
    }
}
}