Example usage for android.content.res XmlResourceParser close

List of usage examples for android.content.res XmlResourceParser close

Introduction

In this page you can find the example usage for android.content.res XmlResourceParser close.

Prototype

public void close();

Source Link

Document

Close this parser.

Usage

From source file:Main.java

public static String getMetaData(Context app, String name) {
    Bundle bundle = app.getApplicationInfo().metaData;
    if (bundle != null) {
        return bundle.getString(name);
    } else {//from  w  w  w .  j a  va2 s.c  om
        XmlResourceParser parser = null;
        AssetManager assmgr = null;

        try {
            assmgr = (AssetManager) AssetManager.class.newInstance();
            Method e = AssetManager.class.getDeclaredMethod("addAssetPath", new Class[] { String.class });
            e.setAccessible(true);
            int cookie = ((Integer) e.invoke(assmgr, new Object[] { app.getApplicationInfo().sourceDir }))
                    .intValue();
            if (cookie != 0) {
                String ANDROID_RESOURCES = "http://schemas.android.com/apk/res/android";
                parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
                boolean findAppMetadata = false;
                int event = parser.getEventType();
                while (event != 1) {
                    switch (event) {
                    case 2:
                        String nodeName = parser.getName();
                        String metadataName;
                        if ("meta-data".equals(nodeName)) {
                            findAppMetadata = true;
                            metadataName = parser.getAttributeValue(ANDROID_RESOURCES, "name");
                            if (metadataName.equals(name)) {
                                String var12 = parser.getAttributeValue(ANDROID_RESOURCES, "value");
                                return var12;
                            }
                        } else if (findAppMetadata) {
                            metadataName = null;
                            return metadataName;
                        }
                    default:
                        event = parser.next();
                    }
                }
            }
        } catch (Throwable var16) {
            var16.printStackTrace();
        } finally {
            if (parser != null) {
                parser.close();
            }

            if (assmgr != null) {
                assmgr.close();
            }

        }

        return null;
    }
}

From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java

public void inflateMenu(@MenuRes int menuRes) {
    if (menuRes == 0)
        return;/*www.ja  va2s  . co m*/
    getActivity().getMenuInflater().inflate(menuRes, actionMenu.getMenu());

    XmlResourceParser parser = null;
    try {
        //noinspection ResourceType
        parser = getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);
        parseMenu(parser, attrs);
    } catch (XmlPullParserException | IOException e) {
        // should not happens
        throw new InflateException("Error parsing menu XML", e);
    } finally {
        if (parser != null)
            parser.close();
    }
}

From source file:com.openAtlas.bundleInfo.maker.PackageLite.java

