aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-20 22:47:36 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-20 22:47:36 +0000
commita239c76e83267df83b200c02ab4b072578c5e369 (patch)
tree2d9ba34dcbbb524c509b91ae81e0d58011e6a335
parentdebd28d1da9752742968e3cd2ce9f909bebd1caa (diff)
parent3ab6ca94d4b7b2b8a42e7a07842d83ef9cb40e28 (diff)
downloadtelephony-android12-d1-s5-release.tar.gz
Merge cherrypicks of [15873636, 15873851, 15873852, 15873654, 15873655, 15873656, 15873657, 15873637, 15873638, 15873639, 15873339, 15873340, 15873341, 15873342, 15873343, 15873344, 15873345, 15873346, 15873947, 15873948, 15873949, 15873950, 15873951, 15873952, 15873953, 15873954, 15873955, 15873956, 15873957, 15873958, 15873959, 15873960, 15873961, 15873642, 15873122, 15873323, 15873123, 15873324, 15872698, 15872700, 15873987, 15873962, 15873963, 15873964, 15873965, 15873557, 15873558, 15873816, 15873643, 15873817, 15873660, 15873559, 15873988, 15873644, 15873645, 15873646, 15873325, 15873661, 15873662, 15873663, 15874027, 15874028, 15874029, 15874030, 15874031, 15874032, 15874033, 15874034, 15874035, 15874036, 15874037, 15874038, 15874039, 15874040, 15874041, 15874042, 15873560, 15873561, 15873854, 15873855, 15873562, 15873563, 15873564, 15873565, 15873566, 15874047, 15874048, 15873326, 15873124, 15874043, 15872622, 15872623, 15873857, 15872701, 15872702] into sc-d1-releaseandroid-12.0.0_r15android-12.0.0_r14android-12.0.0_r13android-12.0.0_r12android12-d1-s6-releaseandroid12-d1-s5-releaseandroid12-d1-release
Change-Id: I39c6c1c16c7c9c358fbf049879bf2e1382055d1b
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java84
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;