aboutsummaryrefslogtreecommitdiff
path: root/tests/telephonytests
diff options
context:
space:
mode:
authorXiangyu/Malcolm Chen <refuhoo@google.com>2020-06-12 00:10:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-12 00:10:19 +0000
commit4f4d7c5ca8b969ff259aa43a28f969ee87dd9f7c (patch)
tree40df48e493fe5b6399cf064efe4aa73980ec8b13 /tests/telephonytests
parent03d293cf82582e79cc3f2c6eef4f1ffc126026e8 (diff)
parent14113826061a50792e8bcf384b1c8c341875e90b (diff)
downloadtelephony-4f4d7c5ca8b969ff259aa43a28f969ee87dd9f7c.tar.gz
Merge "Add test case for notifyDisplayInfoChanged on wrong subId." into rvc-dev
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(),