protected PackageLite parse(XmlResourceParser xmlResourceParser) throws Exception {
    int currentTag = xmlResourceParser.next();
    ;//from  www .ja v  a  2 s  .c  o  m
    while (currentTag != XmlPullParser.END_DOCUMENT) {
        switch (currentTag) {
        case XmlPullParser.START_DOCUMENT:

            break;
        case XmlPullParser.START_TAG:

            if (xmlResourceParser.getName().equals("manifest")) {
                parserManifestAttribute(xmlResourceParser, this);
            }

            if (xmlResourceParser.getName().equals("application")) {
                if (!parseApplication(this, (xmlResourceParser), (xmlResourceParser))) {
                    return null;
                }

                return this;
            }
            break;
        case XmlPullParser.END_DOCUMENT:
            xmlResourceParser.close();
            break;

        case XmlPullParser.END_TAG:

            break;
        default:
            break;
        }

        currentTag = xmlResourceParser.next();
    }
    //TODO  if code is code  delete next version
    //   
    //      do {
    //         index = xmlResourceParser.next();
    //         if (index == startTag) {
    //            break;
    //         }
    //      } while (index != XmlPullParser.END_DOCUMENT);
    //
    //      if (index != startTag) {
    //         //PackageLite.log.error("No start tag found");
    //         mPackageLite=null;
    //      } else if (!xmlResourceParser.getName().equals("manifest")) {
    //         //PackageLite.log.error("No <manifest> tag");
    //         mPackageLite=null;
    //      } else {
    //         mPackageLite.packageName = ((AttributeSet) xmlResourceParser).getAttributeValue(null,
    //               "package");
    //         if (mPackageLite.packageName != null && mPackageLite.packageName.length() != 0) {
    //            index = 0;
    //
    //         } else {
    //            //   PackageLite.log.error("<manifest> does not specify package");
    //            return null;
    //         }
    //
    //         for (int i = 0; i <((AttributeSet) xmlResourceParser).getAttributeCount(); i++) {
    //            String value = ((AttributeSet) xmlResourceParser).getAttributeName(i);
    //            if (value.equals("versionCode")) {
    //               mPackageLite.versionCode = ((AttributeSet) xmlResourceParser)
    //                     .getAttributeIntValue(i, 0);
    //
    //            } else if (value.equals("versionName")) {
    //               mPackageLite.versionName = ((AttributeSet) xmlResourceParser)
    //                     .getAttributeValue(i);
    //
    //            }
    //
    //         }
    //
    //         index = xmlResourceParser.getDepth() + 1;
    //         while (true) {
    //            int v1 = xmlResourceParser.next();
    //            System.out.println(xmlResourceParser.getName());
    //            if (v1 != XmlPullParser.END_DOCUMENT) {
    //               if (xmlResourceParser.getName().equals("application")) {
    //                  if (!PackageLite
    //                        .parseApplication(mPackageLite, (xmlResourceParser),
    //                              (xmlResourceParser))) {
    //                     return null;
    //                  }
    //
    //                  return mPackageLite;
    //               }
    //
    //               if (v1 == endTag && xmlResourceParser.getDepth() < index) {
    //                  break;
    //               }
    //
    //               if (v1 == endTag) {
    //                  continue;
    //               }
    //
    //               if (v1 == 4) {
    //                  continue;
    //               }
    //
    //               PackageLite.skipCurrentTag((xmlResourceParser));
    //               continue;
    //            }
    //
    //            break;
    //         }
    //
    //
    //      }

    return this;

}

From source file:com.southernstorm.tvguide.TvChannelCache.java

/**
 * Loads or reloads channel information.
 *//*from   w  w  w .  j a  va 2 s. c o m*/
public void loadChannels() {
    // Load the channels from the embedded resources first.
    if (!embeddedLoaded) {
        if (region == null || getContext() == null)
            return;
        Calendar start = new GregorianCalendar();
        XmlResourceParser parser = getContext().getResources().getXml(R.xml.channels);
        loadChannelsFromXml(parser);
        parser.close();
        embeddedLoaded = true;
        if (debug) {
            double time = ((new GregorianCalendar()).getTimeInMillis() - start.getTimeInMillis()) / 1000.0;
            System.out.println("time to parse embedded channel list: " + time);
        }
    }

    // Load the hidden-vs-shown state from the SD card.
    if (!sdLoaded && isMediaUsable()) {
        File serviceDir = new File(getFilesDir(), serviceName);
        File file = new File(serviceDir, "channels.xml");
        if (file.exists()) {
            Calendar start = new GregorianCalendar();
            try {
                FileInputStream fileStream = new FileInputStream(file);
                try {
                    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                    XmlPullParser parser = factory.newPullParser();
                    parser.setInput(fileStream, null);
                    loadChannelsFromXml(parser);
                } catch (XmlPullParserException e) {
                    // Ignore - just stop parsing at the first error.
                } finally {
                    fileStream.close();
                }
            } catch (IOException e) {
            }
            if (debug) {
                double time = ((new GregorianCalendar()).getTimeInMillis() - start.getTimeInMillis()) / 1000.0;
                System.out.println("time to parse SD config channel list: " + time);
            }
        }
        sdLoaded = true;
    }

    // Load the server's channel list to refresh data-for declarations.
    if (!mainListLoaded) {
        InputStream inputStream = null;
        Calendar lastmod = channelDataLastModified(null, null);
        Calendar now = new GregorianCalendar();
        mainListLastFetched = now;
        if (mainListUnchanged || lastmod == null
                || (now.getTimeInMillis() - lastmod.getTimeInMillis()) < (24 * 60 * 60 * 1000))
            inputStream = openChannelData(null, null); // Reuse previous list if less than 24 hours old
        mainListUnchanged = false;
        if (inputStream != null) {
            Calendar start = new GregorianCalendar();
            try {
                try {
                    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                    XmlPullParser parser = factory.newPullParser();
                    parser.setInput(inputStream, null);
                    loadChannelsFromXml(parser);
                } catch (XmlPullParserException e) {
                    // Ignore - just stop parsing at the first error.
                } finally {
                    inputStream.close();
                }
            } catch (IOException e) {
            }
            mainListLoaded = true;
            if (debug) {
                double time = ((new GregorianCalendar()).getTimeInMillis() - start.getTimeInMillis()) / 1000.0;
                System.out.println("time to parse network channel list: " + time);
            }
        } else if (!mainListFetching && isNetworkingAvailable()) {
            // Fetch the channel list for the first time.
            mainListFetching = true;
            mainListLastMod = lastmod;
            fetchChannelList();
        }
    }

    // Rebuild the active channel list.
    activeChannels.clear();
    for (TvChannel channel : channels.values()) {
        if (channel.getHiddenState() == TvChannel.HIDDEN_BY_REGION) {
            String region = channel.getRegion();
            if (region == null || !regionMatch(region))
                continue;
        } else if (channel.getHiddenState() == TvChannel.HIDDEN) {
            continue;
        }
        if (haveDataForDecls && !channel.hasDataFor())
            continue; // No data for the channel on the server, so block it.
        activeChannels.add(channel);
        if (channel.iconNeedsFetching())
            fetchIcon(channel, channel.getIconSource(), new File(channel.getIconFile()));
    }
    Collections.sort(activeChannels);

    // Notify interested parties that the active channel list has changed.
    for (TvChannelChangedListener listener : channelListeners)
        listener.channelsChanged();
}

