Example #1
0
 /**
  * Process one apn
  *
  * @param apnValues Where we store the parsed apn
  * @throws IOException
  * @throws XmlPullParserException
  */
 private void processApn(ContentValues apnValues) throws IOException, XmlPullParserException {
   Assert.notNull(apnValues);
   apnValues.clear();
   // Collect all the attributes
   for (int i = 0; i < mInputParser.getAttributeCount(); i++) {
     final String key = APN_ATTRIBUTE_MAP.get(mInputParser.getAttributeName(i));
     if (key != null) {
       apnValues.put(key, mInputParser.getAttributeValue(i));
     }
   }
   // Set numeric to be canonicalized mcc/mnc like "310120", always 6 digits
   final String canonicalMccMnc =
       PhoneUtils.canonicalizeMccMnc(
           apnValues.getAsString(Telephony.Carriers.MCC),
           apnValues.getAsString(Telephony.Carriers.MNC));
   apnValues.put(Telephony.Carriers.NUMERIC, canonicalMccMnc);
   // Some of the values should not be string type, converting them to desired types
   final String authType = apnValues.getAsString(Telephony.Carriers.AUTH_TYPE);
   if (authType != null) {
     apnValues.put(Telephony.Carriers.AUTH_TYPE, parseInt(authType, -1, "apn authtype"));
   }
   final String carrierEnabled = apnValues.getAsString(Telephony.Carriers.CARRIER_ENABLED);
   if (carrierEnabled != null) {
     apnValues.put(
         Telephony.Carriers.CARRIER_ENABLED,
         parseBoolean(carrierEnabled, null, "apn carrierEnabled"));
   }
   final String bearer = apnValues.getAsString(Telephony.Carriers.BEARER);
   if (bearer != null) {
     apnValues.put(Telephony.Carriers.BEARER, parseInt(bearer, 0, "apn bearer"));
   }
   // We are at the end tag
   if (mInputParser.next() != XmlPullParser.END_TAG) {
     throw new XmlPullParserException("Apn: expecting end tag @" + xmlParserDebugContext());
   }
   // We are done parsing one APN, call the handler
   if (mApnHandler != null) {
     mApnHandler.process(apnValues);
   }
 }
Example #2
0
 /**
  * Process one mms_config.
  *
  * @throws IOException
  * @throws XmlPullParserException
  */
 private void processMmsConfig() throws IOException, XmlPullParserException {
   // Get the mcc and mnc attributes
   final String canonicalMccMnc =
       PhoneUtils.canonicalizeMccMnc(
           mInputParser.getAttributeValue(null, "mcc"),
           mInputParser.getAttributeValue(null, "mnc"));
   // We are at the start tag
   for (; ; ) {
     int nextEvent;
     // Skipping spaces
     while ((nextEvent = mInputParser.next()) == XmlPullParser.TEXT) {}
     if (nextEvent == XmlPullParser.START_TAG) {
       // Parse one mms config key/value
       processMmsConfigKeyValue(canonicalMccMnc);
     } else if (nextEvent == XmlPullParser.END_TAG) {
       break;
     } else {
       throw new XmlPullParserException(
           "MmsConfig: expecting start or end tag @" + xmlParserDebugContext());
     }
   }
 }