/**
   * Loop over a package element looking for seinfo child tags. If found return the value attribute
   * of the seinfo tag, otherwise return null. All other tags encountered will be skipped.
   *
   * @param parser an XmlPullParser object representing a package element.
   * @param pb a Policy.PolicyBuilder instance to build
   * @throws IOException
   * @throws XmlPullParserException
   * @throws IllegalArgumentException if any of the validation checks fail while parsing tag values.
   * @throws IllegalStateException if there is a duplicate seinfo tag for the current package tag.
   */
  private static void readPackageOrThrow(XmlPullParser parser, Policy.PolicyBuilder pb)
      throws IOException, XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, null, "package");
    String pkgName = parser.getAttributeValue(null, "name");

    while (parser.next() != XmlPullParser.END_TAG) {
      if (parser.getEventType() != XmlPullParser.START_TAG) {
        continue;
      }

      String tagName = parser.getName();
      if ("seinfo".equals(tagName)) {
        String seinfo = parser.getAttributeValue(null, "value");
        pb.addInnerPackageMapOrThrow(pkgName, seinfo);
        readSeinfo(parser);
      } else {
        skip(parser);
      }
    }
  }