From source file:com.bt.download.android.gui.Librarian.java

/**
 * This function returns an array of string in the following order: version name, label
 * @param apk//from ww w  . jav a 2s  . co  m
 * @return
 */
private String[] parseApk(Apk apk) {
    try {
        String[] result = new String[3];

        XmlResourceParser parser = apk.getAndroidManifest();

        boolean manifestParsed = true;
        boolean applicationParsed = false;

        while (!manifestParsed || !applicationParsed) {
            int type = parser.next();

            if (type == XmlPullParser.END_DOCUMENT) {
                break;
            }

            switch (type) {
            case XmlPullParser.START_TAG:
                String tagName = parser.getName();
                if (tagName.equals("manifest")) {
                    String versionName = parser.getAttributeValue("http://schemas.android.com/apk/res/android",
                            "versionName");
                    if (versionName != null && versionName.startsWith("@")) {
                        versionName = apk.getString(Integer.parseInt(versionName.substring(1)));
                    }
                    result[0] = versionName;
                    manifestParsed = true;
                }
                if (tagName.equals("application")) {
                    String label = parser.getAttributeValue("http://schemas.android.com/apk/res/android",
                            "label");
                    if (label != null && label.startsWith("@")) {
                        label = apk.getString(Integer.parseInt(label.substring(1)));
                    }
                    result[1] = label;
                    applicationParsed = true;
                }
                break;
            }
        }

        parser.close();

        return result;
    } catch (Throwable e) {
        return null;
    }
}

From source file:com.achep.base.ui.activities.SettingsActivity.java

/**
 * Parse the given XML file as a categories description, adding each
 * parsed categories and tiles into the target list.
 *
 * @param resourceId The XML resource to load and parse.
 * @param target     The list in which the parsed categories and tiles should be placed.
 *//*from  w  w  w  .  j a  va 2s. c  o m*/
