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

Commit b72e820a authored by Raj Yengisetty's avatar Raj Yengisetty
Browse files

SetupWizard: protect against IllegalStateExceptions in telephony

Telephony throws this exception in some cases when retrieving SIM state

Change-Id: I87e14aaa328d46ebba4990559f6531de4e961d68
parent ffc0dbd2
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.SystemProperties;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;

import android.util.Log;
import com.android.internal.telephony.TelephonyIntents;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;

@@ -171,7 +172,13 @@ public class CMSetupWizardData extends AbstractSetupData {
        TelephonyManager tm = TelephonyManager.from(mContext);
        int simSlotCount = tm.getSimCount();
        for (int i = 0; i < simSlotCount; i++) {
            int state = tm.getSimState(i);
            int state;
            try {
                state = tm.getSimState(i);
            } catch (IllegalStateException ise) {
                Log.e(TAG, "Unable to get sim state from TelephonyManager");
                continue;
            }
            if (state != TelephonyManager.SIM_STATE_ABSENT
                    && state != TelephonyManager.SIM_STATE_UNKNOWN) {
                 return true;