From 033067fa8f9da97efdb4175da866255576c81333 Mon Sep 17 00:00:00 2001 From: achala piyarathna Date: Fri, 5 Jul 2019 08:53:49 +0000 Subject: [PATCH] Implement enable device backup service restriction in android plugins --- .../public/js/operation-bar.js | 2 ++ .../public/js/operation-mod.js | 6 ++++++ .../public/templates/android-policy-edit.hbs | 11 +++++++++++ .../public/templates/android-policy-view.hbs | 12 ++++++++++++ .../public/templates/android-policy-operations.hbs | 11 +++++++++++ .../mobile/android/impl/AndroidFeatureManager.java | 8 ++++++++ .../src/main/resources/devicetypes/android.xml | 4 ++++ 7 files changed, 54 insertions(+) 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-bar/public/js/operation-bar.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-bar/public/js/operation-bar.js index 3482f2da5f..3aa3e7d42a 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-bar/public/js/operation-bar.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-bar/public/js/operation-bar.js @@ -323,6 +323,7 @@ var generatePayload = function (operationCode, operationData, deviceList) { payload = { "operation": { "CAMERA": operationData["cameraEnabled"], + "BACKUP_SERVICE": operationData["enableBackupService"], "DISALLOW_ADJUST_VOLUME": operationData["disallowAdjustVolumeEnabled"], "DISALLOW_CONFIG_BLUETOOTH": operationData["disallowConfigBluetooth"], "DISALLOW_CONFIG_CELL_BROADCASTS": operationData["disallowConfigCellBroadcasts"], @@ -546,6 +547,7 @@ var androidOperationConstants = { "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", "VPN_OPERATION_CODE": "VPN", "CAMERA_OPERATION_CODE": "CAMERA", + "BACKUP_SERVICE_CODE": "BACKUP_SERVICE", "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", "WIFI_OPERATION_CODE": "WIFI", "WIPE_OPERATION_CODE": "WIPE_DATA", 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 81fa182a85..5243b2fdb4 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 @@ -50,6 +50,7 @@ var androidOperationModule = function () { "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", "VPN_OPERATION_CODE": "VPN", "CAMERA_OPERATION_CODE": "CAMERA", + "BACKUP_SERVICE_CODE": "BACKUP_SERVICE", "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", "WIFI_OPERATION_CODE": "WIFI", "GLOBAL_PROXY_OPERATION_CODE": "GLOBAL_PROXY", @@ -333,6 +334,7 @@ var androidOperationModule = function () { payload = { "operation": { "CAMERA": operationData["cameraEnabled"], + "BACKUP_SERVICE": operationData["enableBackupService"], "DISALLOW_ADJUST_VOLUME": operationData["disallowAdjustVolumeEnabled"], "DISALLOW_CONFIG_BLUETOOTH": operationData["disallowConfigBluetooth"], "DISALLOW_CONFIG_CELL_BROADCASTS": operationData["disallowConfigCellBroadcasts"], @@ -707,6 +709,7 @@ var androidOperationModule = function () { "WIFI": "configure-wifi", "GLOBAL_PROXY": "configure-global-proxy", "CAMERA": "control-camera", + "BACKUP_SERVICE": "enable-backup", "VPN": "configure-vpn", "DEVICE_LOCK": "lock-devices", "DEVICE_UNLOCK": "unlock-devices", @@ -1141,6 +1144,9 @@ var androidOperationModule = function () { } else if (featureCode == androidOperationConstants["DISALLOW_ADJUST_VOLUME"]) { restrictions["disallowAdjustVolumeEnabled"] = restriction["enabled"]; continue; + } else if (featureCode == androidOperationConstants["BACKUP_SERVICE_CODE"]) { + restrictions["enableBackupService"] = restriction["enabled"]; + continue; } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_BLUETOOTH"]) { restrictions["disallowConfigBluetooth"] = restriction["enabled"]; continue; 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 62c5b887c9..319f06510b 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 @@ -862,6 +862,17 @@
+
+ +
+
{{/unless}} 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 f3b145e497..e2a9ab3167 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 @@ -866,6 +866,18 @@ + +
+ +
+
{{/unless}} 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 effc7fe742..9ffd23e9aa 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 @@ -880,6 +880,17 @@
+
+ +
+
{{/unless}} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java index f2f17fba88..33d6a3a831 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java @@ -209,11 +209,19 @@ public class AndroidFeatureManager implements FeatureManager { feature.setName("wifi"); feature.setDescription("Setting up wifi configuration"); supportedFeatures.add(feature); + feature = new Feature(); feature.setCode("CAMERA"); feature.setName("camera"); feature.setDescription("Enable or disable camera"); supportedFeatures.add(feature); + + feature = new Feature(); + feature.setCode("BACKUP_SERVICE"); + feature.setName("Set Backup Service"); + feature.setDescription("set backup service"); + supportedFeatures.add(feature); + feature = new Feature(); feature.setCode("EMAIL"); feature.setName("Email"); diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml index 0b64a6d4da..9a7b9a428d 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml @@ -605,6 +605,10 @@ Fetch device logcat Fetch device logcat + + Enable Backup Service + Enable or disable backup service +