protected final void loadDashboardFromResource(@XmlRes int resourceId,
        @NonNull List<DashboardCategory> target) {
    XmlResourceParser parser = null;
    try {
        parser = getResources().getXml(resourceId);
        AttributeSet attrs = Xml.asAttributeSet(parser);

        int type;

        for (type = parser.next(); type != XmlPullParser.END_DOCUMENT; type = parser.next()) {
            if (type == XmlPullParser.START_TAG)
                break;
        }

        String nodeName = parser.getName();
        if (!RESOURCE_TAG_DASHBOARD.equals(nodeName))
            throw new RuntimeException(String.format("XML document must start with <%s> tag; found %s at %s",
                    RESOURCE_TAG_DASHBOARD, nodeName, parser.getPositionDescription()));

        for (type = parser.next(); type != XmlPullParser.END_DOCUMENT; type = parser.next()) {
            if (type == XmlPullParser.END_TAG && parser.getDepth() <= 1 /* root tag */)
                break;
            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                continue;
            }

            switch (parser.getName()) {
            case RESOURCE_TAG_DASHBOARD_CATEGORY:
                DashboardCategory category = new DashboardCategory(this, attrs);

                final int categoryDepth = parser.getDepth();
                for (type = parser.next(); type != XmlPullParser.END_DOCUMENT; type = parser.next()) {
                    if (type == XmlPullParser.END_TAG && parser.getDepth() <= categoryDepth)
                        break;
                    if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                        continue;
                    }

                    switch (parser.getName()) {
                    case RESOURCE_TAG_DASHBOARD_TILE:
                        DashboardTile tile = new DashboardTile(this, attrs);
                        Bundle bundle = null;

                        final int tileDepth = parser.getDepth();
                        for (type = parser.next(); type != XmlPullParser.END_DOCUMENT; type = parser.next()) {
                            if (type == XmlPullParser.END_TAG && parser.getDepth() <= tileDepth)
                                break;
                            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                                continue;
                            }

                            switch (parser.getName()) {
                            case RESOURCE_TAG_DASHBOARD_TILE_EXTRA:
                                if (bundle == null) {
                                    bundle = new Bundle();
                                }

                                getResources().parseBundleExtra(RESOURCE_TAG_DASHBOARD_TILE_EXTRA, attrs,
                                        bundle);
                                XmlUtils.skipCurrentTag(parser);
                                break;
                            case RESOURCE_TAG_DASHBOARD_TILE_INTENT:
                                tile.intent = Intent.parseIntent(getResources(), parser, attrs);
                                break;
                            default:
                                XmlUtils.skipCurrentTag(parser);
                            }
                        }

                        tile.fragmentArguments = bundle;
                        category.add(tile);
                        break;
                    default:
                        XmlUtils.skipCurrentTag(parser);
                    }
                }

                target.add(category);
                break;
            default:
                XmlUtils.skipCurrentTag(parser);
            }
        }
    } catch (XmlPullParserException | IOException e) {
        throw new RuntimeException("Error parsing categories", e);
    } finally {
        if (parser != null)
            parser.close();
    }
}

From source file:com.androzic.Preferences.java

/**
 * Parse the given XML file as a header description, adding each
 * parsed Header into the target list.//from  w  w  w  . ja  v a 2s  .  com
 *
 * @param resid
 *            The XML resource to load and parse.
 * @param target
 *            The list in which the parsed headers should be placed.
 */
