adding Windows 10 location support

revert-dabc3590
Hasunie 8 years ago
parent ff5659ec1a
commit 223a973cda

@ -218,6 +218,8 @@ public final class PluginConstants {
public static final String BATTERY_CHARGE_REMAINING = "BATTERY_CHARGE_REMAINING";
public static final String BATTERY_ESTIMATED_RUNTIME = "BATTERY_ESTIMATED_RUNTIME";
public static final String MOBILE_ID = "MOBILE_ID";
public static final String LONGITUDE = "LONGITUDE";
public static final String LATITUDE = "LATITUDE";
}
@ -267,6 +269,11 @@ public final class PluginConstants {
public static final String DEVICE_PASSWORD_STATUS = "DEVICE_PASSWORD_STATUS";
public static final String DEVICE_PASSCODE_DELETE = "DEVICE_PASSCODE_DELETE";
public static final String DEVICE_INFO = "DEVICE_INFO";
public static final String POLICY_REVOKE = "POLICY_REVOKE";
public static final String DEVICE_LOCATION = "DEVICE_LOCATION";
public static final String LONGITUDE = "LONGITUDE";
public static final String LATITUDE = "LATITUDE";
public static final String DEVICE_REBOOT = "DEVICE_REBOOT";
}
/**

@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
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.notification.mgt.NotificationManagementService;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
@ -239,4 +240,16 @@ public class WindowsAPIUtils {
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
informationManager.addDeviceInfo(deviceId, deviceInfo);
}
/**
* This method is used to update device location.
* @param deviceLocation Device coordination related information.
* @throws DeviceDetailsMgtException Error occurs while updating Device location.
*/
public static void updateDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
DeviceInformationManager informationManager =
(DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null);
informationManager.addDeviceLocation(deviceLocation);
}
}

