|
|
@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
|
|
|
|
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.device.details.DeviceInfo;
|
|
|
@ -32,15 +31,21 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
|
|
|
|
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.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.StatusTag;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.SyncmlDocument;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.SyncmlHeader;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.ItemTag;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.WindowsOperationException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.ResultsTag;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.SyncmlBody;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile;
|
|
|
|
import org.wso2.carbon.device.mgt.mobile.windows.api.operations.*;
|
|
|
|
|
|
|
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -226,6 +231,22 @@ public class OperationHandler {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateDisenrollOperation(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
|
|
|
|
|
|
|
List<? extends Operation> pendingDeviceInfoOperations;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
pendingDeviceInfoOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while getting pending operations.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Operation operation : pendingDeviceInfoOperations) {
|
|
|
|
|
|
|
|
if (PluginConstants.OperationCodes.DISENROLL.equals(operation.getCode())) {
|
|
|
|
|
|
|
|
operation.setStatus(Operation.Status.COMPLETED);
|
|
|
|
|
|
|
|
updateStatus(deviceIdentifier.getId(), pendingDeviceInfoOperations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateDeviceInfoStatus(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
|
|
|
public void updateDeviceInfoStatus(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
|
|
|
List<? extends Operation> pendingDeviceInfoOperations;
|
|
|
|
List<? extends Operation> pendingDeviceInfoOperations;
|
|
|
@ -294,6 +315,9 @@ public class OperationHandler {
|
|
|
|
if (OperationCode.Command.TOTAL_RAM.getCode().equals(itemTag.getSource().getLocURI())) {
|
|
|
|
if (OperationCode.Command.TOTAL_RAM.getCode().equals(itemTag.getSource().getLocURI())) {
|
|
|
|
updateDeviceInfo(syncmlDocument);
|
|
|
|
updateDeviceInfo(syncmlDocument);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Command.BATTERY_CHARGE_REMAINING.equals(itemTag.getSource().getLocURI())) {
|
|
|
|
|
|
|
|
updateDeviceInfo(syncmlDocument);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UpdateUriOperations(syncmlDocument);
|
|
|
|
UpdateUriOperations(syncmlDocument);
|
|
|
@ -562,6 +586,7 @@ public class OperationHandler {
|
|
|
|
String totalRAM;
|
|
|
|
String totalRAM;
|
|
|
|
String deviceID = null;
|
|
|
|
String deviceID = null;
|
|
|
|
String totalStorage;
|
|
|
|
String totalStorage;
|
|
|
|
|
|
|
|
Double battery;
|
|
|
|
|
|
|
|
|
|
|
|
List<ItemTag> deviceInformations = syncmlDocument.getBody().getResults().getItem();
|
|
|
|
List<ItemTag> deviceInformations = syncmlDocument.getBody().getResults().getItem();
|
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
|
DeviceInfo deviceInfo = new DeviceInfo();
|
|
|
@ -598,6 +623,10 @@ public class OperationHandler {
|
|
|
|
if (OperationCode.Info.DEV_ID.getCode().equals(source)) {
|
|
|
|
if (OperationCode.Info.DEV_ID.getCode().equals(source)) {
|
|
|
|
deviceID = item.getData();
|
|
|
|
deviceID = item.getData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OperationCode.Info.BATTERY_CHARGE_REMAINING.getCode().equals(source)) {
|
|
|
|
|
|
|
|
battery = Double.valueOf(item.getData());
|
|
|
|
|
|
|
|
deviceInfo.setBatteryLevel(battery);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(deviceID);
|
|
|
|
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(deviceID);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -636,6 +665,18 @@ public class OperationHandler {
|
|
|
|
} catch (OperationManagementException e) {
|
|
|
|
} catch (OperationManagementException e) {
|
|
|
|
throw new WindowsOperationException("Error occurred while updating Device Location operation status.");
|
|
|
|
throw new WindowsOperationException("Error occurred while updating Device Location operation status.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void checkForDeviceWipe(List<? extends Operation> pendingDeviceInfoOperations
|
|
|
|
|
|
|
|
, DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Operation operation : pendingDeviceInfoOperations) {
|
|
|
|
|
|
|
|
if (PluginConstants.OperationCodes.WIPE_DATA.equals(operation.getCode())) {
|
|
|
|
|
|
|
|
operation.setStatus(Operation.Status.COMPLETED);
|
|
|
|
|
|
|
|
updateStatus(deviceIdentifier.getId(), pendingDeviceInfoOperations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|