diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-09-15 08:01:19 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-09-15 08:01:19 +0000 |
commit | 1c0937f8b6dfaf53e320287e9c7dceeeea2b405d (patch) | |
tree | 5cb8b3c3ff020911e605ce98546aeef87a331e5e | |
parent | a91f3922e7cc6b0c7eaf371ef191481209fe3c9d (diff) | |
parent | e9bf1b3372a95bc67327fd29bd91b74bc5c080b0 (diff) | |
download | telephony-1c0937f8b6dfaf53e320287e9c7dceeeea2b405d.tar.gz |
Snap for 7734064 from e9bf1b3372a95bc67327fd29bd91b74bc5c080b0 to mainline-resolv-releaseandroid-mainline-12.0.0_r35android-mainline-12.0.0_r16
Change-Id: Idbbe72dbb5506412b5017d31bb75408bb229d0a7
-rw-r--r-- | tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java | 84 |
1 files changed, 82 insertions, 2 deletions
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java index 1d5bce64db..d14bbd0801 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java @@ -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; @@ -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. @@ -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); @@ -630,6 +634,82 @@ public class TelephonyRegistryTest extends TelephonyTest { } @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; final int subId = 1; |