diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java index 6a03fa962f..0a87cd668e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java @@ -62,14 +62,16 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { return complianceData; } List complianceFeatures = new ArrayList(); - + List nonComplianceFeatures = new ArrayList<>(); + String compliancePayloadString = new Gson().toJson(compliancePayload); // Parsing json string to get compliance features. JsonElement jsonElement; - if (compliancePayload instanceof String) { - jsonElement = new JsonParser().parse((String) compliancePayload); + if (compliancePayloadString instanceof String) { + jsonElement = new JsonParser().parse(compliancePayloadString); } else { throw new PolicyComplianceException("Invalid policy compliance payload"); } + JsonArray jsonArray = jsonElement.getAsJsonArray(); Gson gson = new Gson(); ComplianceFeature complianceFeature; @@ -79,14 +81,15 @@ public class AndroidPolicyMonitoringService implements PolicyMonitoringService { complianceFeatures.add(complianceFeature); } - complianceData.setComplianceFeatures(complianceFeatures); - for (ComplianceFeature cf : complianceFeatures) { if (!cf.isCompliant()) { complianceData.setStatus(false); + nonComplianceFeatures.add(cf); break; } } + + complianceData.setComplianceFeatures(nonComplianceFeatures); return complianceData; }