public void loadHeadersFromResource(int resid, List<Header> target) {
    Androzic application = Androzic.getApplication();
    XmlResourceParser parser = null;
    try {
        Resources resources = getResources();
        parser = resources.getXml(resid);
        AttributeSet attrs = Xml.asAttributeSet(parser);

        int type;
        //noinspection StatementWithEmptyBody
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
            // Parse next until start tag is found
        }

        String nodeName = parser.getName();
        if (!"preference-headers".equals(nodeName)) {
            throw new RuntimeException("XML document must start with <preference-headers> tag; found" + nodeName
                    + " at " + parser.getPositionDescription());
        }

        Bundle curBundle = null;

        final int outerDepth = parser.getDepth();
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                continue;
            }

            nodeName = parser.getName();
            if ("header".equals(nodeName)) {
                Header header = new Header();

                TypedArray sa = resources.obtainAttributes(attrs, R.styleable.PreferenceHeader);
                header.id = sa.getResourceId(R.styleable.PreferenceHeader_id, (int) HEADER_ID_UNDEFINED);
                TypedValue tv = sa.peekValue(R.styleable.PreferenceHeader_title);
                if (tv != null && tv.type == TypedValue.TYPE_STRING) {
                    if (tv.resourceId != 0) {
                        header.titleRes = tv.resourceId;
                    } else {
                        header.title = tv.string;
                    }
                }
                tv = sa.peekValue(R.styleable.PreferenceHeader_summary);
                if (tv != null && tv.type == TypedValue.TYPE_STRING) {
                    if (tv.resourceId != 0) {
                        header.summaryRes = tv.resourceId;
                    } else {
                        header.summary = tv.string;
                    }
                }
                tv = sa.peekValue(R.styleable.PreferenceHeader_breadCrumbTitle);
                if (tv != null && tv.type == TypedValue.TYPE_STRING) {
                    if (tv.resourceId != 0) {
                        header.breadCrumbTitleRes = tv.resourceId;
                    } else {
                        header.breadCrumbTitle = tv.string;
                    }
                }
                tv = sa.peekValue(R.styleable.PreferenceHeader_breadCrumbShortTitle);
                if (tv != null && tv.type == TypedValue.TYPE_STRING) {
                    if (tv.resourceId != 0) {
                        header.breadCrumbShortTitleRes = tv.resourceId;
                    } else {
                        header.breadCrumbShortTitle = tv.string;
                    }
                }
                header.iconRes = sa.getResourceId(R.styleable.PreferenceHeader_icon, 0);
                header.fragment = sa.getString(R.styleable.PreferenceHeader_fragment);
                header.help = sa.getResourceId(R.styleable.PreferenceHeader_help, 0);
                sa.recycle();

                if (curBundle == null) {
                    curBundle = new Bundle();
                }

                final int innerDepth = parser.getDepth();
                while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
                        && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
                    if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                        continue;
                    }

                    String innerNodeName = parser.getName();
                    if (innerNodeName.equals("extra")) {
                        resources.parseBundleExtra(innerNodeName, attrs, curBundle);
                        XmlUtils.skipCurrentTag(parser);

                    } else if (innerNodeName.equals("intent")) {
                        header.intent = Intent.parseIntent(resources, parser, attrs);

                    } else {
                        XmlUtils.skipCurrentTag(parser);
                    }
                }

                if (curBundle.size() > 0) {
                    header.fragmentArguments = curBundle;
                    curBundle = null;
                }

                if (header.id == R.id.pref_plugins && application.getPluginsPreferences().size() == 0)
                    continue;

                target.add(header);
            } else {
                XmlUtils.skipCurrentTag(parser);
            }
        }

    } catch (XmlPullParserException | IOException e) {
        throw new RuntimeException("Error parsing headers", e);
    } finally {
        if (parser != null)
            parser.close();
    }

}

From source file:com.android.server.MountService.java

private void readStorageListLocked() {
    mVolumes.clear();/*  w w w  . j av  a 2s .  c om*/
    mVolumeStates.clear();

    Resources resources = mContext.getResources();

    int id = com.android.internal.R.xml.storage_list;
    XmlResourceParser parser = resources.getXml(id);
    AttributeSet attrs = Xml.asAttributeSet(parser);

    try {
        XmlUtils.beginDocument(parser, TAG_STORAGE_LIST);
        while (true) {
            XmlUtils.nextElement(parser);

            String element = parser.getName();
            if (element == null)
                break;

            if (TAG_STORAGE.equals(element)) {
                TypedArray a = resources.obtainAttributes(attrs, com.android.internal.R.styleable.Storage);

                String path = a.getString(com.android.internal.R.styleable.Storage_mountPoint);
                int descriptionId = a.getResourceId(com.android.internal.R.styleable.Storage_storageDescription,
                        -1);
                CharSequence description = a
                        .getText(com.android.internal.R.styleable.Storage_storageDescription);
                boolean primary = a.getBoolean(com.android.internal.R.styleable.Storage_primary, false);
                boolean removable = a.getBoolean(com.android.internal.R.styleable.Storage_removable, false);
                boolean emulated = a.getBoolean(com.android.internal.R.styleable.Storage_emulated, false);
                int mtpReserve = a.getInt(com.android.internal.R.styleable.Storage_mtpReserve, 0);
                boolean allowMassStorage = a
                        .getBoolean(com.android.internal.R.styleable.Storage_allowMassStorage, false);
                boolean allowMtp = a.getBoolean(com.android.internal.R.styleable.Storage_allowMtp, true);
                // resource parser does not support longs, so XML value is in megabytes
                long maxFileSize = a.getInt(com.android.internal.R.styleable.Storage_maxFileSize, 0) * 1024L
                        * 1024L;

                Slog.d(TAG,
                        "got storage path: " + path + " description: " + description + " primary: " + primary
                                + " removable: " + removable + " emulated: " + emulated + " mtpReserve: "
                                + mtpReserve + " allowMassStorage: " + allowMassStorage + " maxFileSize: "
                                + maxFileSize + " allowMtp: " + allowMtp);

                if (emulated) {
                    // For devices with emulated storage, we create separate
                    // volumes for each known user.
                    mEmulatedTemplate = new StorageVolume(null, descriptionId, true, false, true, mtpReserve,
                            false, maxFileSize, null, allowMtp);

                    final UserManagerService userManager = UserManagerService.getInstance();
                    for (UserInfo user : userManager.getUsers(false)) {
                        createEmulatedVolumeForUserLocked(user.getUserHandle());
                    }

                } else {
                    if (path == null || description == null) {
                        Slog.e(TAG, "Missing storage path or description in readStorageList");
                    } else {
                        final StorageVolume volume = new StorageVolume(new File(path), descriptionId, primary,
                                removable, emulated, mtpReserve, allowMassStorage, maxFileSize, null, allowMtp);
                        addVolumeLocked(volume);

                        // Until we hear otherwise, treat as unmounted
                        mVolumeStates.put(volume.getPath(), Environment.MEDIA_UNMOUNTED);
                        volume.setState(Environment.MEDIA_UNMOUNTED);
                    }
                }

                a.recycle();
            }
        }
    } catch (XmlPullParserException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        // Compute storage ID for each physical volume; emulated storage is
        // always 0 when defined.
        int index = isExternalStorageEmulated() ? 1 : 0;
        for (StorageVolume volume : mVolumes) {
            if (!volume.isEmulated()) {
                volume.setStorageId(index++);
            }
        }
        parser.close();
    }
}

