|
|
@ -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 "";
|
|
|
|