From c5d1eaa21bf77f977215574739d92f0606271f07 Mon Sep 17 00:00:00 2001 From: mharindu Date: Thu, 2 Jun 2016 17:11:05 +0530 Subject: [PATCH] Fixed issue in location service --- .../carbon/mdm/services/android/util/AndroidAPIUtils.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java index 6b55b844f..98ab67adc 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java @@ -287,7 +287,10 @@ public class AndroidAPIUtils { } else if (AndroidConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) { try { DeviceLocation location = new Gson().fromJson(operation.getOperationResponse(), DeviceLocation.class); - if (location != null) { + // reason for checking "location.getLatitude() != null" because when device fails to provide + // device location and send status instead, above Gson converter create new location object + // with null attributes + if (location != null && location.getLatitude() != null) { location.setDeviceIdentifier(deviceIdentifier); updateDeviceLocation(location); } @@ -295,7 +298,6 @@ public class AndroidAPIUtils { throw new OperationManagementException("Error occurred while updating the device location.", e); } } - getDeviceManagementService().updateOperation(deviceIdentifier, operation); }