Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5f3d465 authored by tomhsu's avatar tomhsu
Browse files

Fix Crash due to runtime exception from CarrierManager

Fix: 329754400
Test: atest passed
Change-Id: I6065160dcd15d547241dd8bc0f9f99c336c59625
parent a54a9756
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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()
}
+23 −0
Original line number Diff line number Diff line
@@ -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 {