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

Commit 612c77f3 authored by Zoran Jovanovic's avatar Zoran Jovanovic
Browse files

Make FSM for loading SPN more robust

Let FSM for loading SPN continue if the loaded
data is null or empty.

Change-Id: Ie0a138edb62a02761108b9dbf117d9199ef8354b
parent f214d9e5
Loading
Loading
Loading
Loading
+60 −27
Original line number Original line Diff line number Diff line
@@ -1732,22 +1732,32 @@ public class SIMRecords extends IccRecords {
                if (ar != null && ar.exception == null) {
                if (ar != null && ar.exception == null) {
                    data = (byte[]) ar.result;
                    data = (byte[]) ar.result;
                    mSpnDisplayCondition = 0xff & data[0];
                    mSpnDisplayCondition = 0xff & data[0];

                    setServiceProviderName(IccUtils.adnStringFieldToString(
                    setServiceProviderName(IccUtils.adnStringFieldToString(
                            data, 1, data.length - 1));
                            data, 1, data.length - 1));
                    // for card double-check and brand override
                    // we have to do this:
                    final String spn = getServiceProviderName();


                    if (DBG) log("Load EF_SPN: " + getServiceProviderName()
                    if (spn == null || spn.length() == 0) {
                        mSpnState = GetSpnFsmState.READ_SPN_CPHS;
                    } else {
                        if (DBG) log("Load EF_SPN: " + spn
                                + " spnDisplayCondition: " + mSpnDisplayCondition);
                                + " spnDisplayCondition: " + mSpnDisplayCondition);
                        mTelephonyManager.setSimOperatorNameForPhone(
                        mTelephonyManager.setSimOperatorNameForPhone(
                            mParentApp.getPhoneId(), getServiceProviderName());
                                mParentApp.getPhoneId(), spn);


                        mSpnState = GetSpnFsmState.IDLE;
                        mSpnState = GetSpnFsmState.IDLE;
                    }
                } else {
                } else {
                    mSpnState = GetSpnFsmState.READ_SPN_CPHS;
                }

                if (mSpnState == GetSpnFsmState.READ_SPN_CPHS) {
                    mFh.loadEFTransparent( EF_SPN_CPHS,
                    mFh.loadEFTransparent( EF_SPN_CPHS,
                            obtainMessage(EVENT_GET_SPN_DONE));
                            obtainMessage(EVENT_GET_SPN_DONE));
                    mRecordsToLoad++;
                    mRecordsToLoad++;


                    mSpnState = GetSpnFsmState.READ_SPN_CPHS;

                    // See TS 51.011 10.3.11.  Basically, default to
                    // See TS 51.011 10.3.11.  Basically, default to
                    // show PLMN always, and SPN also if roaming.
                    // show PLMN always, and SPN also if roaming.
                    mSpnDisplayCondition = -1;
                    mSpnDisplayCondition = -1;
@@ -1756,34 +1766,57 @@ public class SIMRecords extends IccRecords {
            case READ_SPN_CPHS:
            case READ_SPN_CPHS:
                if (ar != null && ar.exception == null) {
                if (ar != null && ar.exception == null) {
                    data = (byte[]) ar.result;
                    data = (byte[]) ar.result;
                    setServiceProviderName(IccUtils.adnStringFieldToString(data, 0, data.length));

                    setServiceProviderName(IccUtils.adnStringFieldToString(
                            data, 0, data.length));
                    // for card double-check and brand override
                    // we have to do this:
                    final String spn = getServiceProviderName();

                    if (spn == null || spn.length() == 0) {
                        mSpnState = GetSpnFsmState.READ_SPN_SHORT_CPHS;
                    } else {
                        // Display CPHS Operator Name only when not roaming
                        // Display CPHS Operator Name only when not roaming
                        mSpnDisplayCondition = 2;
                        mSpnDisplayCondition = 2;


                    if (DBG) log("Load EF_SPN_CPHS: " + getServiceProviderName());
                        if (DBG) log("Load EF_SPN_CPHS: " + spn);
                        mTelephonyManager.setSimOperatorNameForPhone(
                        mTelephonyManager.setSimOperatorNameForPhone(
                            mParentApp.getPhoneId(), getServiceProviderName());
                                mParentApp.getPhoneId(), spn);


                        mSpnState = GetSpnFsmState.IDLE;
                        mSpnState = GetSpnFsmState.IDLE;
                    }
                } else {
                } else {
                    mSpnState = GetSpnFsmState.READ_SPN_SHORT_CPHS;
                }

                if (mSpnState == GetSpnFsmState.READ_SPN_SHORT_CPHS) {
                    mFh.loadEFTransparent(
                    mFh.loadEFTransparent(
                            EF_SPN_SHORT_CPHS, obtainMessage(EVENT_GET_SPN_DONE));
                            EF_SPN_SHORT_CPHS, obtainMessage(EVENT_GET_SPN_DONE));
                    mRecordsToLoad++;
                    mRecordsToLoad++;

                    mSpnState = GetSpnFsmState.READ_SPN_SHORT_CPHS;
                }
                }
                break;
                break;
            case READ_SPN_SHORT_CPHS:
            case READ_SPN_SHORT_CPHS:
                if (ar != null && ar.exception == null) {
                if (ar != null && ar.exception == null) {
                    data = (byte[]) ar.result;
                    data = (byte[]) ar.result;
                    setServiceProviderName(IccUtils.adnStringFieldToString(data, 0, data.length));

                    setServiceProviderName(IccUtils.adnStringFieldToString(
                            data, 0, data.length));
                    // for card double-check and brand override
                    // we have to do this:
                    final String spn = getServiceProviderName();

                    if (spn == null || spn.length() == 0) {
                        if (DBG) log("No SPN loaded in either CHPS or 3GPP");
                    } else {
                        // Display CPHS Operator Name only when not roaming
                        // Display CPHS Operator Name only when not roaming
                        mSpnDisplayCondition = 2;
                        mSpnDisplayCondition = 2;


                    if (DBG) log("Load EF_SPN_SHORT_CPHS: " + getServiceProviderName());
                        if (DBG) log("Load EF_SPN_SHORT_CPHS: " + spn);
                        mTelephonyManager.setSimOperatorNameForPhone(
                        mTelephonyManager.setSimOperatorNameForPhone(
                            mParentApp.getPhoneId(), getServiceProviderName());
                                mParentApp.getPhoneId(), spn);
                    }
                } else {
                } else {
                    setServiceProviderName(null);
                    if (DBG) log("No SPN loaded in either CHPS or 3GPP");
                    if (DBG) log("No SPN loaded in either CHPS or 3GPP");
                }
                }