Loading OWNERS +1 −2 Original line number Diff line number Diff line Loading @@ -6,11 +6,10 @@ rgreenwalt@google.com tgunn@google.com jminjie@google.com shuoq@google.com nazaninb@google.com sarahchin@google.com xiaotonj@google.com huiwang@google.com jayachandranc@google.com chinmayd@google.com amruthr@google.com sasindran@google.com 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/TelephonyRegistryTest.java +82 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; Loading Loading @@ -273,7 +274,6 @@ public class TelephonyRegistryTest extends TelephonyTest { assertEquals(phoneCapability, mPhoneCapability); } @Test @SmallTest public void testActiveDataSubChanged() { // mTelephonyRegistry.listen with notifyNow = true should trigger callback immediately. Loading Loading @@ -616,9 +616,13 @@ public class TelephonyRegistryTest extends TelephonyTest { int[] events = {TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED}; mTelephonyRegistry.listenWithEventList(2, mContext.getOpPackageName(), mContext.getAttributionTag(), mTelephonyCallback.callback, events, false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( anyString(), any())).thenReturn(true); TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED); // Notify with invalid subId on default phone. Should NOT trigger callback. TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo(0, 0); mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); processAllMessages(); assertEquals(null, mTelephonyDisplayInfo); Loading @@ -629,6 +633,82 @@ public class TelephonyRegistryTest extends TelephonyTest { assertEquals(displayInfo, mTelephonyDisplayInfo); } @Test public void testDisplayInfoCompatibility() { mContext.sendBroadcast(new Intent(ACTION_DEFAULT_SUBSCRIPTION_CHANGED) .putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 12) .putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0)); processAllMessages(); int[] events = {TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED}; mTelephonyRegistry.listenWithEventList(2, mContext.getOpPackageName(), mContext.getAttributionTag(), mTelephonyCallback.callback, events, false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( anyString(), any())).thenReturn(false); TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); processAllMessages(); assertEquals(null, mTelephonyDisplayInfo); // Notify with the matching subId on default phone. Should trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, 2, displayInfo); processAllMessages(); assertEquals(expectDisplayInfo, mTelephonyDisplayInfo); } @Test public void testDisplayInfoCompatibility_moreCallingPackages() { mContext.sendBroadcast(new Intent(ACTION_DEFAULT_SUBSCRIPTION_CHANGED) .putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 12) .putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0)); processAllMessages(); int[] events = {TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED}; TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE); TelephonyCallback telephonyCallback2 = new TelephonyCallbackWrapper() { @Override public void onDisplayInfoChanged(TelephonyDisplayInfo displayInfoNotify) { assertEquals(displayInfo, displayInfoNotify); } }; Executor mSimpleExecutor2 = new Executor() { @Override public void execute(Runnable r) { r.run(); } }; telephonyCallback2.init(mSimpleExecutor2); mTelephonyRegistry.listenWithEventList(2, "pkg1", mContext.getAttributionTag(), mTelephonyCallback.callback, events, false); mTelephonyRegistry.listenWithEventList(2, "pkg2", mContext.getAttributionTag(), telephonyCallback2.callback, events, false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( eq("pkg1"), any())).thenReturn(false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( eq("pkg2"), any())).thenReturn(true); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); processAllMessages(); assertEquals(null, mTelephonyDisplayInfo); // Notify with the matching subId on default phone. Should trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, 2, displayInfo); processAllMessages(); assertEquals(expectDisplayInfo, mTelephonyDisplayInfo); } @Test public void testNotifyCellLocationForSubscriberByUserSwitched() throws RemoteException { final int phoneId = 0; 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
OWNERS +1 −2 Original line number Diff line number Diff line Loading @@ -6,11 +6,10 @@ rgreenwalt@google.com tgunn@google.com jminjie@google.com shuoq@google.com nazaninb@google.com sarahchin@google.com xiaotonj@google.com huiwang@google.com jayachandranc@google.com chinmayd@google.com amruthr@google.com sasindran@google.com
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/TelephonyRegistryTest.java +82 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; Loading Loading @@ -273,7 +274,6 @@ public class TelephonyRegistryTest extends TelephonyTest { assertEquals(phoneCapability, mPhoneCapability); } @Test @SmallTest public void testActiveDataSubChanged() { // mTelephonyRegistry.listen with notifyNow = true should trigger callback immediately. Loading Loading @@ -616,9 +616,13 @@ public class TelephonyRegistryTest extends TelephonyTest { int[] events = {TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED}; mTelephonyRegistry.listenWithEventList(2, mContext.getOpPackageName(), mContext.getAttributionTag(), mTelephonyCallback.callback, events, false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( anyString(), any())).thenReturn(true); TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED); // Notify with invalid subId on default phone. Should NOT trigger callback. TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo(0, 0); mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); processAllMessages(); assertEquals(null, mTelephonyDisplayInfo); Loading @@ -629,6 +633,82 @@ public class TelephonyRegistryTest extends TelephonyTest { assertEquals(displayInfo, mTelephonyDisplayInfo); } @Test public void testDisplayInfoCompatibility() { mContext.sendBroadcast(new Intent(ACTION_DEFAULT_SUBSCRIPTION_CHANGED) .putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 12) .putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0)); processAllMessages(); int[] events = {TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED}; mTelephonyRegistry.listenWithEventList(2, mContext.getOpPackageName(), mContext.getAttributionTag(), mTelephonyCallback.callback, events, false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( anyString(), any())).thenReturn(false); TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); processAllMessages(); assertEquals(null, mTelephonyDisplayInfo); // Notify with the matching subId on default phone. Should trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, 2, displayInfo); processAllMessages(); assertEquals(expectDisplayInfo, mTelephonyDisplayInfo); } @Test public void testDisplayInfoCompatibility_moreCallingPackages() { mContext.sendBroadcast(new Intent(ACTION_DEFAULT_SUBSCRIPTION_CHANGED) .putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 12) .putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0)); processAllMessages(); int[] events = {TelephonyCallback.EVENT_DISPLAY_INFO_CHANGED}; TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE); TelephonyCallback telephonyCallback2 = new TelephonyCallbackWrapper() { @Override public void onDisplayInfoChanged(TelephonyDisplayInfo displayInfoNotify) { assertEquals(displayInfo, displayInfoNotify); } }; Executor mSimpleExecutor2 = new Executor() { @Override public void execute(Runnable r) { r.run(); } }; telephonyCallback2.init(mSimpleExecutor2); mTelephonyRegistry.listenWithEventList(2, "pkg1", mContext.getAttributionTag(), mTelephonyCallback.callback, events, false); mTelephonyRegistry.listenWithEventList(2, "pkg2", mContext.getAttributionTag(), telephonyCallback2.callback, events, false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( eq("pkg1"), any())).thenReturn(false); when(mMockConfigurationProvider.isDisplayInfoNrAdvancedSupported( eq("pkg2"), any())).thenReturn(true); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); processAllMessages(); assertEquals(null, mTelephonyDisplayInfo); // Notify with the matching subId on default phone. Should trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, 2, displayInfo); processAllMessages(); assertEquals(expectDisplayInfo, mTelephonyDisplayInfo); } @Test public void testNotifyCellLocationForSubscriberByUserSwitched() throws RemoteException { final int phoneId = 0; 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)); } }