| 160 | } |
| 161 | |
| 162 | private static class Loader { |
| 163 | // https://tools.ietf.org/id/draft-kucherawy-dmarc-base-13.xml#xml_schema |
| 164 | private DateFormat DTF; |
| 165 | private int colorWarning; |
| 166 | private int colorVerified; |
| 167 | private int colorSeparator; |
| 168 | private float stroke; |
| 169 | |
| 170 | private boolean feedback = false; |
| 171 | private boolean report_metadata = false; |
| 172 | private boolean policy_published = false; |
| 173 | private boolean record = false; |
| 174 | private boolean row = false; |
| 175 | private boolean policy_evaluated = false; |
| 176 | private boolean identifiers = false; |
| 177 | private boolean auth_results = false; |
| 178 | private String lastDomain = null; |
| 179 | private String result = null; |
| 180 | private List<Pair<String, DnsHelper.DnsRecord>> spf = null; |
| 181 | private SpannableStringBuilder ssb = new SpannableStringBuilderEx(); |
| 182 | |
| 183 | SpannableStringBuilder load(Context context, InputStream is) throws XmlPullParserException, IOException { |
| 184 | DTF = Helper.getDateTimeInstance(context, DateFormat.SHORT, DateFormat.SHORT); |
| 185 | colorWarning = Helper.resolveColor(context, R.attr.colorWarning); |
| 186 | colorVerified = Helper.resolveColor(context, R.attr.colorVerified); |
| 187 | colorSeparator = Helper.resolveColor(context, R.attr.colorSeparator); |
| 188 | stroke = context.getResources().getDisplayMetrics().density; |
| 189 | |
| 190 | XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); |
| 191 | XmlPullParser xml = factory.newPullParser(); |
| 192 | xml.setInput(is, StandardCharsets.UTF_8.name()); |
| 193 | |
| 194 | int eventType = xml.getEventType(); |
| 195 | while (eventType != XmlPullParser.END_DOCUMENT) { |
| 196 | if (eventType == XmlPullParser.START_TAG) { |
| 197 | String name = xml.getName(); |
| 198 | switch (name) { |
| 199 | case "feedback": |
| 200 | feedback = true; |
| 201 | break; |
| 202 | case "report_metadata": |
| 203 | report_metadata = true; |
| 204 | break; |
| 205 | case "policy_published": |
| 206 | policy_published = true; |
| 207 | lastDomain = null; |
| 208 | break; |
| 209 | case "record": |
| 210 | record = true; |
| 211 | break; |
| 212 | case "row": |
| 213 | row = true; |
| 214 | ssb.append("\uFFFC"); |
| 215 | ssb.setSpan(new LineSpan(colorSeparator, stroke, 0), ssb.length() - 1, ssb.length(), 0); |
| 216 | ssb.append("\n"); |
| 217 | break; |
| 218 | case "policy_evaluated": |
| 219 | policy_evaluated = true; |
nothing calls this directly
no outgoing calls
no test coverage detected