From 2374f26f3cebdf711aca3e253fadcf689baaf496 Mon Sep 17 00:00:00 2001 From: Nipun Nadeen De Silva Date: Sat, 16 Nov 2019 07:50:55 +0000 Subject: [PATCH] Create the display-message-configuration policy --- .../services/android/bean/DisplayMessage.java | 65 ++++++++++++++ .../wrapper/DisplayMessageBeanWrapper.java | 54 ++++++++++++ .../DeviceManagementAdminService.java | 57 +++++++++++++ .../DeviceManagementAdminServiceImpl.java | 44 ++++++++++ .../android/util/AndroidConstants.java | 1 + .../public/js/operation-mod.js | 23 ++++- .../public/js/android-policy-edit.js | 35 +++++++- .../public/templates/android-policy-edit.hbs | 84 +++++++++++++++++++ .../public/templates/android-policy-view.hbs | 80 ++++++++++++++++++ .../public/js/android-policy-operations.js | 35 +++++++- .../templates/android-policy-operations.hbs | 83 ++++++++++++++++++ 11 files changed, 556 insertions(+), 5 deletions(-) create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DisplayMessage.java create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisplayMessageBeanWrapper.java diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DisplayMessage.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DisplayMessage.java new file mode 100644 index 0000000000..20531f6f92 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/DisplayMessage.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.bean; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.Serializable; + +/** + * This class represents the information of configuring display message operation. + */ +@ApiModel(value = "LockScreenMessage", description = "This class represents the information of configuring wifi operation") +public class DisplayMessage extends AndroidOperation implements Serializable { + + @ApiModelProperty(name = "lockScreenMessage", value = "The message of the lock screen that you wish to configure", + required = true) + private String lockScreenMessage; + @ApiModelProperty(name = "settingAppSupportMessage", value = "The message of the administrators applications that you wish to configure", + required = true) + private String settingAppSupportMessage; + @ApiModelProperty(name = "disabledSettingSupportMessage", value = "The password to connect to the specified Wifi network", + required = true) + private String disabledSettingSupportMessage; + + public String getLockScreenMessage() { + return lockScreenMessage; + } + + public void setLockScreenMessage(String lockScreenMessage) { + this.lockScreenMessage = lockScreenMessage; + } + + public String getSettingAppSupportMessage() { + return settingAppSupportMessage; + } + + public void setSettingAppSupportMessage(String settingAppSupportMessage) { + this.settingAppSupportMessage = settingAppSupportMessage; + } + + public String getDisabledSettingSupportMessage() { + return disabledSettingSupportMessage; + } + + public void setDisabledSettingSupportMessage(String disabledSettingSupportMessage) { + this.disabledSettingSupportMessage = disabledSettingSupportMessage; + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisplayMessageBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisplayMessageBeanWrapper.java new file mode 100644 index 0000000000..8ef1fe644b --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/DisplayMessageBeanWrapper.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.mdm.services.android.bean.wrapper; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.mdm.services.android.bean.DisplayMessage; + +import java.util.List; + +/** + * This class is used to wrap the Wifi bean with devices. + */ +@ApiModel(value = "DisplayMessageBeanWrapper", + description = "Mapping between display message operation and device list to be applied.") +public class DisplayMessageBeanWrapper { + + @ApiModelProperty(name = "operation", value = "Information of configuring display message operation", required = true) + private DisplayMessage operation; + @ApiModelProperty(name = "deviceIDs", value = "List of device Ids", required = true) + private List deviceIDs; + + public DisplayMessage getOperation() { + return operation; + } + + public void setOperation(DisplayMessage operation) { + this.operation = operation; + } + + public List getDeviceIDs() { + return deviceIDs; + } + + public void setDeviceIDs(List deviceIDs) { + this.deviceIDs = deviceIDs; + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java index 5e1ddd7f1c..89787ea686 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java @@ -257,6 +257,12 @@ import java.util.List; description = "Send app restrictions to an application in the device", key = "perm:android:send-app-restrictions", permissions = {"/device-mgt/devices/owning-device/operations/android/send-app-conf"} + ), + @Scope( + name = "Configure display message", + description = "Configure display message on Android Device", + key = "perm:android:configure-display-message", + permissions = {"/device-mgt/devices/owning-device/operations/android/display-message"} ) } ) @@ -2052,4 +2058,55 @@ public interface DeviceManagementAdminService { value = "The properties to set the global proxy settings.", required = true) GlobalProxyBeanWrapper globalProxyBeanWrapper); + + @POST + @Path("/configure-display-message") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Sending a messages to Android Devices.", + notes = "Send a message to Android Devices.", + response = Activity.class, + tags = "Android Device Management Administrative Service", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:configure-display-message") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully sent the message.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a new display messages operation.") + }) + Response configureDisplayMessage( + @ApiParam( + name = "display-message", + value = "The properties required to send a messages. Provide the message you wish to send and the ID of the " + + "Android device. Multiple device IDs can be added by using comma separated values.", + required = true) + DisplayMessageBeanWrapper displayMessageBeanWrapper); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java index 03d7a9114b..0ed723ccee 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java @@ -37,6 +37,7 @@ package org.wso2.carbon.mdm.services.android.services.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpStatus; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; @@ -56,6 +57,7 @@ import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; import org.wso2.carbon.mdm.services.android.bean.FileTransfer; import org.wso2.carbon.mdm.services.android.bean.GlobalProxy; import org.wso2.carbon.mdm.services.android.bean.LockCode; +import org.wso2.carbon.mdm.services.android.bean.DisplayMessage; import org.wso2.carbon.mdm.services.android.bean.Notification; import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; @@ -74,6 +76,7 @@ import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.FileTransferBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.GlobalProxyBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.DisplayMessageBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper; import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; @@ -1090,6 +1093,47 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } } + @POST + @Path("/configure-display-message") + @Override + public Response configureDisplayMessage(DisplayMessageBeanWrapper displayMessageBeanWrapper) { + if (log.isDebugEnabled()) { + log.debug("Invoking 'configure-display-message' operation"); + } + + try { + if (displayMessageBeanWrapper == null || displayMessageBeanWrapper.getOperation() == null) { + String errorMessage = "The payload of the display message operation is incorrect"; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST). + setMessage(errorMessage).build()); + } + DisplayMessage configureDisplayMessage = displayMessageBeanWrapper.getOperation(); + ProfileOperation operation = new ProfileOperation(); + operation.setCode(AndroidConstants.OperationCodes.DISPLAY_MESSAGE_CONFIGURATION); + operation.setType(Operation.Type.PROFILE); + operation.setPayLoad(configureDisplayMessage.toJSON()); + + Activity activity = AndroidDeviceUtils.getOperationResponse(displayMessageBeanWrapper. + getDeviceIDs(), operation); + return Response.status(Response.Status.CREATED).entity(activity).build(); + + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST). + setMessage(errorMessage).build()); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder(). + setCode(HttpStatus.SC_INTERNAL_SERVER_ERROR).setMessage(errorMessage).build()); + } + } + private static void validateApplicationUrl(String apkUrl) { try { URL url = new URL(apkUrl); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java index 18cd1d9975..fd29cb29eb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidConstants.java @@ -151,6 +151,7 @@ public final class AndroidConstants { public static final String NOTIFIER_FREQUENCY = "NOTIFIER_FREQUENCY"; public static final String GLOBAL_PROXY = "SET_GLOBAL_PROXY"; public static final String REMOTE_APP_CONFIG = "REMOTE_APP_CONFIG"; + public static final String DISPLAY_MESSAGE_CONFIGURATION = "DISPLAY_MESSAGE_CONFIGURATION"; } public final class StatusCodes { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js index adb2d38d6c..c0a1268b3c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js @@ -110,7 +110,8 @@ var androidOperationModule = function () { "DISALLOW_BLUETOOTH_SHARING": "DISALLOW_BLUETOOTH_SHARING", "DISALLOW_REMOVE_USER": "DISALLOW_REMOVE_USER", "DISALLOW_DATA_ROAMING": "DISALLOW_DATA_ROAMING", - "CERT_ADD_OPERATION_CODE": "INSTALL_CERT" + "CERT_ADD_OPERATION_CODE": "INSTALL_CERT", + "DISPLAY_MESSAGE_CONFIGURATION_OPERATION_CODE": "DISPLAY_MESSAGE_CONFIGURATION" }; /** @@ -333,6 +334,13 @@ var androidOperationModule = function () { "CERT_LIST": listNew }; break; + case androidOperationConstants["DISPLAY_MESSAGE_CONFIGURATION_OPERATION_CODE"]: + payload = { + "lockScreenMessage": operationPayload["lockScreenMessage"], + "settingAppSupportMessage": operationPayload["settingAppSupportMessage"], + "disabledSettingSupportMessage": operationPayload["disabledSettingSupportMessage"] + }; + break; } return payload; }; @@ -717,6 +725,16 @@ var androidOperationModule = function () { } }; break; + case androidOperationConstants["DISPLAY_MESSAGE_CONFIGURATION_OPERATION_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + payload = { + "operation": { + "lockScreenMessage": operationData["lockScreenMessage"], + "settingAppSupportMessage": operationData["settingAppSupportMessage"], + "disabledSettingSupportMessage": operationData["disabledSettingSupportMessage"] + } + }; + break; default: // If the operation is neither of above, it is a command operation operationType = operationTypeConstants["COMMAND"]; @@ -757,7 +775,8 @@ var androidOperationModule = function () { "BLACKLIST_APPLICATIONS": "blacklist-applications", "PASSCODE_POLICY": "set-password-policy", "ENTERPRISE_WIPE": "enterprise-wipe", - "WIPE_DATA": "wipe" + "WIPE_DATA": "wipe", + "DISPLAY_MESSAGE_CONFIGURATION": "configure-display-message" }; return "/api/device-mgt/android/v1.0/admin/devices/" + featureMap[operationCode]; }; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js index abbbd343d3..4aa6b0a8cf 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js @@ -59,7 +59,9 @@ var androidOperationConstants = { "COSU_PROFILE_CONFIGURATION_OPERATION_CODE": "COSU_PROFILE", "ENROLLMENT_APP_INSTALL": "enrollment-app-install", "ENROLLMENT_APP_INSTALL_CODE": "ENROLLMENT_APP_INSTALL", - "CERT_ADD_OPERATION_CODE": "INSTALL_CERT" + "CERT_ADD_OPERATION_CODE": "INSTALL_CERT", + "DISPLAY_MESSAGE_CONFIGURATION_OPERATION": "display-message-configuration", + "DISPLAY_MESSAGE_CONFIGURATION_OPERATION_CODE": "DISPLAY_MESSAGE_CONFIGURATION" }; /** @@ -662,6 +664,37 @@ var validatePolicyProfile = function () { validationStatusArray.push(validationStatus); } + // Validating DISPLAY MESSAGE CONFIGURATION + if ($.inArray(androidOperationConstants["DISPLAY_MESSAGE_CONFIGURATION_OPERATION_CODE"], configuredOperations) != -1) { + // if DISPLAY_MESSAGE_CONFIGURATION policy is configured + operation = androidOperationConstants["DISPLAY_MESSAGE_CONFIGURATION_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var lockScreenMessage = $("textarea#lock-screen-message").val(); + var settingAppMessage = $("textarea#setting-app-message").val(); + var disabledSettingMessage = $("textarea#disabled-setting-message").val(); + if (!lockScreenMessage && !settingAppMessage && !disabledSettingMessage) { + validationStatus = { + "error": true, + "subErrorMsg": "Please fill at-least a one field.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating PROXY if ($.inArray(androidOperationConstants["GLOBAL_PROXY_OPERATION_CODE"], configuredOperations) !== -1) { // if PROXY is configured diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs index 835ffbdee9..e82c1132ac 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs @@ -162,6 +162,18 @@ + + + + + + Display Message Configuration + + + + +
@@ -3318,6 +3330,78 @@
+ + +
+
+ +
+
+
+ +
+ +
+ Below lock screen message is valid only when the Agent is the + device owner. +
+ +

