From 5e7370f362c63a5258c5e126af320b9358211468 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Fri, 30 Jun 2017 18:39:36 +0530 Subject: [PATCH] Fixing https://github.com/wso2/product-iots/issues/685: android sense re-enrollment fixed --- .../iot/androidsense/service/impl/AndroidSenseServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java index 3059c92792..cb575909df 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java @@ -123,7 +123,8 @@ public class AndroidSenseServiceImpl implements AndroidSenseService { deviceIdentifier.setId(deviceId); deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE); try { - if (APIUtil.getDeviceManagementService().isEnrolled(deviceIdentifier)) { + Device enrolledDevice = APIUtil.getDeviceManagementService().getDevice(deviceIdentifier); + if (enrolledDevice != null && !enrolledDevice.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) { AndroidConfiguration androidConfiguration = new AndroidConfiguration(); androidConfiguration.setTenantDomain(APIUtil.getAuthenticatedUserTenantDomain()); androidConfiguration.setMqttEndpoint(APIUtil.getMqttEndpoint());