Fix Kotlin safety build error
Handle nullable in kotlin to avoid build error.
Bug: 314709820
Change-Id: I05b2824e3a5e4ec0dfe79d7c91fdfe8700ec1516
diff --git a/src/com/android/contacts/sdn/SdnRepository.kt b/src/com/android/contacts/sdn/SdnRepository.kt
index 082adeb..0759127 100644
--- a/src/com/android/contacts/sdn/SdnRepository.kt
+++ b/src/com/android/contacts/sdn/SdnRepository.kt
@@ -63,7 +63,7 @@
@SuppressLint("MissingPermission")
fun getSimCardInformation(): List<SimCard> {
val subscriptionManager = context.getSystemService(SubscriptionManager::class.java)
- return subscriptionManager.activeSubscriptionInfoList?.filterNotNull()?.mapNotNull {
+ return subscriptionManager?.activeSubscriptionInfoList?.filterNotNull()?.mapNotNull {
if (it.subscriptionId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
null
} else {
@@ -77,7 +77,7 @@
private fun fetchSdnFromCarrierConfig(simCard: SimCard): List<Sdn> {
val carrierConfigManager = context.getSystemService(CarrierConfigManager::class.java)
val carrierConfig =
- carrierConfigManager.getConfigForSubId(simCard.subscriptionId) ?: return emptyList()
+ carrierConfigManager?.getConfigForSubId(simCard.subscriptionId) ?: return emptyList()
val nameList: List<String> =
carrierConfig
.getStringArray(CarrierConfigManager.KEY_CARRIER_SERVICE_NAME_STRING_ARRAY)