+ + +

+ + +
+
+
+
+ + \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs index ba006b6ee5..77f5cef573 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs @@ -144,6 +144,18 @@ + + + + + + Display Message Configuration + + + + +
@@ -3235,6 +3247,74 @@
+ + +
+
+ +
+
+
+ +
+ Below lock screen message is valid only when the Agent is the + device owner. +
+ +

+ + +

+ + +
+
+
+
+ + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js index 330bdee1a0..312f56704d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js @@ -56,7 +56,9 @@ var androidOperationConstants = { "COSU_PROFILE_CONFIGURATION_OPERATION_CODE": "COSU_PROFILE", "ENROLLMENT_APP_INSTALL": "enrollment-app-install", "ENROLLMENT_APP_INSTALL_CODE": "ENROLLMENT_APP_INSTALL", - "CERTIFICATE_INSTALL": "INSTALL_CERT" + "CERTIFICATE_INSTALL": "INSTALL_CERT", + "DISPLAY_MESSAGE_CONFIGURATION_OPERATION": "display-message-configuration", + "DISPLAY_MESSAGE_CONFIGURATION_OPERATION_CODE": "DISPLAY_MESSAGE_CONFIGURATION" }; /** @@ -593,6 +595,36 @@ var validatePolicyProfile = function () { // updating validationStatusArray with validationStatus validationStatusArray.push(validationStatus); } + // Validating DISPLAY MESSAGE CONFIGURATION + if ($.inArray(androidOperationConstants["DISPLAY_MESSAGE_CONFIGURATION_OPERATION_CODE"], configuredOperations) !== -1) { + // if DISPLAY_MESSAGE_CONFIGURATION policy is configured + operation = androidOperationConstants["DISPLAY_MESSAGE_CONFIGURATION_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var lockScreenMessage = $("textarea#lock-screen-message").val(); + var settingAppMessage = $("textarea#setting-app-message").val(); + var disabledSettingMessage = $("textarea#disabled-setting-message").val(); + if (!lockScreenMessage && !settingAppMessage && !disabledSettingMessage) { + validationStatus = { + "error": true, + "subErrorMsg": "Please fill at-least a one field.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } // Validating PROXY if ($.inArray(androidOperationConstants["GLOBAL_PROXY_OPERATION_CODE"], configuredOperations) !== -1) { @@ -600,7 +632,6 @@ var validatePolicyProfile = function () { operation = androidOperationConstants["GLOBAL_PROXY_OPERATION"]; // initializing continueToCheckNextInputs to true continueToCheckNextInputs = true; - if ($("input#manual-proxy-configuration-radio-button").is(":checked")) { var proxyHost = $("input#proxy-host").val(); var proxyPort = $("input#proxy-port").val(); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs index 3eb1276195..2a4df56b1c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs @@ -170,6 +170,18 @@ + + + + + + Display Message Configuration + + + + +
@@ -3335,6 +3347,77 @@
+ + +
+
+ +
+
+
+ +
+ +
+ Below lock screen message is valid only when the Agent is the + device owner. +
+ +

+ + +

+ + +
+
+
+
+