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

Commit 695a7609 authored by andychou's avatar andychou
Browse files

Fix Invalid SIM is not displayed for card error condition and add test

case testTelephonyCapable_SimState_CardIOError()

There is existing bug that KeyguardUpdateMonitor doesn't notify
CarrierTextController in State.CARD_IO_ERROR condition, so invalid text
doesn't display.
Notify CarrierTextController in State.CARD_IO_ERROR condition to allow
correct text to display

Bug: 132376981
Test: fake SIM state with State.CARD_IO_ERROR and make sure invalid text
is displayed. Also atest testTelephonyCapable_SimState_CardIOError pass

Change-Id: Iecb404689f57776c21591a049bc660fec17127d4
parent 7e460b6e
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1994,7 +1994,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        boolean becameAbsent = false;
        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
            Log.w(TAG, "invalid subId in handleSimStateChange()");
            /* Only handle No SIM(ABSENT) due to handleServiceStateChange() handle other case */
            /* Only handle No SIM(ABSENT) and Card Error(CARD_IO_ERROR) due to
             * handleServiceStateChange() handle other case */
            if (state == State.ABSENT) {
                updateTelephonyCapable(true);
                // Even though the subscription is not valid anymore, we need to notify that the
@@ -2007,6 +2008,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                        data.simState = State.ABSENT;
                    }
                }
            } else if (state == State.CARD_IO_ERROR) {
                updateTelephonyCapable(true);
            } else {
                return;
            }
+15 −4
Original line number Diff line number Diff line
@@ -143,10 +143,21 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    @Test
    public void testTelephonyCapable_SimState_Absent() {
        Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE
                , IccCardConstants.INTENT_VALUE_ICC_ABSENT);
        mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext()
                , putPhoneInfo(intent,null, false));
        intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE,
                IccCardConstants.INTENT_VALUE_ICC_ABSENT);
        mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext(),
                putPhoneInfo(intent, null, false));
        mTestableLooper.processAllMessages();
        assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue();
    }

    @Test
    public void testTelephonyCapable_SimState_CardIOError() {
        Intent intent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        intent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE,
                IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR);
        mKeyguardUpdateMonitor.mBroadcastReceiver.onReceive(getContext(),
                putPhoneInfo(intent, null, false));
        mTestableLooper.processAllMessages();
        assertThat(mKeyguardUpdateMonitor.mTelephonyCapable).isTrue();
    }