diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java index f35823785..7e2aeb6cc 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java @@ -44,6 +44,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.appmgt.mobile.utils.User; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.exceptions.RegistryException; import org.wso2.carbon.registry.core.session.UserRegistry; @@ -250,18 +251,22 @@ public class ApplicationOperationsImpl implements ApplicationOperations { List devices; List deviceList = null; try { - if (MDMAppConstants.WEBAPP.equals - (applicationOperationDevice.getPlatform())) { - deviceList = MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationDevice.getTenantId()). - getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername()); - } else { - deviceList = MDMServiceAPIUtils - .getDeviceManagementService(applicationOperationDevice.getTenantId()). - getDevicesOfUser(applicationOperationDevice.getCurrentUser().getUsername(), - applicationOperationDevice.getPlatform()); - } - devices = new ArrayList<>(deviceList.size()); + DeviceManagementProviderService deviceManagementService = MDMServiceAPIUtils + .getDeviceManagementService(applicationOperationDevice.getTenantId()); + final String username = applicationOperationDevice.getCurrentUser().getUsername(); + if (MDMAppConstants.WEBAPP.equals + (applicationOperationDevice.getPlatform())) { + deviceList = deviceManagementService. + getDevicesOfUser(username); + } else { + deviceList = deviceManagementService. + getDevicesOfUser(username, + MDMAppConstants.ANDROID); + deviceList.addAll(deviceManagementService. + getDevicesOfUser(username, + MDMAppConstants.IOS)); + } + devices = new ArrayList<>(deviceList.size()); if(log.isDebugEnabled()){ log.debug("device list got from mdm "+ deviceList.toString()); }