@ -43,8 +43,6 @@ public class OperationCode {
ENCRYPT_STORAGE_STATUS("./Vendor/MSFT/PolicyManager/Device/Security/RequireDeviceEncryption"),
DEVICE_PASSWORD_STATUS("./Vendor/MSFT/PolicyManager/Device/DeviceLock/DevicePasswordEnabled"),
DEVICE_PASSCODE_DELETE("./Vendor/MSFT/PolicyManager/My/DeviceLock"),
LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"),
LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"),
// Windows10 operation codes
TOTAL_RAM("./DevDetail/Ext/Microsoft/TotalRAM"),
@ -56,6 +54,8 @@ public class OperationCode {
BATTERY_STATUS("./Vendor/MSFT/DeviceStatus/Battery/Status"),
BATTERY_CHARGE_REMAINING("./Vendor/MSFT/DeviceStatus/Battery/EstimatedChargeRemaining"),
BATTERY_ESTIMATED_RUNTIME("./Vendor/MSFT/DeviceStatus/Battery/EstimatedRuntime"),
LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"),
LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"),
TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors");
private final String code;
@ -91,7 +91,10 @@ public class OperationCode {
BATTERY_STATUS("./Vendor/MSFT/DeviceStatus/Battery/Status"),
BATTERY_CHARGE_REMAINING("./Vendor/MSFT/DeviceStatus/Battery/EstimatedChargeRemaining"),
BATTERY_ESTIMATED_RUNTIME("./Vendor/MSFT/DeviceStatus/Battery/EstimatedRuntime"),
TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors");
LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"),
LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"),
TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors"),
DEVICE_REBOOT("./Vendor/MSFT/Reboot/RebootNow");
private final String code;

@ -25,11 +25,13 @@ import org.json.JSONObject;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
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.DeviceLocation;
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.NotificationManagementService;
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.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.util.WindowsAPIUtils;
import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile;
@ -239,6 +241,33 @@ public class OperationHandler {
}
}
public void updateDeviceLocationStatus(SyncmlDocument syncmlDocument) throws OperationManagementException {
List<? extends Operation> pendingDataOperations;
List<StatusTag> statuses = syncmlDocument.getBody().getStatus();
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
syncmlDocument.getHeader().getSource().getLocURI());
try {
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
} catch (DeviceManagementException e) {
throw new OperationManagementException("Error occurred in getting pending operation.");
}
for (Operation operation : pendingDataOperations) {
if (PluginConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) {
for (StatusTag statusTag : statuses) {
if (Constants.GET.equals(statusTag.getCommand()) && statusTag.getTargetReference() != null
&& OperationCode.Command.LATITUDE.getCode().equals(statusTag.getTargetReference())) {
if (Constants.SyncMLResponseCodes.ACCEPTED.equals(statusTag.getData())) {
operation.setStatus(Operation.Status.COMPLETED);
} else {
operation.setStatus(Operation.Status.ERROR);
}
}
}
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
pendingDataOperations);
}
}
}
/**
* Get pending operations.
@ -253,14 +282,20 @@ public class OperationHandler {
SyncmlBody syncmlBody = syncmlDocument.getBody();
List<? extends Operation> pendingOperations;
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.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)) {
List<StatusTag> statuses = syncmlBody.getStatus();
for (StatusTag status : statuses ) {
if (OperationCode.Command.LATITUDE.getCode().equals(status.getTargetReference()) &&
Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) {
updateLocation(syncmlDocument);
}
if (OperationCode.Command.TOTAL_RAM.getCode().equals(status.getTargetReference()) &&
Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) {
if ((syncmlBody.getResults() != null)) {
updateDeviceInfo(syncmlDocument);
}
}
}
UpdateUriOperations(syncmlDocument);
generateComplianceFeatureStatus(syncmlDocument);
pendingOperations = WindowsAPIUtils.getDeviceManagementService().getPendingOperations(deviceIdentifier);
@ -568,4 +603,33 @@ public class OperationHandler {
throw new WindowsOperationException("Error occurred while updating Device info operation status.");
}
}
private void updateLocation(SyncmlDocument syncmlDocument) throws WindowsOperationException {
List<ItemTag> deviceInformations = syncmlDocument.getBody().getResults().getItem();
DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(
syncmlDocument.getHeader().getSource().getLocURI());
DeviceLocation deviceLocation = new DeviceLocation();
deviceLocation.setDeviceIdentifier(deviceIdentifier);
for (ItemTag item : deviceInformations) {
String source = item.getSource().getLocURI();
if (OperationCode.Info.LONGITUDE.getCode().equals(source)) {
String longitude = item.getData();
deviceLocation.setLongitude(Double.parseDouble(longitude));
}
if (OperationCode.Info.LATITUDE.getCode().equals(source)) {
Double latitude = Double.parseDouble(item.getData());
deviceLocation.setLatitude(latitude);
}
}
try {
WindowsAPIUtils.updateDeviceLocation(deviceLocation);
updateDeviceLocationStatus(syncmlDocument);
} catch (DeviceDetailsMgtException e) {
throw new WindowsOperationException("Error occurred while updating Device Location.");
} catch (OperationManagementException e) {
throw new WindowsOperationException("Error occurred while updating Device Location operation status.");
}
}
}

@ -240,7 +240,6 @@ public class OperationReply {
List<ItemTag> replaceItems = new ArrayList<>();
SequenceTag monitorSequence = new SequenceTag();
List<Operation> deviceInfoOperations;
if (operations != null) {
for (Operation operation : operations) {
Operation.Type type = operation.getType();
@ -293,6 +292,23 @@ public class OperationReply {
SequenceTag sequence = buildSequence(operation, sequenceElement);
syncmlBody.setSequence(sequence);
}
if (PluginConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) {
Operation longitudeOperation = new Operation();
Operation latitudeOperation = new Operation();
longitudeOperation.setCode(PluginConstants.OperationCodes.LONGITUDE);
latitudeOperation.setCode(PluginConstants.OperationCodes.LATITUDE);
List<Operation> deviceLocationOperations = new ArrayList<>();
deviceLocationOperations.add(latitudeOperation);
deviceLocationOperations.add(longitudeOperation);
for (Operation infoOperation : deviceLocationOperations) {
ItemTag deviceInfo = appendGetInfo(infoOperation);
getElements.add(deviceInfo);
}
}
if (PluginConstants.OperationCodes.DEVICE_REBOOT.equals(operation.getCode())) {
execElement = executeCommand(operation);
executeElements.add(execElement);
}
if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode()))) {
GetTag monitorGetElement = new GetTag();
List<ItemTag> monitorItems;
@ -561,8 +577,7 @@ public class OperationReply {
return execElement;
}
public SequenceTag buildSequence(Operation operation, SequenceTag sequenceElement) throws
JSONException,
public SequenceTag buildSequence(Operation operation, SequenceTag sequenceElement) throws JSONException,
SyncmlOperationException {
sequenceElement.setCommandId(operation.getId());
@ -580,7 +595,6 @@ public class OperationReply {
sequenceElement.setExec(execElement);
sequenceElement.setGet(getElements);
return sequenceElement;
} else if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode()))) {
List<? extends Operation> policyOperations;
try {

@ -62,73 +62,6 @@ function onRequest(context) {
viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"];
}
}
if (filteredDeviceData["initialDeviceInfo"]) {
viewModel["deviceInfoAvailable"] = true;
if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) {
viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"];
}
if (!filteredDeviceData["latestDeviceInfo"]) {
if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) {
if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] != "0") {
viewModel["osBuildDate"] = new Date(filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] * 1000);
}
}
if (filteredDeviceData["initialDeviceInfo"]["LATITUDE"] && filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]) {
viewModel["location"] = {};
viewModel["location"]["latitude"] = filteredDeviceData["initialDeviceInfo"]["LATITUDE"];
viewModel["location"]["longitude"] = filteredDeviceData["initialDeviceInfo"]["LONGITUDE"];
}
if (filteredDeviceData["initialDeviceInfo"]["VENDOR"] && filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) {
viewModel["vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"];
viewModel["model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"];
}
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]) {
if (deviceType == "android") {
viewModel["BatteryLevel"] = {};
viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"];
viewModel["internalMemory"] = {};
viewModel["internalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else {
viewModel["internalMemory"]["usage"] = 0;
}
viewModel["externalMemory"] = {};
viewModel["externalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) {
viewModel["externalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100;
} else {
viewModel["externalMemory"]["usage"] = 0;
}
} else if (deviceType == "ios") {
viewModel["BatteryLevel"] = {};
viewModel["BatteryLevel"]["value"] = Math. round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BatteryLevel"] * 10000) / 100;
viewModel["internalMemory"] = {};
viewModel["internalMemory"]["total"] = Math.
round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 100) / 100;
if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) {
viewModel["internalMemory"]["usage"] = Math.
round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] -
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"])
/ filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100;
} else {
viewModel["internalMemory"]["usage"] = 0;
}
}
}
}
}
if (filteredDeviceData["latestDeviceInfo"]) {
viewModel["deviceInfoAvailable"] = true;
if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"]) {

@ -32,7 +32,7 @@ parser.getResult();
var os = parser.getOS();
var platform = os.name;
if (platform != "Windows Phone") {
if (platform != "Windows Phone" && platform != "Windows") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else if (session.get("lastAccessedPage") != "login-agent") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");

@ -27,7 +27,7 @@ parser.getResult();
var os = parser.getOS();
var platform = os.name;
if (platform != "Windows Phone") {
if (platform != "Windows Phone" && platform != "Windows") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else if (session.get("lastAccessedPage") != "license-agent") {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");

@ -24,11 +24,27 @@
<License>
<Language>en_US</Language>
<Version>1.0.0</Version>
<Text>This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, Inc., regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device management program, and the loading to and removal from Your Device and Your use of certain applications and any associated software and user documentation, whether provided in "online" or electronic format, used in connection with the operation of or provision of services to WSO2, Inc., BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.
<Text>This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, Inc.,
regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device management
program, and the loading to and removal from Your Device and Your use of certain applications and any
associated software and user documentation, whether provided in "online" or electronic format, used in
connection with the operation of or provision of services to WSO2, Inc.,
BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE,
AND THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS
DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1)
THIS IS A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.
IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.
You agree that: (1) You understand and agree to be bound by the terms and conditions contained in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or the cessation of Your relationship with SoR (including termination of Your employment if You are an employee or expiration or termination of Your applicable franchise or supply agreement if You are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all rights not expressly granted herein.
You agree that: (1) You understand and agree to be bound by the terms and conditions
contained in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter
into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right,
without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of
Your Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or
the cessation of Your relationship with SoR (including termination of Your employment
if You are an employee or expiration or termination of Your applicable franchise or supply agreement
if You are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly
reserves all rights not expressly granted herein.
</Text>
</License>
@ -64,32 +80,44 @@
<Features>
<Feature code="DISENROLL">
<Name>Disenroll</Name>
<Description>Lock the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/disenroll-devices" method="POST" type="application/json">
<Description>Dis-enrol the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/disenroll-devices" method="POST"
type="application/json">
</Operation>
</Feature>
<Feature code="WIPE_DATA">
<Name>Wipe Data</Name>
<Description>Lock the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/wipe-devices" method="POST" type="application/json">
<Description>Wipe the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/wipe-devices" method="POST"
type="application/json">
</Operation>
</Feature>
<Feature code="DEVICE_RING">
<Name>Ring</Name>
<Description>Lock the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/ring-devices" method="POST" type="application/json">
<Description>Ring the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/ring-devices" method="POST"
type="application/json">
</Operation>
</Feature>
<Feature code="DEVICE_LOCK">
<Name>Device Lock</Name>
<Description>Lock the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/lock-devices" method="POST" type="application/json">
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/lock-devices" method="POST"
type="application/json">
</Operation>
</Feature>
<Feature code="LOCK_RESET">
<Name>Device Lock Reset</Name>
<Description>Lock the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/lock-reset-devices" method="POST" type="application/json">
<Description>Lock Reset the device</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/lock-reset-devices" method="POST"
type="application/json">
</Operation>
</Feature>
<Feature code="DEVICE_LOCATION">
<Name>Location</Name>
<Description>Request coordinates of device location</Description>
<Operation context="/api/device-mgt/windows/v1.0/admin/devices/location" method="POST"
type="application/json">
</Operation>
</Feature>
<Feature code="DEVICE_INFO">

Loading…
Cancel
Save