From b00e84db0bd20c780feab62b634e238909b1503c Mon Sep 17 00:00:00 2001 From: Ace Date: Mon, 24 Jun 2019 14:53:54 +0530 Subject: [PATCH 01/18] Adding information bits to signify when an operation can be carried out --- .../operation-bar.hbs | 4 +++- .../public/templates/operation-bar.hbs | 4 +++- .../public/templates/android-policy-edit.hbs | 5 ++--- .../public/templates/android-policy-view.hbs | 10 ++++++++-- .../public/templates/android-policy-operations.hbs | 4 ++-- .../src/main/resources/devicetypes/android.xml | 3 ++- 6 files changed, 20 insertions(+), 10 deletions(-) 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/operation-bar.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.operation-bar/operation-bar.hbs index df84b7e50..c41797a2c 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/operation-bar.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.operation-bar/operation-bar.hbs @@ -120,7 +120,9 @@ + data-param-type="form" + data-toggle="tooltip" + title="{{this.helper}}"/> {{this.label}}
{{/equal}} 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/templates/operation-bar.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.operation-bar/public/templates/operation-bar.hbs index 2fd7b7990..c76e48859 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/templates/operation-bar.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.operation-bar/public/templates/operation-bar.hbs @@ -120,7 +120,9 @@ + data-param-type="form" + data-toggle="tooltip" + title="{{this.helper}}"/> {{this.label}}
{{/equal}} 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 faeb8bcb6..28dac3063 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 @@ -508,9 +508,8 @@

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 be24a42f5..f93acffe7 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 @@ -756,8 +756,14 @@ -
- +
+ +
+

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 50a1bd835..5ff8daf82 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 @@ -132,7 +132,8 @@ checkbox hard-lock - + + This feature is only available in OEM Mode. From 8efd8c74dbc677f5d7c3e6c021880586b33f4e80 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Mon, 24 Jun 2019 15:14:26 +0530 Subject: [PATCH 02/18] Modify android disenroll device API to support permanently delete device --- .../device/test/util/TestDeviceManager.java | 5 ++++ .../services/DeviceManagementService.java | 23 ++++++++++++++- .../impl/DeviceManagementServiceImpl.java | 28 ++++++++++++++----- .../android/DeviceManagementServiceTests.java | 4 +-- .../android/impl/AndroidDeviceManager.java | 6 ++++ .../windows/impl/WindowsDeviceManager.java | 6 ++++ 6 files changed, 62 insertions(+), 10 deletions(-) diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java index 78197c0ce..58d8b7749 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java @@ -63,6 +63,11 @@ public class TestDeviceManager implements DeviceManager { return true; } + @Override + public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException { + return true; + } + @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { return true; 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/DeviceManagementService.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/DeviceManagementService.java index bb172a619..59898ff89 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/DeviceManagementService.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/DeviceManagementService.java @@ -15,6 +15,22 @@ * specific language governing permissions and limitations * under the License. * + * + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://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.services; @@ -40,6 +56,7 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; @@ -406,6 +423,10 @@ public interface DeviceManagementService { @ApiParam( name = "id", value = "The unique device identifier.") - @PathParam("id") String id); + @PathParam("id") String id, + @ApiParam( + name = "permanentDelete", + value = "Boolean flag indicating whether to permanently delete the device.") + @QueryParam("permanentDelete") boolean permanentDelete); } 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/DeviceManagementServiceImpl.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/DeviceManagementServiceImpl.java index 0322bd5e0..8b5b49738 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/DeviceManagementServiceImpl.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/DeviceManagementServiceImpl.java @@ -78,6 +78,7 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.ArrayList; @@ -446,26 +447,39 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @DELETE @Path("/{id}") @Override - public Response disEnrollDevice(@PathParam("id") String id) { + public Response disEnrollDevice(@PathParam("id") String id, + @QueryParam("permanentDelete") boolean permanentDelete) { boolean result; DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(id); try { - result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); + if (permanentDelete) { + result = AndroidAPIUtils.getDeviceManagementService().deleteDevice(deviceIdentifier); + } else { + result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); + } if (result) { + String msg = "Android device that carries id '" + id + "' is successfully "; Message responseMessage = new Message(); responseMessage.setResponseCode(Response.Status.OK.toString()); - responseMessage.setResponseMessage("Android device that carries id '" + id + - "' has successfully dis-enrolled"); + if (permanentDelete) { + responseMessage.setResponseMessage(msg + "deleted"); + } else { + responseMessage.setResponseMessage(msg + "dis-enrolled"); + } return Response.status(Response.Status.OK).entity(responseMessage).build(); } else { Message responseMessage = new Message(); responseMessage.setResponseCode(Response.Status.NOT_FOUND.toString()); - responseMessage.setResponseMessage("Android device that carries id '" + id + - "' has not been dis-enrolled"); + responseMessage.setResponseMessage("Android device that carries id '" + id + "' is not available"); return Response.status(Response.Status.NOT_FOUND).entity(responseMessage).build(); } } catch (DeviceManagementException e) { - String msg = "Error occurred while dis-enrolling the Android device that carries the id '" + id + "'"; + String msg = "Error occurred while %s the Android device that carries the id '" + id + "'"; + if (permanentDelete) { + msg = String.format(msg, "deleting"); + } else { + msg = String.format(msg, "dis-enrolling"); + } log.error(msg, e); throw new UnexpectedServerErrorException( new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build()); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java index dc16b5d43..b1b3de01e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementServiceTests.java @@ -300,7 +300,7 @@ public class DeviceManagementServiceTests { public void testDisEnrollDeviceSuccess() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId()); + Response response = deviceManagementService.disEnrollDevice(TestUtils.getDeviceId(), false); Assert.assertNotNull(response); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -309,7 +309,7 @@ public class DeviceManagementServiceTests { public void testDisenrollUnSuccess() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { mockDeviceManagementService(); - Response response = deviceManagementService.disEnrollDevice("1234"); + Response response = deviceManagementService.disEnrollDevice("1234", false); Assert.assertNotNull(response); Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); } 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/AndroidDeviceManager.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/AndroidDeviceManager.java index 63df2b80d..33bb666b9 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/AndroidDeviceManager.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/AndroidDeviceManager.java @@ -220,6 +220,12 @@ public class AndroidDeviceManager implements DeviceManager { return true; } + @Override + public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException { + //Returning false since AndroidDeviceManager is not used instead DeviceTypeManager is used. + return false; + } + @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { boolean isEnrolled = false; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java index 33752a2d1..9688d8cb0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java @@ -168,6 +168,12 @@ public class WindowsDeviceManager implements DeviceManager { return true; } + @Override + public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException { + //Returning false since WindowsDeviceManager is not used instead DeviceTypeManager is used. + return false; + } + @Override public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { boolean isEnrolled = false; From bd8d89b53a84379946fca815b553196221bfc06f Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Mon, 24 Jun 2019 16:39:49 +0530 Subject: [PATCH 03/18] Update devicemgt core version to latest --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1573decb5..597997657 100644 --- a/pom.xml +++ b/pom.xml @@ -1242,7 +1242,7 @@ 1.1.1 - 3.2.6 + 3.2.7-SNAPSHOT [3.1.0, 4.0.0) From 281e0a636e7c2243c92ca4fd317db9208d0db8da Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Tue, 25 Jun 2019 19:37:15 +0530 Subject: [PATCH 04/18] Update pending operations status of device to be disenrolled --- .../impl/DeviceManagementServiceImpl.java | 1 + .../android/util/AndroidDeviceUtils.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) 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/DeviceManagementServiceImpl.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/DeviceManagementServiceImpl.java index 8b5b49738..a595bdba7 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/DeviceManagementServiceImpl.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/DeviceManagementServiceImpl.java @@ -455,6 +455,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { if (permanentDelete) { result = AndroidAPIUtils.getDeviceManagementService().deleteDevice(deviceIdentifier); } else { + AndroidDeviceUtils.updateDisEnrollOperationStatus(deviceIdentifier); result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier); } if (result) { 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/AndroidDeviceUtils.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/AndroidDeviceUtils.java index 0e6319f9a..a6c949957 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/AndroidDeviceUtils.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/AndroidDeviceUtils.java @@ -572,4 +572,25 @@ public class AndroidDeviceUtils { } } + /** + * Update status of pending operations to error when a dis-enroll operation is triggered. + * + * @param deviceIdentifier Identifier of the device + * @throws DeviceManagementException + */ + public static void updateDisEnrollOperationStatus(DeviceIdentifier deviceIdentifier) + throws DeviceManagementException { + try { + List pendingOperations = getPendingOperations(deviceIdentifier); + for (Operation operation : pendingOperations) { + operation.setStatus(Operation.Status.ERROR); + AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); + } + } catch (OperationManagementException e) { + String msg = "Error occurred while retrieving pending operations to update operation statuses of " + + "device to be dis-enrolled"; + log.error(msg); + throw new DeviceManagementException(msg, e); + } + } } From 60c5c625bbad5b72a2e2270cb392279f0f721c5e Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Tue, 25 Jun 2019 21:36:48 +0530 Subject: [PATCH 05/18] Fix typo in setting device status --- .../cdmf.unit.device.type.android.device-view/device-view.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.device-view/device-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.device-view/device-view.hbs index 09c6fe7e4..b814fc2a7 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.device-view/device-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.device-view/device-view.hbs @@ -16,7 +16,7 @@ data-type="{{device.type}}" data-ownership="{{device.ownership}}" data-owner="{{device.owner}}" - data-status="{{devicamera-enabledce.status}}" + data-status="{{device.status}}" data-deviceinfoservice="{{device.deviceInfoServiceAPI}}" data-devicelocationservice="{{device.deviceLocationServiceAPI}}"> {{device.owner}}'s {{device.name}} From a6f0a716816122ea773151971076baac48dc5410 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Wed, 26 Jun 2019 05:57:41 +0530 Subject: [PATCH 06/18] Check null of pending operations before updating status --- .../mdm/services/android/util/AndroidDeviceUtils.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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/AndroidDeviceUtils.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/AndroidDeviceUtils.java index a6c949957..12ac7ef61 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/AndroidDeviceUtils.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/AndroidDeviceUtils.java @@ -582,9 +582,11 @@ public class AndroidDeviceUtils { throws DeviceManagementException { try { List pendingOperations = getPendingOperations(deviceIdentifier); - for (Operation operation : pendingOperations) { - operation.setStatus(Operation.Status.ERROR); - AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); + if (pendingOperations != null && !pendingOperations.isEmpty()) { + for (Operation operation : pendingOperations) { + operation.setStatus(Operation.Status.ERROR); + AndroidAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); + } } } catch (OperationManagementException e) { String msg = "Error occurred while retrieving pending operations to update operation statuses of " + From c3d75251782ddc44ccd8131afc56edf9254e8a84 Mon Sep 17 00:00:00 2001 From: Pahansith Gunathilake Date: Wed, 26 Jun 2019 03:56:12 +0000 Subject: [PATCH 07/18] Fix issue with cert file read --- .../public/js/android-policy-edit.js | 12 ++++++------ .../public/templates/android-policy-edit.hbs | 8 ++++---- .../public/templates/android-policy-view.hbs | 8 ++++---- .../public/js/android-policy-operations.js | 9 ++++----- .../public/templates/android-policy-operations.hbs | 8 ++++---- 5 files changed, 22 insertions(+), 23 deletions(-) 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 f8e7c65fa..c34646467 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 @@ -174,14 +174,14 @@ var ovpnConfigUploaded = function () { }; var certConfigUploaded = function (val) { - var certFileInput = document.getElementById("cert-file-field"); - if ('files' in certFileInput) { - if (certFileInput.files.length === 1) { + var certFileInput = $(val); + if (certFileInput[0].files) { + if (certFileInput[0].files.length === 1) { var reader = new FileReader(); - reader.onload = function (progressEvent) { + reader.onload = function(progressEvent){ var txt = ""; var lines = this.result.split('\n'); - for (var line = 0; line < lines.length; line++) { + for(var line = 0; line < lines.length; line++){ console.log(lines[line]); if (lines[line].charAt(0) !== '#') { txt += lines[line] + '\n'; @@ -191,7 +191,7 @@ var certConfigUploaded = function (val) { //console.log(document.getElementById ("cert-config").value); $(val).next().val(txt); }; - reader.readAsText(certFileInput.files[0]); + reader.readAsText(certFileInput[0].files[0]); } } }; 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 28dac3063..62c5b887c 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 @@ -78,9 +78,9 @@ - + - Secure Certificates + Certificates Install @@ -1431,7 +1431,7 @@ data-operation-code="INSTALL_CERT">
- + - Secure Certificate + Certificate Install @@ -2327,7 +2327,7 @@ data-operation-code="INSTALL_CERT">
- + - Secure Certificate + Certificate Install @@ -2346,7 +2346,7 @@ data-operation-code="INSTALL_CERT">
Date: Fri, 28 Jun 2019 14:49:02 +0530 Subject: [PATCH 08/18] Change app restrictions operation name --- .../src/main/resources/devicetypes/android.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 5ff8daf82..0b64a6d4d 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 @@ -610,8 +610,8 @@ Unlock the device - Wipe Data - Factory reset the device + Send app restriction + Send remote configurations to an app

+
+ +
+
{{/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 f3b145e49..e2a9ab316 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 effc7fe74..9ffd23e9a 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 f2f17fba8..33d6a3a83 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 0b64a6d4d..9a7b9a428 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 +