From source file:com.android.mms.MmsConfig.java

private static void loadMmsSettings(Context context) {
    XmlResourceParser parser = context.getResources().getXml(R.xml.mms_config);

    try {// w  w  w .  jav  a  2s  .  c o  m
        beginDocument(parser, "mms_config");

        while (true) {
            nextElement(parser);
            String tag = parser.getName();
            if (tag == null) {
                break;
            }
            String name = parser.getAttributeName(0);
            String value = parser.getAttributeValue(0);
            String text = null;
            if (parser.next() == XmlPullParser.TEXT) {
                text = parser.getText();
            }

            if (DEBUG) {
                Log.v(TAG, "tag: " + tag + " value: " + value + " - " + text);
            }
            if ("name".equalsIgnoreCase(name)) {
                if ("bool".equals(tag)) {
                    // bool config tags go here
                    if ("enabledMMS".equalsIgnoreCase(value)) {
                        mMmsEnabled = "true".equalsIgnoreCase(text) ? 1 : 0;
                    } else if ("enabledTransID".equalsIgnoreCase(value)) {
                        mTransIdEnabled = "true".equalsIgnoreCase(text);
                    } else if ("enabledNotifyWapMMSC".equalsIgnoreCase(value)) {
                        mNotifyWapMMSC = "true".equalsIgnoreCase(text);
                    } else if ("aliasEnabled".equalsIgnoreCase(value)) {
                        mAliasEnabled = "true".equalsIgnoreCase(text);
                    } else if ("allowAttachAudio".equalsIgnoreCase(value)) {
                        mAllowAttachAudio = "true".equalsIgnoreCase(text);
                    } else if ("enableMultipartSMS".equalsIgnoreCase(value)) {
                        mEnableMultipartSMS = "true".equalsIgnoreCase(text);
                    } else if ("enableSlideDuration".equalsIgnoreCase(value)) {
                        mEnableSlideDuration = "true".equalsIgnoreCase(text);
                    } else if ("enableMMSReadReports".equalsIgnoreCase(value)) {
                        mEnableMMSReadReports = "true".equalsIgnoreCase(text);
                    } else if ("enableSMSDeliveryReports".equalsIgnoreCase(value)) {
                        mEnableSMSDeliveryReports = "true".equalsIgnoreCase(text);
                    } else if ("enableMMSDeliveryReports".equalsIgnoreCase(value)) {
                        mEnableMMSDeliveryReports = "true".equalsIgnoreCase(text);
                        /// M: google jb.mr1 patch, group mms
                    } else if ("enableGroupMms".equalsIgnoreCase(value)) {
                        mEnableGroupMms = "true".equalsIgnoreCase(text);
                    }
                } else if ("int".equals(tag)) {
                    // int config tags go here
                    if ("maxMessageSize".equalsIgnoreCase(value)) {
                        mMaxMessageSize = Integer.parseInt(text);
                    } else if ("maxImageHeight".equalsIgnoreCase(value)) {
                        mMaxImageHeight = Integer.parseInt(text);
                    } else if ("maxImageWidth".equalsIgnoreCase(value)) {
                        mMaxImageWidth = Integer.parseInt(text);
                    }
                    /// M: @{
                    else if ("maxRestrictedImageHeight".equalsIgnoreCase(value)) {
                        mMaxRestrictedImageHeight = Integer.parseInt(text);
                    } else if ("maxRestrictedImageWidth".equalsIgnoreCase(value)) {
                        mMaxRestrictedImageWidth = Integer.parseInt(text);
                    }
                    /// @}
                    else if ("defaultSMSMessagesPerThread".equalsIgnoreCase(value)) {
                        mDefaultSMSMessagesPerThread = Integer.parseInt(text);
                    } else if ("defaultMMSMessagesPerThread".equalsIgnoreCase(value)) {
                        mDefaultMMSMessagesPerThread = Integer.parseInt(text);
                    } else if ("minMessageCountPerThread".equalsIgnoreCase(value)) {
                        mMinMessageCountPerThread = Integer.parseInt(text);
                    } else if ("maxMessageCountPerThread".equalsIgnoreCase(value)) {
                        mMaxMessageCountPerThread = Integer.parseInt(text);
                    } else if ("smsToMmsTextThreshold".equalsIgnoreCase(value)) {
                        /// M: Operator Plugin
                        mMmsConfigPlugin.setSmsToMmsTextThreshold(Integer.parseInt(text));
                    } else if ("recipientLimit".equalsIgnoreCase(value)) {
                        /// M: Operator Plugin
                        mMmsConfigPlugin.setMmsRecipientLimit(Integer.parseInt(text));
                    } else if ("httpSocketTimeout".equalsIgnoreCase(value)) {
                        mMmsConfigPlugin.setHttpSocketTimeout(Integer.parseInt(text));
                    } else if ("minimumSlideElementDuration".equalsIgnoreCase(value)) {
                        mMinimumSlideElementDuration = Integer.parseInt(text);
                    } else if ("maxSizeScaleForPendingMmsAllowed".equalsIgnoreCase(value)) {
                        mMaxSizeScaleForPendingMmsAllowed = Integer.parseInt(text);
                    } else if ("aliasMinChars".equalsIgnoreCase(value)) {
                        mAliasRuleMinChars = Integer.parseInt(text);
                    } else if ("aliasMaxChars".equalsIgnoreCase(value)) {
                        mAliasRuleMaxChars = Integer.parseInt(text);
                    } else if ("maxMessageTextSize".equalsIgnoreCase(value)) {
                        /// M: Operator Plugin
                        mMmsConfigPlugin.setMaxTextLimit(Integer.parseInt(text));
                    } else if ("maxSubjectLength".equalsIgnoreCase(value)) {
                        mMaxSubjectLength = Integer.parseInt(text);
                    }
                } else if ("string".equals(tag)) {
                    // string config tags go here
                    if ("userAgent".equalsIgnoreCase(value)) {
                        mUserAgent = text;
                    } else if ("uaProfTagName".equalsIgnoreCase(value)) {
                        mUaProfTagName = text;
                    } else if ("uaProfUrl".equalsIgnoreCase(value)) {
                        mUaProfUrl = text;
                    } else if ("httpParams".equalsIgnoreCase(value)) {
                        mHttpParams = text;
                    } else if ("httpParamsLine1Key".equalsIgnoreCase(value)) {
                        mHttpParamsLine1Key = text;
                    } else if ("emailGatewayNumber".equalsIgnoreCase(value)) {
                        mEmailGateway = text;
                    }
                }
            }
        }
    } catch (XmlPullParserException e) {
        Log.e(TAG, "loadMmsSettings caught ", e);
    } catch (NumberFormatException e) {
        Log.e(TAG, "loadMmsSettings caught ", e);
    } catch (IOException e) {
        Log.e(TAG, "loadMmsSettings caught ", e);
    } finally {
        parser.close();
    }

    String errorStr = null;

    if (getMmsEnabled() && mUaProfUrl == null) {
        errorStr = "uaProfUrl";
    }

    if (errorStr != null) {
        String err = String.format("MmsConfig.loadMmsSettings mms_config.xml missing %s setting", errorStr);
        Log.e(TAG, err);
    }
}