From 82c7eefd2e17a650b5ef6296f5648e1f4deb48c3 Mon Sep 17 00:00:00 2001 From: charitha Date: Thu, 23 Nov 2017 14:39:08 +0530 Subject: [PATCH] Fix for https://github.com/wso2/product-iots/issues/1496 --- .../carbon/mdm/services/android/util/AndroidDeviceUtils.java | 4 ++-- 1 file changed, 2 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/AndroidDeviceUtils.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/AndroidDeviceUtils.java index ac99f2004..ad5f65f8d 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/AndroidDeviceUtils.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/AndroidDeviceUtils.java @@ -21,6 +21,7 @@ package org.wso2.carbon.mdm.services.android.util; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; +import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.commons.logging.Log; @@ -371,13 +372,12 @@ public class AndroidDeviceUtils { // {"name":"BATTERY_LEVEL","value":"100"},{"name":"INTERNAL_TOTAL_MEMORY","value":"0.76"}] JsonElement jsonElement = new JsonParser().parse(properties); JsonArray jsonArray = jsonElement.getAsJsonArray(); - boolean exist = false; for (JsonElement element : jsonArray) { if (element.isJsonObject()) { JsonObject jsonObject = element.getAsJsonObject(); if (jsonObject.has("name") && jsonObject.get("name").getAsString().equalsIgnoreCase(needed)) { - if (jsonObject.has("value")) { + if (jsonObject.has("value") && jsonObject.get("value") != JsonNull.INSTANCE) { return jsonObject.get("value").getAsString().replace("%", ""); } else { return "";