|
|
@ -36,6 +36,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
|
|
@ -277,8 +278,7 @@ public class AndroidAPIUtils {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Device device = new Gson().fromJson(operation.getOperationResponse(), Device.class);
|
|
|
|
Device device = new Gson().fromJson(operation.getOperationResponse(), Device.class);
|
|
|
|
org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = convertDeviceToInfo(device);
|
|
|
|
org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = convertDeviceToInfo(device);
|
|
|
|
deviceInfo.setDeviceIdentifier(deviceIdentifier);
|
|
|
|
updateDeviceInfo(deviceIdentifier, deviceInfo);
|
|
|
|
updateDeviceInfo(deviceInfo);
|
|
|
|
|
|
|
|
} catch (DeviceDetailsMgtException e) {
|
|
|
|
} catch (DeviceDetailsMgtException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while updating the device information.", e);
|
|
|
|
throw new OperationManagementException("Error occurred while updating the device information.", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -312,26 +312,31 @@ public class AndroidAPIUtils {
|
|
|
|
private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier)
|
|
|
|
private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
// Parsing json string to get applications list.
|
|
|
|
// Parsing json string to get applications list.
|
|
|
|
JsonElement jsonElement = new JsonParser().parse(operation.getOperationResponse());
|
|
|
|
if (operation.getOperationResponse() != null) {
|
|
|
|
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
|
|
|
JsonElement jsonElement = new JsonParser().parse(operation.getOperationResponse());
|
|
|
|
Application app;
|
|
|
|
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
|
|
|
List<Application> applications = new ArrayList<Application>(jsonArray.size());
|
|
|
|
Application app;
|
|
|
|
for (JsonElement element : jsonArray) {
|
|
|
|
List<Application> applications = new ArrayList<Application>(jsonArray.size());
|
|
|
|
app = new Application();
|
|
|
|
for (JsonElement element : jsonArray) {
|
|
|
|
app.setName(element.getAsJsonObject().
|
|
|
|
app = new Application();
|
|
|
|
get(AndroidConstants.ApplicationProperties.NAME).getAsString());
|
|
|
|
app.setName(element.getAsJsonObject().
|
|
|
|
app.setApplicationIdentifier(element.getAsJsonObject().
|
|
|
|
get(AndroidConstants.ApplicationProperties.NAME).getAsString());
|
|
|
|
get(AndroidConstants.ApplicationProperties.IDENTIFIER).getAsString());
|
|
|
|
app.setApplicationIdentifier(element.getAsJsonObject().
|
|
|
|
app.setPlatform(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
get(AndroidConstants.ApplicationProperties.IDENTIFIER).getAsString());
|
|
|
|
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS) != null) {
|
|
|
|
app.setPlatform(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
app.setMemoryUsage(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS).getAsInt());
|
|
|
|
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS) != null) {
|
|
|
|
}
|
|
|
|
app.setMemoryUsage(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.USS).getAsInt());
|
|
|
|
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION) != null) {
|
|
|
|
}
|
|
|
|
app.setVersion(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION).getAsString());
|
|
|
|
if (element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION) != null) {
|
|
|
|
|
|
|
|
app.setVersion(element.getAsJsonObject().get(AndroidConstants.ApplicationProperties.VERSION).getAsString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
applications.add(app);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applications.add(app);
|
|
|
|
getApplicationManagerService().updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.error("Operation Response is null.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getApplicationManagerService().updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -344,14 +349,14 @@ public class AndroidAPIUtils {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void updateDeviceInfo(org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo)
|
|
|
|
private static void updateDeviceInfo(DeviceIdentifier deviceId, DeviceInfo deviceInfo)
|
|
|
|
throws DeviceDetailsMgtException {
|
|
|
|
throws DeviceDetailsMgtException {
|
|
|
|
|
|
|
|
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
|
|
|
DeviceInformationManager informationManager =
|
|
|
|
DeviceInformationManager informationManager =
|
|
|
|
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
|
|
|
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
|
|
|
|
|
|
|
|
|
|
|
|
informationManager.addDeviceInfo(deviceInfo);
|
|
|
|
informationManager.addDeviceInfo(deviceId, deviceInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|