summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/CarrierNetworkConfig.java8
-rw-r--r--tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java23
2 files changed, 28 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/CarrierNetworkConfig.java b/service/java/com/android/server/wifi/CarrierNetworkConfig.java
index 6e754231f..20aac5bc1 100644
--- a/service/java/com/android/server/wifi/CarrierNetworkConfig.java
+++ b/service/java/com/android/server/wifi/CarrierNetworkConfig.java
@@ -249,9 +249,11 @@ public class CarrierNetworkConfig {
// Process the carrier config for each active subscription.
for (SubscriptionInfo subInfo : subInfoList) {
- processNetworkConfig(
- carrierConfigManager.getConfigForSubId(subInfo.getSubscriptionId()),
- subInfo.getDisplayName().toString());
+ CharSequence displayNameCs = subInfo.getDisplayName();
+ String displayNameStr = displayNameCs == null ? "" : displayNameCs.toString();
+ PersistableBundle bundle = carrierConfigManager.getConfigForSubId(
+ subInfo.getSubscriptionId());
+ processNetworkConfig(bundle, displayNameStr);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java
index 082944e5d..9ff5be97d 100644
--- a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkConfigTest.java
@@ -46,6 +46,7 @@ import org.mockito.MockitoAnnotations;
import java.security.PublicKey;
import java.util.Arrays;
+import java.util.Collections;
/**
* Unit tests for {@link com.android.server.wifi.CarrierNetworkConfig}.
@@ -150,6 +151,28 @@ public class CarrierNetworkConfigTest {
}
/**
+ * Tests that SubscriptionInfo.getDisplayName() returning null does not throw a
+ * NullPointerException in CarrierNetworkConfig.
+ */
+ @Test
+ public void getExistingCarrierNetworkInfo_nullDisplayName_shouldNotThrowNpe() {
+ when(mCarrierConfigManager.getConfigForSubId(TEST_SUBSCRIPTION_ID))
+ .thenReturn(generateTestConfig(TEST_SSID, TEST_STANDARD_EAP_TYPE,
+ CarrierNetworkConfig.ENCODING_METHOD_RFC_2045,
+ CarrierNetworkConfig.IDENTITY_SEQUENCE_IMSI_V1_0));
+ SubscriptionInfo testSubscriptionInfoNullDisplayName = new SubscriptionInfo(
+ TEST_SUBSCRIPTION_ID, null, 0, null, null, 0, 0,
+ null, 0, null, "0", "0", null, false, null, null);
+ when(mSubscriptionManager.getActiveSubscriptionInfoList())
+ .thenReturn(Collections.singletonList(testSubscriptionInfoNullDisplayName));
+ mCarrierNetworkConfig = new CarrierNetworkConfig(mContext, mLooper.getLooper(),
+ mFrameworkFacade);
+ reset(mCarrierConfigManager);
+
+ assertEquals("", mCarrierNetworkConfig.getCarrierName(TEST_SSID));
+ }
+
+ /**
* Verify that {@link CarrierNetworkConfig#isCarrierEncryptionInfoAvailable} will return true
* when the carrier IMSI encryption info is available.
*