Fix Crash due to runtime exception from CarrierManager

Fix: 329754400
Test: atest passed
Change-Id: I6065160dcd15d547241dd8bc0f9f99c336c59625
This commit is contained in:
tomhsu
2024-05-29 05:11:59 +00:00
parent a54a9756c0
commit a5f3d46539
2 changed files with 26 additions and 0 deletions

View File

@@ -36,4 +36,7 @@ fun CarrierConfigManager.safeGetConfig(
// Settings should not assume Carrier config loader (and any other system services as well) are
// always available. If not available, use default value instead.
persistableBundleOf()
} catch (e: RuntimeException) {
// The reason is same with above.
persistableBundleOf()
}

View File

@@ -27,6 +27,7 @@ import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.doThrow
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.stub
@@ -43,6 +44,28 @@ class ClientInitiatedActionRepositoryTest {
private val repository = ClientInitiatedActionRepository(context)
@Test
fun onSystemUpdate_runtimeException_doNothing() {
mockCarrierConfigManager.stub {
on { getConfigForSubId(any(), any()) } doThrow(RuntimeException())
}
repository.onSystemUpdate()
verify(context, never()).sendBroadcast(any())
}
@Test
fun onSystemUpdate_illegalStateException_doNothing() {
mockCarrierConfigManager.stub {
on { getConfigForSubId(any(), any()) } doThrow(IllegalStateException())
}
repository.onSystemUpdate()
verify(context, never()).sendBroadcast(any())
}
@Test
fun onSystemUpdate_notEnabled() {
mockCarrierConfigManager.stub {