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

Commit c8e2916d authored by Kazuhiro Ondo's avatar Kazuhiro Ondo Committed by Wink Saville
Browse files

Bring back ERI into CDMA-LTE mode

Use ERI mechanism for roaming determination in CDMA-LTE mode.
Also display SPN name from CSIM card as "SPN" field in the status bar.
PLMN field will be derived from ERI text as done in original CDMA phone.

Bug: 4970448
Change-Id: I21382b15e148a8451f4c3fcbbb5d1ed296e41b5a
parent 97667d0c
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -1030,13 +1030,8 @@ public class CDMAPhone extends PhoneBase {
            case EVENT_NV_READY:{
                Log.d(LOG_TAG, "Event EVENT_NV_READY Received");
                //Inform the Service State Tracker
                mEriManager.loadEriFile();
                mNvLoadedRegistrants.notifyRegistrants();
                if(mEriManager.isEriFileLoaded()) {
                    // when the ERI file is loaded
                    Log.d(LOG_TAG, "ERI read, notify registrants");
                    mEriFileLoadedRegistrants.notifyRegistrants();
                }
                prepareEri();
            }
            break;

@@ -1421,6 +1416,19 @@ public class CDMAPhone extends PhoneBase {
        return false;
    }

    public void prepareEri() {
        mEriManager.loadEriFile();
        if(mEriManager.isEriFileLoaded()) {
            // when the ERI file is loaded
            log("ERI read, notify registrants");
            mEriFileLoadedRegistrants.notifyRegistrants();
        }
    }

    public boolean isEriFileLoaded() {
        return mEriManager.isEriFileLoaded();
    }

    protected void log(String s) {
        if (DBG)
            Log.d(LOG_TAG, "[CDMAPhone] " + s);
+49 −9
Original line number Diff line number Diff line
@@ -21,13 +21,15 @@ import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.RILConstants;

import android.content.Intent;
import android.telephony.SignalStrength;
import android.telephony.ServiceState;
import android.telephony.cdma.CdmaCellLocation;
import android.os.AsyncResult;
import android.os.Message;
import android.provider.Telephony.Intents;


import android.text.TextUtils;
import android.util.Log;
import android.util.EventLog;

@@ -37,6 +39,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
    CDMALTEPhone mCdmaLtePhone;

    private ServiceState  mLteSS;  // The last LTE state from Voice Registration
    private String mCurrentSpn = null;

    public CdmaLteServiceStateTracker(CDMALTEPhone phone) {
        super(phone);
@@ -73,6 +76,9 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
            pollState();
            // Signal strength polling stops when radio is off.
            queueNextSignalStrengthPoll();

            // load ERI file
            phone.prepareEri();
            break;
        case EVENT_SIM_RECORDS_LOADED:
            CdmaLteUiccRecords sim = (CdmaLteUiccRecords)phone.mIccRecords;
@@ -84,6 +90,10 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
                mIsMinInfoReady = true;
                updateOtaspState();
            }
            // SID/NID/PRL is loaded. Poll service state
            // again to update to the roaming state with
            // the latest variables.
            pollState();
            break;
        default:
            super.handleMessage(msg);
@@ -319,7 +329,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
        }

        if (hasChanged) {
            if (cm.getNvState().isNVReady()) {
            if (phone.isEriFileLoaded()) {
                String eriText;
                // Now the CDMAPhone sees the new ServiceState so it can get the
                // new ERI text
@@ -334,13 +344,6 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
                }
                ss.setOperatorAlphaLong(eriText);
            }
            if (cm.getSimState().isSIMReady()) {
                // SIM is found on the device. Read the operator name from the card.
                ss.setOperatorAlphaLong(phone.mIccRecords.getServiceProviderName());

                // If SIM card is present, Eri will not be used. Turn it off
                ss.setCdmaEriIconIndex(EriInfo.ROAMING_INDICATOR_OFF);
            }

            String operatorNumeric;

@@ -464,6 +467,43 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
        return provisioningState;
    }

    @Override
    protected void updateSpnDisplay() {
        // mOperatorAlphaLong contains the ERI text
        String plmn = ss.getOperatorAlphaLong();

        boolean showSpn = false;
        String spn = null;
        if (cm.getSimState().isSIMReady()) {
            // SIM is found on the device. Read the operator name from the card.
            showSpn = ((CdmaLteUiccRecords)phone.mIccRecords).getCsimSpnDisplayCondition();
            spn = phone.mIccRecords.getServiceProviderName();

            // double check we are not printing identicall test
            if (TextUtils.equals(plmn, spn)) showSpn = false;
        }

        if (!TextUtils.equals(plmn, mCurPlmn) ||
            !TextUtils.equals(spn, mCurrentSpn)) {
            boolean showPlmn = plmn != null;
            if (DBG) {
                log(String.format("updateSpnDisplay: changed sending intent" +
                                  " showPlmn='%b' plmn='%s' showSpn='%b' spn='%s'",
                                  showPlmn, plmn, showSpn, spn));
            }
            Intent intent = new Intent(Intents.SPN_STRINGS_UPDATED_ACTION);
            intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
            intent.putExtra(Intents.EXTRA_SHOW_SPN, showSpn);
            intent.putExtra(Intents.EXTRA_SPN, spn);
            intent.putExtra(Intents.EXTRA_SHOW_PLMN, showPlmn);
            intent.putExtra(Intents.EXTRA_PLMN, plmn);
            phone.getContext().sendStickyBroadcast(intent);
        }

        mCurPlmn = plmn;
        mCurrentSpn = spn;
    }

    @Override
    protected void log(String s) {
        Log.d(LOG_TAG, "[CdmaLteSST] " + s);
+7 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public final class CdmaLteUiccRecords extends SIMRecords {
    // From CSIM application
    private byte[] mEFpl = null;
    private byte[] mEFli = null;
    boolean csimSpnDisplayCondition = false;
    boolean mCsimSpnDisplayCondition = false;
    private String mMdn;
    private String mMin;
    private String mPrlVersion;
@@ -235,7 +235,7 @@ public final class CdmaLteUiccRecords extends SIMRecords {
                     IccUtils.bytesToHexString(data));

        // C.S0065 for EF_SPN decoding
        csimSpnDisplayCondition = ((0x02 & data[0]) > 0)?true:false;
        mCsimSpnDisplayCondition = ((0x01 & data[0]) != 0) ? true : false;

        int encoding = data[1];
        int language = data[2];
@@ -272,7 +272,7 @@ public final class CdmaLteUiccRecords extends SIMRecords {
            log("spn decode error: " + e);
        }
        if (DBG) log("spn=" + spn);
        if (DBG) log("spnCondition=" + csimSpnDisplayCondition);
        if (DBG) log("spnCondition=" + mCsimSpnDisplayCondition);
        phone.setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, spn);
    }

@@ -437,6 +437,10 @@ public final class CdmaLteUiccRecords extends SIMRecords {
        return mPrlVersion;
    }

    public boolean getCsimSpnDisplayCondition() {
        return mCsimSpnDisplayCondition;
    }

    @Override
    public boolean isProvisioned() {
        // If UICC card has CSIM app, look for MDN and MIN field
+3 −3
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
    private static final String WAKELOCK_TAG = "ServiceStateTracker";

    /** Contains the name of the registered network in CDMA (either ONS or ERI text). */
    private String curPlmn = null;
    protected String mCurPlmn = null;

    protected String mMdn;
    private int mHomeSystemId[] = null;
@@ -484,7 +484,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {

        // mOperatorAlphaLong contains the ERI text
        String plmn = ss.getOperatorAlphaLong();
        if (!TextUtils.equals(plmn, curPlmn)) {
        if (!TextUtils.equals(plmn, mCurPlmn)) {
            // Allow A blank plmn, "" to set showPlmn to true. Previously, we
            // would set showPlmn to true only if plmn was not empty, i.e. was not
            // null and not blank. But this would cause us to incorrectly display
@@ -503,7 +503,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
            phone.getContext().sendStickyBroadcast(intent);
        }

        curPlmn = plmn;
        mCurPlmn = plmn;
    }

    @Override