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

Commit ab4f64ec authored by Deepak Kundra's avatar Deepak Kundra Committed by Gerrit Code Review
Browse files

Telephony: Apply SPN override for cdma SIM (RUIM)

* Move spn override function to common IccRecords class to share between
  SIMRecords and RUIMRecords
* Add spn override to onAllRecordsLoaded() in RUIMRecords since IMSI record
  is loaded after SPN record

Change-Id: I76731ec8355a02cd94f9b218fecb16dfa181063a
parent a8f75011
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicBoolean;

import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA;

/**
 * {@hide}
 */
@@ -61,6 +63,8 @@ public abstract class IccRecords extends Handler implements IccConstants {

    protected AdnRecordCache mAdnCache;

    private SpnOverride mSpnOverride;

    // ***** Cached SIM State; cleared on channel close

    protected boolean mRecordsRequested = false; // true if we've made requests for the sim records
@@ -124,6 +128,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
                + " mCi=" + mCi
                + " mFh=" + mFh
                + " mParentApp=" + mParentApp
                + " mSpnOverride=" + "mSpnOverride"
                + " recordsLoadedRegistrants=" + mRecordsLoadedRegistrants
                + " mImsiReadyRegistrants=" + mImsiReadyRegistrants
                + " mRecordsEventsRegistrants=" + mRecordsEventsRegistrants
@@ -172,6 +177,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
        mTelephonyManager = (TelephonyManager) mContext.getSystemService(
                Context.TELEPHONY_SERVICE);
        mCi.registerForIccRefresh(this, EVENT_REFRESH, null);
        mSpnOverride = new SpnOverride();
    }

    /**
@@ -390,6 +396,16 @@ public abstract class IccRecords extends Handler implements IccConstants {
        mSpn = spn;
    }

    protected void setSpnFromConfig(String carrier) {
        if (mSpnOverride.containsCarrier(carrier)) {
            String overrideSpn = mSpnOverride.getSpn(carrier);
            log("set override spn carrier: " + carrier + ", spn: " + overrideSpn);
            setServiceProviderName(overrideSpn);
            mTelephonyManager.setSimOperatorNameForPhone(
                    mParentApp.getPhoneId(), getServiceProviderName());
        }
    }

    /**
     * Set voice mail number to SIM record
     *
@@ -780,6 +796,7 @@ public abstract class IccRecords extends Handler implements IccConstants {
        pw.println(" mCi=" + mCi);
        pw.println(" mFh=" + mFh);
        pw.println(" mParentApp=" + mParentApp);
        pw.println(" mSpnOverride=" + mSpnOverride);
        pw.println(" recordsLoadedRegistrants: size=" + mRecordsLoadedRegistrants.size());
        for (int i = 0; i < mRecordsLoadedRegistrants.size(); i++) {
            pw.println("  recordsLoadedRegistrants[" + i + "]="
+1 −0
Original line number Diff line number Diff line
@@ -772,6 +772,7 @@ public final class RuimRecords extends IccRecords {
                log("update icc_operator_numeric=" + operator);
                mTelephonyManager.setSimOperatorNumericForPhone(
                        mParentApp.getPhoneId(), operator);
                setSpnFromConfig(operator);
            } else {
                log("onAllRecordsLoaded empty 'gsm.sim.operator.numeric' skipping");
            }
+0 −14
Original line number Diff line number Diff line
@@ -53,8 +53,6 @@ public class SIMRecords extends IccRecords {
    VoiceMailConstants mVmConfig;


    SpnOverride mSpnOverride;

    // ***** Cached SIM State; cleared on channel close

    private boolean mCallForwardingEnabled;
@@ -93,7 +91,6 @@ public class SIMRecords extends IccRecords {
    public String toString() {
        return "SimRecords: " + super.toString()
                + " mVmConfig" + mVmConfig
                + " mSpnOverride=" + "mSpnOverride"
                + " callForwardingEnabled=" + mCallForwardingEnabled
                + " spnState=" + mSpnState
                + " mCphsInfo=" + mCphsInfo
@@ -194,7 +191,6 @@ public class SIMRecords extends IccRecords {
        mAdnCache = new AdnRecordCache(mFh);

        mVmConfig = new VoiceMailConstants();
        mSpnOverride = new SpnOverride();

        mRecordsRequested = false;  // No load request is made till SIM ready

@@ -1454,15 +1450,6 @@ public class SIMRecords extends IccRecords {

    //***** Private methods

    private void setSpnFromConfig(String carrier) {
        if (mSpnOverride.containsCarrier(carrier)) {
            setServiceProviderName(mSpnOverride.getSpn(carrier));
            mTelephonyManager.setSimOperatorNameForPhone(
                    mParentApp.getPhoneId(), getServiceProviderName());
        }
    }


    private void setVoiceMailByCountry (String spn) {
        if (mVmConfig.containsCarrier(spn)) {
            mIsVoiceMailFixed = true;
@@ -1884,7 +1871,6 @@ public class SIMRecords extends IccRecords {
        pw.println(" extends:");
        super.dump(fd, pw, args);
        pw.println(" mVmConfig=" + mVmConfig);
        pw.println(" mSpnOverride=" + mSpnOverride);
        pw.println(" mCallForwardingEnabled=" + mCallForwardingEnabled);
        pw.println(" mSpnState=" + mSpnState);
        pw.println(" mCphsInfo=" + mCphsInfo);