Loading src/java/com/android/internal/telephony/dataconnection/LinkBandwidthEstimator.java +3 −1 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class LinkBandwidthEstimator extends Handler { // Used to derive byte count threshold from avg BW 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 MAX_BW_TO_STATIC_BW_RATIO = 15; private static final int BYTE_DELTA_THRESHOLD_MIN_KB = 10; private static final int MAX_ERROR_PERCENT = 100 * 100; private static final String[] AVG_BW_PER_RAT = { Loading Loading @@ -606,7 +607,8 @@ public class LinkBandwidthEstimator extends Handler { return; } long linkBandwidthLongKbps = bytesDelta * 8 / timeDeltaMs * 1000 / 1024; if (linkBandwidthLongKbps > Integer.MAX_VALUE || linkBandwidthLongKbps < 0) { if (linkBandwidthLongKbps > (long) mStaticBwKbps * MAX_BW_TO_STATIC_BW_RATIO || linkBandwidthLongKbps < 0) { return; } int linkBandwidthKbps = (int) linkBandwidthLongKbps; Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/LinkBandwidthEstimatorTest.java +5 −4 Original line number Diff line number Diff line Loading @@ -634,7 +634,7 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest { @Test public void testVeryHighByteCountReturnNonNegativeValue() throws Exception { public void testVeryHighRxLinkBandwidthEstimationIgnored() throws Exception { mLBE.obtainMessage(MSG_SCREEN_STATE_CHANGED, true).sendToTarget(); processAllMessages(); mLBE.obtainMessage(MSG_SIGNAL_STRENGTH_CHANGED, mSignalStrength).sendToTarget(); Loading @@ -650,11 +650,12 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest { processAllMessages(); } // This will result in link bandwidth estimation value 128Gbps which is too high for LTE. // So it will be ignored by the estimator. LinkBandwidthEstimator.NetworkBandwidth network = mLBE.lookupNetwork("310260", 366, "LTE"); assertEquals(BW_STATS_COUNT_THRESHOLD + 4, network.getCount(LINK_RX, 1)); assertEquals(0, network.getCount(LINK_RX, 1)); assertEquals(0, network.getValue(LINK_TX, 1)); assertEquals(16_000_000_000L * 8 / 1024 * (BW_STATS_COUNT_THRESHOLD + 4), network.getValue(LINK_RX, 1)); assertEquals(0, network.getValue(LINK_RX, 1)); } } Loading
src/java/com/android/internal/telephony/dataconnection/LinkBandwidthEstimator.java +3 −1 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class LinkBandwidthEstimator extends Handler { // Used to derive byte count threshold from avg BW 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 MAX_BW_TO_STATIC_BW_RATIO = 15; private static final int BYTE_DELTA_THRESHOLD_MIN_KB = 10; private static final int MAX_ERROR_PERCENT = 100 * 100; private static final String[] AVG_BW_PER_RAT = { Loading Loading @@ -606,7 +607,8 @@ public class LinkBandwidthEstimator extends Handler { return; } long linkBandwidthLongKbps = bytesDelta * 8 / timeDeltaMs * 1000 / 1024; if (linkBandwidthLongKbps > Integer.MAX_VALUE || linkBandwidthLongKbps < 0) { if (linkBandwidthLongKbps > (long) mStaticBwKbps * MAX_BW_TO_STATIC_BW_RATIO || linkBandwidthLongKbps < 0) { return; } int linkBandwidthKbps = (int) linkBandwidthLongKbps; Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/LinkBandwidthEstimatorTest.java +5 −4 Original line number Diff line number Diff line Loading @@ -634,7 +634,7 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest { @Test public void testVeryHighByteCountReturnNonNegativeValue() throws Exception { public void testVeryHighRxLinkBandwidthEstimationIgnored() throws Exception { mLBE.obtainMessage(MSG_SCREEN_STATE_CHANGED, true).sendToTarget(); processAllMessages(); mLBE.obtainMessage(MSG_SIGNAL_STRENGTH_CHANGED, mSignalStrength).sendToTarget(); Loading @@ -650,11 +650,12 @@ public class LinkBandwidthEstimatorTest extends TelephonyTest { processAllMessages(); } // This will result in link bandwidth estimation value 128Gbps which is too high for LTE. // So it will be ignored by the estimator. LinkBandwidthEstimator.NetworkBandwidth network = mLBE.lookupNetwork("310260", 366, "LTE"); assertEquals(BW_STATS_COUNT_THRESHOLD + 4, network.getCount(LINK_RX, 1)); assertEquals(0, network.getCount(LINK_RX, 1)); assertEquals(0, network.getValue(LINK_TX, 1)); assertEquals(16_000_000_000L * 8 / 1024 * (BW_STATS_COUNT_THRESHOLD + 4), network.getValue(LINK_RX, 1)); assertEquals(0, network.getValue(LINK_RX, 1)); } }