Merge pull request #850 from charithag/master

Fix for https://github.com/wso2/product-iots/issues/1496
revert-dabc3590
Ruwan 7 years ago committed by GitHub
commit bb0097986a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,6 +21,7 @@ package org.wso2.carbon.mdm.services.android.util;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import org.apache.commons.logging.Log; 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"}] // {"name":"BATTERY_LEVEL","value":"100"},{"name":"INTERNAL_TOTAL_MEMORY","value":"0.76"}]
JsonElement jsonElement = new JsonParser().parse(properties); JsonElement jsonElement = new JsonParser().parse(properties);
JsonArray jsonArray = jsonElement.getAsJsonArray(); JsonArray jsonArray = jsonElement.getAsJsonArray();
boolean exist = false;
for (JsonElement element : jsonArray) { for (JsonElement element : jsonArray) {
if (element.isJsonObject()) { if (element.isJsonObject()) {
JsonObject jsonObject = element.getAsJsonObject(); JsonObject jsonObject = element.getAsJsonObject();
if (jsonObject.has("name") if (jsonObject.has("name")
&& jsonObject.get("name").getAsString().equalsIgnoreCase(needed)) { && 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("%", ""); return jsonObject.get("value").getAsString().replace("%", "");
} else { } else {
return ""; return "";

Loading…
Cancel
Save