diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java index 86d3fd3a2bb..4bf8c21685c 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/Device.java @@ -17,6 +17,7 @@ package cdm.api.android; import cdm.api.android.util.AndroidAPIUtils; +import com.google.gson.Gson; import com.google.gson.JsonObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -70,7 +71,8 @@ public class Device { } switch (status) { case 1: - return Response.status(200).entity(result).build(); + String response = new Gson().toJson(result); + return Response.status(200).entity(response).build(); case -1: return Response.status(500).entity(msg).build(); } @@ -83,7 +85,7 @@ public class Device { int status = 0; String msg = ""; DeviceManagementService dmService; - org.wso2.carbon.device.mgt.common.Device device = null; + org.wso2.carbon.device.mgt.common.Device device = new org.wso2.carbon.device.mgt.common.Device(); try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); @@ -111,7 +113,8 @@ public class Device { } switch (status) { case 1: - return Response.status(200).entity(device).build(); + String response = new Gson().toJson(device); + return Response.status(200).entity(response).build(); case -1: return Response.status(500).entity(msg).build(); } diff --git a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java index f9f32a125f4..94391d40aeb 100644 --- a/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java +++ b/product/modules/agents/android/jax-rs/src/main/java/cdm/api/android/util/AndroidAPIUtils.java @@ -31,7 +31,6 @@ public class AndroidAPIUtils { public static Device convertToDeviceObject(String jsonString) { JsonObject obj = new Gson().fromJson(jsonString, JsonObject.class); Device device = new Device(); - device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); if (obj.get(AndroidConstants.DeviceConstants.DEVICE_MAC_KEY) != null) { device.setDeviceIdentifier(