FileDocCategorySizeDatePackage
SpnOverride.javaAPI DocAndroid 5.1 API3768Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.uicc

SpnOverride

public class SpnOverride extends Object

Fields Summary
private HashMap
mCarrierSpnMap
static final String
LOG_TAG
static final String
PARTNER_SPN_OVERRIDE_PATH
static final String
OEM_SPN_OVERRIDE_PATH
Constructors Summary
SpnOverride()


      
        mCarrierSpnMap = new HashMap<String, String>();
        loadSpnOverrides();
    
Methods Summary
booleancontainsCarrier(java.lang.String carrier)

        return mCarrierSpnMap.containsKey(carrier);
    
java.lang.StringgetSpn(java.lang.String carrier)

        return mCarrierSpnMap.get(carrier);
    
private voidloadSpnOverrides()

        FileReader spnReader;

        File spnFile = new File(Environment.getRootDirectory(),
                PARTNER_SPN_OVERRIDE_PATH);
        File oemSpnFile = new File(Environment.getOemDirectory(),
                OEM_SPN_OVERRIDE_PATH);

        if (oemSpnFile.exists()) {
            // OEM image exist SPN xml, get the timestamp from OEM & System image for comparison.
            long oemSpnTime = oemSpnFile.lastModified();
            long sysSpnTime = spnFile.lastModified();
            Rlog.d(LOG_TAG, "SPN Timestamp: oemTime = " + oemSpnTime + " sysTime = " + sysSpnTime);

            // To get the newer version of SPN from OEM image
            if (oemSpnTime > sysSpnTime) {
                Rlog.d(LOG_TAG, "SPN in OEM image is newer than System image");
                spnFile = oemSpnFile;
            }
        } else {
            // No SPN in OEM image, so load it from system image.
            Rlog.d(LOG_TAG, "No SPN in OEM image = " + oemSpnFile.getPath() +
                " Load SPN from system image");
        }

        try {
            spnReader = new FileReader(spnFile);
        } catch (FileNotFoundException e) {
            Rlog.w(LOG_TAG, "Can not open " + spnFile.getAbsolutePath());
            return;
        }

        try {
            XmlPullParser parser = Xml.newPullParser();
            parser.setInput(spnReader);

            XmlUtils.beginDocument(parser, "spnOverrides");

            while (true) {
                XmlUtils.nextElement(parser);

                String name = parser.getName();
                if (!"spnOverride".equals(name)) {
                    break;
                }

                String numeric = parser.getAttributeValue(null, "numeric");
                String data    = parser.getAttributeValue(null, "spn");

                mCarrierSpnMap.put(numeric, data);
            }
            spnReader.close();
        } catch (XmlPullParserException e) {
            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
        } catch (IOException e) {
            Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e);
        }