|
|
@ -24,6 +24,7 @@ import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
|
|
|
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
|
|
@ -165,7 +166,7 @@ public class OperationHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/**
|
|
|
|
* Update status of the ring operation.
|
|
|
|
* Update status of the ring operation.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param status Ring status of the device.
|
|
|
|
* @param status Ring status of the device.
|
|
|
@ -193,7 +194,7 @@ public class OperationHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/**
|
|
|
|
* Update the status of the DataWipe operation.
|
|
|
|
* Update the status of the DataWipe operation.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param status Status of the data wipe.
|
|
|
|
* @param status Status of the data wipe.
|
|
|
@ -222,6 +223,23 @@ public class OperationHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateDeviceInfoStatus(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
|
|
|
|
|
|
|
List<? extends Operation> pendingDeviceInfoOperations;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
pendingDeviceInfoOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred in getting pending operation.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Operation operation : pendingDeviceInfoOperations) {
|
|
|
|
|
|
|
|
if (PluginConstants.OperationCodes.DEVICE_INFO.equals(operation.getCode())) {
|
|
|
|
|
|
|
|
operation.setStatus(Operation.Status.COMPLETED);
|
|
|
|
|
|
|
|
updateStatus(deviceIdentifier.getId(), pendingDeviceInfoOperations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get pending operations.
|
|
|
|
* Get pending operations.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -231,13 +249,20 @@ public class OperationHandler {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<? extends Operation> getPendingOperations(SyncmlDocument syncmlDocument)
|
|
|
|
public List<? extends Operation> getPendingOperations(SyncmlDocument syncmlDocument)
|
|
|
|
throws OperationManagementException, WindowsOperationException {
|
|
|
|
throws OperationManagementException, WindowsOperationException {
|
|
|
|
|
|
|
|
SyncmlHeader syncmlHeader = syncmlDocument.getHeader();
|
|
|
|
|
|
|
|
SyncmlBody syncmlBody = syncmlDocument.getBody();
|
|
|
|
List<? extends Operation> pendingOperations;
|
|
|
|
List<? extends Operation> pendingOperations;
|
|
|
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
|
|
|
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource().getLocURI());
|
|
|
|
syncmlDocument.getHeader().getSource().getLocURI());
|
|
|
|
int sessionId = syncmlHeader.getSessionId();
|
|
|
|
|
|
|
|
int msgId = syncmlHeader.getMsgID();
|
|
|
|
|
|
|
|
if (!(PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID == msgId &&
|
|
|
|
|
|
|
|
PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) {
|
|
|
|
|
|
|
|
if ((syncmlBody.getResults() != null)) {
|
|
|
|
|
|
|
|
updateDeviceInfo(syncmlDocument);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
UpdateUriOperations(syncmlDocument);
|
|
|
|
UpdateUriOperations(syncmlDocument);
|
|
|
|
generateComplianceFeatureStatus(syncmlDocument);
|
|
|
|
generateComplianceFeatureStatus(syncmlDocument);
|
|
|
|
|
|
|
|
|
|
|
|
pendingOperations = WindowsAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
|
|
|
pendingOperations = WindowsAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
|
|
|
return pendingOperations;
|
|
|
|
return pendingOperations;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -486,4 +511,61 @@ public class OperationHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateDeviceInfo(SyncmlDocument syncmlDocument) throws WindowsOperationException {
|
|
|
|
|
|
|
|
String softwareVersion;
|
|
|
|
|
|
|
|
String imsi;
|
|
|
|
|
|
|
|
String imei;
|
|
|
|
|
|
|
|
String model;
|
|
|
|
|
|
|
|
String vendor;
|
|
|
|
|
|
|
|
String totalRAM;
|
|
|
|
|
|
|
|
String deviceID = null;
|
|
|
|
|
|
|
|
String totalStorage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ItemTag> deviceInformations = syncmlDocument.getBody().getResults().getItem();
|
|
|
|
|
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
|
|
|
|
|
for (ItemTag item : deviceInformations) {
|
|
|
|
|
|
|
|
String source = item.getSource().getLocURI();
|
|
|
|
|
|
|
|
if (OperationCode.Info.SOFTWARE_VERSION.getCode().equals(source)) {
|
|
|
|
|
|
|
|
softwareVersion = item.getData();
|
|
|
|
|
|
|
|
deviceInfo.setOsVersion(softwareVersion);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.IMSI.getCode().equals(source)) {
|
|
|
|
|
|
|
|
imsi = item.getData();
|
|
|
|
|
|
|
|
deviceInfo.setIMSI(imsi);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.IMEI.getCode().equals(source)) {
|
|
|
|
|
|
|
|
imei = item.getData();
|
|
|
|
|
|
|
|
deviceInfo.setIMEI(imei);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.DEVICE_MODEL.getCode().equals(source)) {
|
|
|
|
|
|
|
|
model = item.getData();
|
|
|
|
|
|
|
|
deviceInfo.setDeviceModel(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.VENDOR.getCode().equals(source)) {
|
|
|
|
|
|
|
|
vendor = item.getData();
|
|
|
|
|
|
|
|
deviceInfo.setVendor(vendor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.TOTAL_RAM.getCode().equals(source)) {
|
|
|
|
|
|
|
|
totalRAM = item.getData();
|
|
|
|
|
|
|
|
deviceInfo.setAvailableRAMMemory(Double.parseDouble(totalRAM));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.TOTAL_STORAGE.getCode().equals(source)) {
|
|
|
|
|
|
|
|
totalStorage = item.getData();
|
|
|
|
|
|
|
|
deviceInfo.setInternalAvailableMemory(Double.parseDouble(totalStorage));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.DEV_ID.getCode().equals(source)) {
|
|
|
|
|
|
|
|
deviceID = item.getData();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(deviceID);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
WindowsAPIUtils.updateDeviceInfo(deviceIdentifier, deviceInfo);
|
|
|
|
|
|
|
|
updateDeviceInfoStatus(deviceIdentifier);
|
|
|
|
|
|
|
|
} catch (org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException e) {
|
|
|
|
|
|
|
|
throw new WindowsOperationException("Error occurred while adding Device info.");
|
|
|
|
|
|
|
|
} catch (OperationManagementException e) {
|
|
|
|
|
|
|
|
throw new WindowsOperationException("Error occurred while updating Device info operation status.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|