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 beebf032c..5e1ddd7f1 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 @@ -156,6 +156,12 @@ import java.util.List; key = "perm:android:reboot", permissions = {"/device-mgt/devices/owning-device/operations/android/reboot"} ), + @Scope( + name = "Change LockTask mode", + description = "Change LoockTask mode of KIOSK devices", + key = "perm:android:change-LockTask", + permissions = {"/device-mgt/devices/owning-device/operations/android/change-LockTask"} + ), @Scope( name = "Mute Device", description = "Mute Android devices", @@ -1055,6 +1061,66 @@ public interface DeviceManagementAdminService { required = true) List deviceIDs); + @POST + @Path("/change-LockTask") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Change LockTask mode of KIOSK Devices", + notes = "Enable or disable LockTask mode of KIOSK devices.", + response = Activity.class, + tags = "Android Device Management Administrative Service", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:change-LockTask") + }) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the change LockTask operation.", + 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 = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding the new change LockTask operation.") + }) + Response changeLockTask( + @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ", + required = true) + List deviceIDs); + @POST @Path("/mute") @ApiOperation( 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 b8d1a7af9..03d7a9114 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 @@ -500,6 +500,33 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } } + @POST + @Path("/change-LockTask") + @Override + public Response changeLockTask(List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Android change LockTask mode operation"); + } + + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_TASK_MODE); + operation.setType(Operation.Type.COMMAND); + Activity activity = AndroidDeviceUtils.getOperationResponse(deviceIDs, 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(400l).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(500l).setMessage(errorMessage).build()); + } + } + @POST @Path("/mute") @Override 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 787253c4a..18cd1d997 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 @@ -137,6 +137,7 @@ public final class AndroidConstants { public static final String ENCRYPT_STORAGE = "ENCRYPT_STORAGE"; public static final String DEVICE_RING = "DEVICE_RING"; public static final String DEVICE_REBOOT = "REBOOT"; + public static final String CHANGE_LOCK_TASK_MODE = "CHANGE_LOCK_TASK_MODE"; public static final String UPGRADE_FIRMWARE = "UPGRADE_FIRMWARE"; public static final String NOTIFICATION = "NOTIFICATION"; public static final String POLICY_BUNDLE = "POLICY_BUNDLE"; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml index 1c3c034b8..0b0e8150f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml @@ -249,6 +249,13 @@ POST + + Change LockTask mode + /device-mgt/admin/device/android/operation/change-LockTask + /admin/devices/change-LockTask + POST + + Ring device /device-mgt/admin/device/android/operation/ring 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/DeviceManagementAdminServiceTests.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java index 30e5474d7..a8a267beb 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/DeviceManagementAdminServiceTests.java @@ -169,6 +169,15 @@ public class DeviceManagementAdminServiceTests { Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); } + @Test + public void testChangeLockTask() + throws DeviceManagementException, OperationManagementException, InvalidDeviceException { + mockDeviceManagementService(); + Response response = deviceManagementAdminService.changeLockTask(TestUtils.getDeviceIds()); + Assert.assertNotNull(response); + Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode()); + } + @Test public void testMuteDevice() throws DeviceManagementException, OperationManagementException, InvalidDeviceException { 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 06f588011..adb2d38d6 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 @@ -745,6 +745,7 @@ var androidOperationModule = function () { "APPLICATION_LIST": "get-application-list", "DEVICE_RING": "ring", "DEVICE_REBOOT": "reboot", + "CHANGE_LOCK_TASK_MODE": "change-LockTask", "UPGRADE_FIRMWARE": "upgrade-firmware", "DEVICE_MUTE": "mute", "NOTIFICATION": "send-notification", @@ -775,6 +776,7 @@ var androidOperationModule = function () { "WIPE_DATA": "fw-delete", "DEVICE_RING": "fw-dial-up", "DEVICE_REBOOT": "fw-refresh", + "CHANGE_LOCK_TASK_MODE": "fw-mobile", "UPGRADE_FIRMWARE": "fw-hardware", "DEVICE_MUTE": "fw-mute", "NOTIFICATION": "fw-message", 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.type-view/private/config.json 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.type-view/private/config.json index 82394b258..17511f509 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.type-view/private/config.json +++ 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.type-view/private/config.json @@ -36,6 +36,7 @@ "perm:android:unlock-devices", "perm:android:control-camera", "perm:android:reboot", + "perm:android:change-LockTask", "perm:android:logcat", "perm:android:send-app-restrictions" ], @@ -74,6 +75,11 @@ "filter" : {"property" : "ownership", "value" : "COPE", "text": "This feature is only available in COPE/COSU"}, "permission": "/device-mgt/devices/owning-device/operations/android/reboot" }, + "CHANGE_LOCK_TASK_MODE": { + "icon": "fw-mobile", + "filter" : {"property" : "ownership", "value" : "COPE", "text": "This feature is only available in COSU(KIOSK)"}, + "permission": "/device-mgt/devices/owning-device/operations/android/change-LockTask" + }, "UPGRADE_FIRMWARE": { "icon": "fw-hardware", "filter" : {"property" : "ownership", "value" : "COPE", "text": "This feature is only available in COPE/COSU"}, 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 6f99ea30c..40e84c21a 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 @@ -191,6 +191,26 @@ + + Change LockTask + Change LockTask mode of KIOSK device + + Upgrade Firmware Upgrade Firmware