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

Commit f83b2ff8 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Moved ERI configuration files from resoures to Carrier Config." into nyc-dev

parents 0579827c 2dd87406
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -2077,6 +2077,12 @@ public class GsmCdmaPhone extends Phone {
                    loge("didn't get broadcastEmergencyCallStateChanges from carrier config");
                }

                // Load the ERI based on carrier config. Carrier might have their specific ERI.
                prepareEri();
                if (!isPhoneTypeGsm()) {
                    mSST.pollState();
                }

                break;

            case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
@@ -2091,12 +2097,6 @@ public class GsmCdmaPhone extends Phone {
                }
                break;

            //CDMA
            case EVENT_NV_READY:
                logd("Event EVENT_NV_READY Received");
                prepareEri();
                break;

            case EVENT_SIM_RECORDS_LOADED:
                if (isPhoneTypeGsm()) {
                    updateCurrentCarrierInProvider();
+0 −4
Original line number Diff line number Diff line
@@ -1205,7 +1205,6 @@ public class ServiceStateTracker extends Handler {
                // Only support automatic selection mode in CDMA.
                mCi.getNetworkSelectionMode(obtainMessage(EVENT_POLL_STATE_NETWORK_SELECTION_MODE));

                mPhone.prepareEri();
                break;

            case EVENT_NV_READY:
@@ -1276,9 +1275,6 @@ public class ServiceStateTracker extends Handler {
                            }
                            updateOtaspState();
                        }
                        // reload eri in case of IMSI changed
                        // eri.xml can be defined by mcc mnc
                        mPhone.prepareEri();
                        // SID/NID/PRL is loaded. Poll service state
                        // again to update to the roaming state with
                        // the latest variables.
+34 −5
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.internal.telephony.cdma;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.Rlog;
import android.util.Xml;

@@ -83,7 +85,7 @@ public class EriManager {
        }
    }

    private static final String LOG_TAG = "CDMA";
    private static final String LOG_TAG = "EriManager";
    private static final boolean DBG = true;
    private static final boolean VDBG = false;

@@ -95,8 +97,10 @@ public class EriManager {
    private int mEriFileSource = ERI_FROM_XML;
    private boolean mIsEriFileLoaded;
    private EriFile mEriFile;
    private final Phone mPhone;

    public EriManager(Phone phone, Context context, int eriFileSource) {
        mPhone = phone;
        mContext = context;
        mEriFileSource = eriFileSource;
        mEriFile = new EriFile();
@@ -170,8 +174,31 @@ public class EriManager {
        }

        if (parser == null) {
            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: open normal file");
            parser = r.getXml(com.android.internal.R.xml.eri);
            String eriFile = null;

            CarrierConfigManager configManager = (CarrierConfigManager)
                    mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
            if (configManager != null) {
                PersistableBundle b = configManager.getConfig(mPhone.getSubId());
                if (b != null) {
                    eriFile = b.getString(CarrierConfigManager.KEY_CARRIER_ERI_FILE_NAME_STRING);
                }
            }

            Rlog.d(LOG_TAG, "eriFile = " + eriFile);

            if (eriFile == null) {
                if (DBG) Rlog.e(LOG_TAG, "loadEriFileFromXml: Can't find ERI file to load");
                return;
            }

            try {
                parser = Xml.newPullParser();
                parser.setInput(mContext.getAssets().open(eriFile), null);
            } catch (IOException | XmlPullParserException e) {
                if (DBG) Rlog.e(LOG_TAG, "loadEriFileFromXml: no parser for " + eriFile +
                        ". Exception = " + e.toString());
            }
        }

        try {
@@ -216,7 +243,9 @@ public class EriManager {
                }
            }

            if (DBG) Rlog.d(LOG_TAG, "loadEriFileFromXml: eri parsing successful, file loaded");
            Rlog.d(LOG_TAG, "loadEriFileFromXml: eri parsing successful, file loaded. ver = " +
                    mEriFile.mVersionNumber + ", # of entries = " + mEriFile.mNumberOfEriEntries);

            mIsEriFileLoaded = true;

        } catch (Exception e) {
@@ -282,7 +311,7 @@ public class EriManager {
    private EriDisplayInformation getEriDisplayInformation(int roamInd, int defRoamInd){
        EriDisplayInformation ret;

        // Carrier can use eri.xml to customize any built-in roaming display indications
        // Carrier can use carrier config to customize any built-in roaming display indications
        if (mIsEriFileLoaded) {
            EriInfo eriInfo = getEriInfo(roamInd);
            if (eriInfo != null) {
+10 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.CellLocation;
import android.telephony.ServiceState;
@@ -693,4 +692,14 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        editor.remove(Phone.CF_STATUS + subId2);
        editor.apply();
    }

    @Test
    @SmallTest
    public void testEriLoading() {
        mPhoneUT.mEriManager = mEriManager;
        mPhoneUT.sendMessage(mPhoneUT.obtainMessage(GsmCdmaPhone.EVENT_CARRIER_CONFIG_CHANGED,
                null));
        waitForMs(100);
        verify(mEriManager, times(1)).loadEriFile();
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -356,7 +356,6 @@ public class ServiceStateTrackerTest extends TelephonyTest {

        // on RUIM_RECORDS_LOADED, sst is expected to call following apis
        verify(mRuimRecords, times(1)).isProvisioned();
        verify(mPhone, times(1)).prepareEri();

        // switch back to GSM
        doReturn(true).when(mPhone).isPhoneTypeGsm();
@@ -374,7 +373,6 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        waitForMs(200);

        verify(mRuimRecords, times(1)).isProvisioned();
        verify(mPhone, times(1)).prepareEri();
    }

    @Test
@@ -567,7 +565,7 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        mSimulatedCommands.setDataRegState(ServiceState.RIL_REG_STATE_ROAMING);
        mSimulatedCommands.notifyVoiceNetworkStateChanged();

        waitForMs(100);
        waitForMs(200);

        // verify if registered handler has message posted to it
        ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);