public static boolean checkIsSupportedFeature(String featureName, Context context) { HashMap<String, AppSupportFeature> featureEntity = SupportedFeature.getInstance(context); boolean isSupported = false; if (featureEntity != null && featureEntity.size() > 0) { AppSupportFeature appSupportFeature = featureEntity.get(featureName); isSupported = appSupportFeature.isSupported(); } return isSupported; }
public static synchronized HashMap<String, AppSupportFeature> getInstance(Context context) { if (features == null) { InputStream inputStream = context.getResources().openRawResource(R.raw.app_supported_feature_config); XML2Feature xml2Feature = new XML2Feature(); try { android.util.Xml.parse(inputStream, Xml.Encoding.UTF_8, xml2Feature); List<AppSupportFeature> featuresList = xml2Feature.getFeatures(); if (featuresList != null && featuresList.size() > 0) { features = new HashMap<String, AppSupportFeature>(); for (AppSupportFeature appSupportFeature : featuresList) { features.put(appSupportFeature.getName(), appSupportFeature); } } } catch (IOException e) { LOG.error("Parse feature config error", e); } catch (SAXException e) { LOG.error("Parse feature config error", e); } finally { IOUtils.close(inputStream); } } return features; }