CTS Test for TelephonyManager.getForbiddenPlmns()
-Validate that the API returns a non-null value for UMTS devices
-If the return is non-null, validate that the records are correct:
-5-6 characters that are 0-9,F
Bug: 35261110
Test: Verified on Bullhead with a TMO SIM
Merged-In: Ia15cd2b6fdeb53bf5654424385c456b53187dd55
Change-Id: Ia15cd2b6fdeb53bf5654424385c456b53187dd55
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
index 3615cb2..ae42574 100644
--- a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
@@ -550,6 +550,47 @@
mTelephonyManager.getMeid(mTelephonyManager.getPhoneCount());
}
+ /**
+ * Tests that the device properly reports the contents of EF_FPLMN or null
+ */
+ @Test
+ public void testGetForbiddenPlmns() {
+ if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+ return;
+ }
+ String[] plmns = mTelephonyManager.getForbiddenPlmns();
+
+ int phoneType = mTelephonyManager.getPhoneType();
+ switch (phoneType) {
+ case TelephonyManager.PHONE_TYPE_GSM:
+ assertNotNull("Forbidden PLMNs must be valid or an empty list!", plmns);
+ case TelephonyManager.PHONE_TYPE_CDMA:
+ case TelephonyManager.PHONE_TYPE_NONE:
+ if (plmns == null) {
+ return;
+ }
+ }
+
+ for(String plmn : plmns) {
+ if (plmn.length() > 6 || plmn.length() < 5) {
+ fail("Invalid Length for PLMN-ID, must be 5 or 6: " + plmn);
+ }
+
+ // A record which is written in the SIM but empty will
+ // be all f's
+ if(android.text.TextUtils.isDigitsOnly(plmn)) {
+ assertTrue(
+ "PLMNs must be strings of digits 0-9,F! " + plmn,
+ android.text.TextUtils.isDigitsOnly(plmn));
+ } else {
+ for (char c : plmn.toUpperCase().toCharArray()) {
+ assertTrue("PLMNs must be strings of digits 0-9,F! " + plmn,
+ Character.toUpperCase(c) == 'F');
+ }
+ }
+ }
+ }
+
private static Context getContext() {
return InstrumentationRegistry.getContext();
}