Merge branch 'test' into 'application-mgt-new'

Add operation to enable/disable lock task mode of KIOSK devices

See merge request entgra/carbon-device-mgt-plugins!99
merge-requests/102/head
Dharmakeerthi Lasantha 5 years ago
commit 9524b5b90a

@ -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<String> 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<String> deviceIDs);
@POST
@Path("/mute")
@ApiOperation(

@ -500,6 +500,33 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
}
}
@POST
@Path("/change-LockTask")
@Override
public Response changeLockTask(List<String> 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

@ -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";

@ -249,6 +249,13 @@
<method>POST</method>
</Permission>
<Permission>
<name>Change LockTask mode</name>
<path>/device-mgt/admin/device/android/operation/change-LockTask</path>
<url>/admin/devices/change-LockTask</url>
<method>POST</method>
</Permission>
<Permission>
<name>Ring device</name>
<path>/device-mgt/admin/device/android/operation/ring</path>

@ -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 {

@ -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",

@ -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"},

@ -191,6 +191,26 @@
</metadata>
</Operation>
</Feature>
<Feature type="operation" code="CHANGE_LOCK_TASK_MODE">
<Name>Change LockTask</Name>
<Description>Change LockTask mode of KIOSK device</Description>
<Operation hidden="false" icon="fw-mobile">
<params/>
<metadata>
<uri>/api/device-mgt/android/v1.0/admin/devices/change-LockTask</uri>
<method>POST</method>
<contentType>application/json</contentType>
<permission>/device-mgt/devices/owning-device/operations/android/change-LockTask</permission>
<filters>
<filter>
<property>ownership</property>
<value>COPE</value>
<description>This feature is only available in COSU(KIOSK)</description>
</filter>
</filters>
</metadata>
</Operation>
</Feature>
<Feature type="operation" code="UPGRADE_FIRMWARE">
<Name>Upgrade Firmware</Name>
<Description>Upgrade Firmware</Description>

Loading…
Cancel
Save