aboutsummaryrefslogtreecommitdiff
path: root/tests/telephonytests
diff options
context:
space:
mode:
authorMalcolm Chen <refuhoo@google.com>2020-06-11 14:41:01 -0700
committerXiangyu/Malcolm Chen <refuhoo@google.com>2020-06-11 21:53:25 +0000
commit14113826061a50792e8bcf384b1c8c341875e90b (patch)
tree19adba100f2e513a542df3ec461319dfcf2afa3c /tests/telephonytests
parent9e974c132e3e63f4f85de5597c8f026a73d90f7f (diff)
downloadtelephony-14113826061a50792e8bcf384b1c8c341875e90b.tar.gz
Add test case for notifyDisplayInfoChanged on wrong subId.
Bug: 157039855 Test: unittest Change-Id: Ib2e16f9510ccb19cd0d42da02c70781a4255d920
Diffstat (limited to 'tests/telephonytests')
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
index d081a2446b..657eea18d6 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
@@ -19,6 +19,8 @@ import static android.telephony.PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTI
import static android.telephony.PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE;
import static android.telephony.PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED;
import static android.telephony.PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED;
+import static android.telephony.SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED;
+import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
import static android.telephony.TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED;
import static android.telephony.TelephonyManager.RADIO_POWER_OFF;
import static android.telephony.TelephonyManager.RADIO_POWER_ON;
@@ -39,6 +41,8 @@ import android.telephony.PhoneCapability;
import android.telephony.PhoneStateListener;
import android.telephony.PreciseDataConnectionState;
import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.test.suitebuilder.annotation.SmallTest;
@@ -65,6 +69,7 @@ public class TelephonyRegistryTest extends TelephonyTest {
private TelephonyRegistry mTelephonyRegistry;
private PhoneCapability mPhoneCapability;
private int mActiveSubId;
+ private TelephonyDisplayInfo mTelephonyDisplayInfo;
private int mSrvccState = -1;
private int mRadioPowerState = RADIO_POWER_UNAVAILABLE;
// All events contribute to TelephonyRegistry.ENFORCE_PHONE_STATE_PERMISSION_MASK
@@ -142,6 +147,10 @@ public class TelephonyRegistryTest extends TelephonyTest {
public void onPreciseDataConnectionStateChanged(PreciseDataConnectionState preciseState) {
invocationCount.incrementAndGet();
}
+ @Override
+ public void onDisplayInfoChanged(TelephonyDisplayInfo displayInfo) {
+ mTelephonyDisplayInfo = displayInfo;
+ }
}
private void addTelephonyRegistryService() {
@@ -418,6 +427,28 @@ public class TelephonyRegistryTest extends TelephonyTest {
}
}
+ @Test
+ public void testNotifyDisplayInfoChanged() {
+ mContext.sendBroadcast(new Intent(ACTION_DEFAULT_SUBSCRIPTION_CHANGED)
+ .putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, 12)
+ .putExtra(SubscriptionManager.EXTRA_SLOT_INDEX, 0));
+ processAllMessages();
+ mTelephonyRegistry.listenForSubscriber(2, mContext.getOpPackageName(),
+ mContext.getAttributionTag(), mPhoneStateListener.callback,
+ PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED, false);
+
+ // 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);
+
+ // Notify with the matching subId on default phone. Should trigger callback.
+ mTelephonyRegistry.notifyDisplayInfoChanged(0, 2, displayInfo);
+ processAllMessages();
+ assertEquals(displayInfo, mTelephonyDisplayInfo);
+ }
+
private void assertSecurityExceptionThrown(int event, String eventDesc) {
try {
mTelephonyRegistry.listen(mContext.getOpPackageName(),