Merge pull request #12 from milanperera/master

Refactored Android policy compliance
revert-dabc3590
Prabath Abeysekara 9 years ago
commit 8bdc613d1f

@ -59,13 +59,18 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService {
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>(); List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>();
// Parsing json string to get compliance features. // Parsing json string to get compliance features.
JsonElement jsonElement = new JsonParser().parse((String) compliancePayload); JsonElement jsonElement;
if (compliancePayload instanceof String) {
jsonElement = new JsonParser().parse((String) compliancePayload);
} else {
throw new PolicyComplianceException("Invalid policy compliance payload");
}
JsonArray jsonArray = jsonElement.getAsJsonArray(); JsonArray jsonArray = jsonElement.getAsJsonArray();
Gson gson = new Gson(); Gson gson = new Gson();
ComplianceFeature complianceFeature; ComplianceFeature complianceFeature;
for (int i = 0; i < jsonArray.size(); i++) { for (JsonElement element : jsonArray) {
complianceFeature = gson.fromJson(jsonArray.get(i), ComplianceFeature.class); complianceFeature = gson.fromJson(element, ComplianceFeature.class);
complianceFeatures.add(complianceFeature); complianceFeatures.add(complianceFeature);
} }

Loading…
Cancel
Save