Merge "Fix Crash due to runtime exception from CarrierManager" into main
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user