/** @hide */
  public static Profile fromXml(XmlPullParser xpp, Context context)
      throws XmlPullParserException, IOException {
    String value = xpp.getAttributeValue(null, "nameres");
    int profileNameResId = -1;
    String profileName = null;

    if (value != null) {
      profileNameResId = context.getResources().getIdentifier(value, "string", "android");
      if (profileNameResId > 0) {
        profileName = context.getResources().getString(profileNameResId);
      }
    }

    if (profileName == null) {
      profileName = xpp.getAttributeValue(null, "name");
    }

    UUID profileUuid = UUID.randomUUID();
    try {
      profileUuid = UUID.fromString(xpp.getAttributeValue(null, "uuid"));
    } catch (NullPointerException e) {
      Log.w(
          TAG,
          "Null Pointer - UUID not found for "
              + profileName
              + ".  New UUID generated: "
              + profileUuid.toString());
    } catch (IllegalArgumentException e) {
      Log.w(
          TAG,
          "UUID not recognized for "
              + profileName
              + ".  New UUID generated: "
              + profileUuid.toString());
    }

    Profile profile = new Profile(profileName, profileNameResId, profileUuid);
    int event = xpp.next();
    while (event != XmlPullParser.END_TAG) {
      if (event == XmlPullParser.START_TAG) {
        String name = xpp.getName();
        if (name.equals("statusbar")) {
          profile.setStatusBarIndicator(xpp.nextText() == "yes");
        }
        if (name.equals("profileGroup")) {
          ProfileGroup pg = ProfileGroup.fromXml(xpp, context);
          profile.addProfileGroup(pg);
        }
        if (name.equals("streamDescriptor")) {
          StreamSettings sd = StreamSettings.fromXml(xpp, context);
          profile.setStreamSettings(sd);
        }
        if (name.equals("connectionDescriptor")) {
          ConnectionSettings cs = ConnectionSettings.fromXml(xpp, context);
          profile.connections.put(cs.getConnectionId(), cs);
        }
      }
      event = xpp.next();
    }

    /* we just loaded from XML, so nothing needs saving */
    profile.mDirty = false;

    return profile;
  }